浏览代码

Weenier 168otc项目部署 0630

wesmiler 3 年之前
父节点
当前提交
b117a1a564
共有 3 个文件被更改,包括 30 次插入9 次删除
  1. 11 7
      app/Models/CacheModel.php
  2. 9 0
      app/Services/Api/MemberPaymentService.php
  3. 10 2
      app/Services/Api/MemberService.php

+ 11 - 7
app/Models/CacheModel.php

@@ -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;
     }
 

+ 9 - 0
app/Services/Api/MemberPaymentService.php

@@ -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');
+    }
+
 
 }

+ 10 - 2
app/Services/Api/MemberService.php

@@ -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;
     }