wesmiler vor 2 Jahren
Ursprung
Commit
279cffcf68

+ 1 - 2
app/Http/Controllers/Api/v1/MerchantController.php

@@ -23,8 +23,7 @@ class MerchantController extends webApp
     public function info()
     {
         $type = request()->post('type', 'detail');
-        $id = request()->post('id', 0);
-        $info = MerchantService::make()->getInfoById($id, $type, $this->userId);
+        $info = MerchantService::make()->getInfoById($this->userId, $type);
         if($info){
             return showJson(1010, true, $info);
         }else{

+ 6 - 18
app/Services/Api/MerchantService.php

@@ -149,9 +149,9 @@ class MerchantService extends BaseService
      * @param string $type
      * @return array|mixed
      */
-    public function getInfoById($id, $type='info', $userId=0)
+    public function getInfoById($userId, $type='info')
     {
-        $cacheKey = "caches:merch:{$type}_{$id}";
+        $cacheKey = "caches:merch:{$type}_{$userId}";
         $info = RedisService::get($cacheKey);
         if($info){
             return $info;
@@ -159,7 +159,7 @@ class MerchantService extends BaseService
         $field = ['a.id','a.name','a.user_id','a.type','a.logo','a.category','a.business_scope','a.balance','a.usdt','a.service_time','a.deposit','a.delivery_fee','a.bonus_rate','a.power_rate','a.status','a.trade_status','b.username','b.nickname'];
         $info = $this->model->from('merchant as a')->with(['category'])
             ->leftJoin('member as b','b.id','=','a.user_id')
-            ->where(['a.id'=> $id,'a.mark'=>1,'b.mark'=>1])
+            ->where(['a.user_id'=> $userId,'a.mark'=>1,'b.mark'=>1])
             ->select($field)
             ->first();
         $info = $info? $info->toArray() : [];
@@ -173,21 +173,9 @@ class MerchantService extends BaseService
                 $info['albums'] = $info['albums']? get_images_preview($info['albums']) : [];
             }
 
-            $info['service_status'] = 2;
-            $info['service_time'] = isset($info['service_time']) && $info['service_time']? $info['service_time']:'08点~22点';
-            $serviceTime = $info['service_time']? str_replace('~','~',$info['service_time']):'';
-            $times = $serviceTime? explode('~',$serviceTime) : [];
-            $times[0] = isset($times[0]) && $times[0]? $times[0] : '08点';
-            $times[1] = isset($times[1]) && $times[1]? $times[1] : '22点';
-            if($times && date('H点')>= $times[0] && date('H点')<=$times[1]){
-                $info['service_status'] = 1;
-            }
-
-            if($info['trade_status'] != 1){
-                $info['service_status'] = 2;
-            }
-
-            RedisService::set($cacheKey, $info, rand(3, 5));
+            $info['day_usdt'] = moneyFormat(AccountLogService::make()->getCountDataByDate($info['id'],1,2,1),2);
+            $info['total_usdt'] = moneyFormat(AccountLogService::make()->getCountDataByDate($info['id'],1,2,0),2);
+            RedisService::set($cacheKey, $info, rand(2, 3));
         }
 
         return $info;