Sfoglia il codice sorgente

wesmiler 抢表商城

APPLE 3 anni fa
parent
commit
a98443cc4f
1 ha cambiato i file con 25 aggiunte e 1 eliminazioni
  1. 25 1
      app/Services/Common/TradeService.php

+ 25 - 1
app/Services/Common/TradeService.php

@@ -55,7 +55,6 @@ class TradeService extends BaseService
         return self::$instance;
         return self::$instance;
     }
     }
 
 
-
     /**
     /**
      * @param $params
      * @param $params
      * @param int $pageSize
      * @param int $pageSize
@@ -70,6 +69,7 @@ class TradeService extends BaseService
         $parentId = isset($params['parent_id']) ? $params['parent_id'] : 0;
         $parentId = isset($params['parent_id']) ? $params['parent_id'] : 0;
         $isAppeal = isset($params['is_appeal']) ? $params['is_appeal'] : 0;
         $isAppeal = isset($params['is_appeal']) ? $params['is_appeal'] : 0;
         $sellUid = isset($params['sell_uid']) ? $params['sell_uid'] : 0;
         $sellUid = isset($params['sell_uid']) ? $params['sell_uid'] : 0;
+        $type = isset($params['type']) ? $params['type'] : 0;
         if ($shopId > 0) {
         if ($shopId > 0) {
             $where['a.shop_id'] = $shopId;
             $where['a.shop_id'] = $shopId;
         }
         }
@@ -92,6 +92,11 @@ class TradeService extends BaseService
             ->leftJoin('shop as s', 's.id', '=', 'g.shop_id')
             ->leftJoin('shop as s', 's.id', '=', 'g.shop_id')
             ->where($where)
             ->where($where)
             ->where('a.status','>', 0)
             ->where('a.status','>', 0)
+            ->where(function($query) use($type){
+                if($type == 1){
+                    $query->where('create_time','>=', strtotime(date('Y-m-d')));
+                }
+            })
             ->where(function ($query) use ($params) {
             ->where(function ($query) use ($params) {
                 $keyword = isset($params['keyword']) ? $params['keyword'] : '';
                 $keyword = isset($params['keyword']) ? $params['keyword'] : '';
                 if ($keyword) {
                 if ($keyword) {
@@ -996,5 +1001,24 @@ class TradeService extends BaseService
         }
         }
     }
     }
 
 
+    public function clearByDay()
+    {
+        $day = ConfigService::make()->getConfigByCode('clear_trade_time');
+        $day = $day? $day : 2;
+        $cacheKey = "caches:task:clearTrade:d{$day}_".date('Ymd');
+        if(RedisService::get($cacheKey)){
+            $this->error = '2301';
+            return false;
+        }
 
 
+        $clearDay = strtotime(date('Y-m-d')) - $day * 86400;
+        $count = $this->model->where('create_time','<', $clearDay)->where(['mark'=>1])->count();
+        if($count<=0){
+            $this->error = '';
+            RedisService::set($cacheKey,['error'=>'没有记录可以清除','day'=> $day,'clearDay'=> date('Y-m-d', $clearDay)], 6 * 3600);
+            return false;
+        }
+
+
+    }
 }
 }