@@ -102,7 +102,7 @@ class CacheModel extends Model
}
$cache_key = implode("_", $arg_list);
- return "models:" . $cache_key;
+ return "models:".$cache_key;
/**
@@ -201,13 +201,17 @@ class CacheModel extends Model
*/
public function getCacheFunc($funcName, $id = '')
{
-
- $arg_list = func_get_args();
- if ($this->table) {
- array_shift($arg_list);
+ $cache_key = $this->getCacheKey($funcName, $id);
+ $data = $this->getCache($cache_key);
+ if (!$data) {
+ $arg_list = func_get_args();
+ if ($this->table) {
+ array_shift($arg_list);
+ }
+ $act = "cache" . ucfirst($funcName);
+ $data = call_user_func_array(array($this, $act), $arg_list);
+ $this->setCache($cache_key, $data, rand(1, 3));
- $act = "cache" . ucfirst($funcName);
- $data = call_user_func_array(array($this, $act), $arg_list);
return $data;
@@ -70,5 +70,14 @@ class MemberPaymentService extends BaseService
return $list? $list->toArray() : [];
+ /**
+ * 是否已经设置了收款方式
+ * @param $userId
+ * @return mixed
+ */
+ public function checkHasByUser($userId){
+ return $this->model->where(['user_id'=> $userId,'status'=>1])->count('id');
+
@@ -56,12 +56,20 @@ class MemberService extends BaseService
public function getInfo($where, array $field=[])
+ $field = $field? $field : ['id','username','realname','nickname','openid','idcard','source','idcard_check','safe_level','user_type','member_level','usdt_num','user_type','status','credit','avatar'];
if(is_array($where)){
$info = $this->model->where($where)->select($field)->first();
}else{
- $info = $this->model->getInfo((int)$where);
+ $info = $this->model->where(['id'=> (int)$where])->select($field)->first();
- $info['usdt_num'] = isset($info['usdt_num'])? moneyFormat($info['usdt_num'], 4) : '0.0000';
+ if($info){
+ $info['avatar'] = $info['avatar']? get_image_url($info['avatar']) : '';
+ $info['idcard'] = $info['idcard']? get_image_url($info['idcard']) : '';
+ $info['usdt_num'] = isset($info['usdt_num'])? moneyFormat($info['usdt_num'], 4) : '0.0000';
+ $info['is_collection'] = MemberPaymentService::make()->checkHasByUser($info['id']);
return $info;