wupengfei 2 anos atrás
pai
commit
0e77e8c733
1 arquivos alterados com 27 adições e 8 exclusões
  1. 27 8
      application/api/controller/Index.php

+ 27 - 8
application/api/controller/Index.php

@@ -97,17 +97,36 @@ class Index extends Base
         if(!in_array($type,[0,1,3])) $this->error('参数错误');
         $in_type = $type == 0 ? '1,3' : $type;
         $issue_mode = input('issue_mode',0);
-        $list = Db::name('store_collection')
-            ->where('is_deleted',0)
-            ->where('status',1)
-            ->whereIn('type',$in_type)
-            ->where('sell_time','< time',date("Y-m-d 23:59:59"))
-            ->when($issue_mode,function ($query)use($issue_mode){ if($issue_mode) $query->where('issue_mode',$issue_mode);})
-            ->field('id,cover,name,type,label,price,inventory,now_inventory,state,sell_time,advance_info,auth_name,auth_img,issue_mode,apply_st,before_time')
+        /*  $list = Db::name('store_collection')
+              ->where('is_deleted',0)
+              ->where('status',1)
+              ->whereIn('type',$in_type)
+              ->where('sell_time','< time',date("Y-m-d 23:59:59"))
+              ->when($issue_mode,function ($query)use($issue_mode){ if($issue_mode) $query->where('issue_mode',$issue_mode);})
+              ->field('id,cover,name,type,label,price,inventory,now_inventory,state,sell_time,advance_info,auth_name,auth_img,issue_mode,apply_st,before_time')
+              ->order('state asc,sell_time asc')
+              ->limit($this->off_set,$this->page_num)
+              ->select();*/
+
+        $list =  Db::name('store_collection')->where(function ($query)use($in_type,$issue_mode){
+            if($issue_mode){
+                return $query->where('status',1)->where('is_deleted',0)->whereIn('type',$in_type)->where('sell_time','< time',date("Y-m-d 23:59:59"))->where('issue_mode',$issue_mode);
+            }else{
+                return $query->where('status',1)->where('is_deleted',0)->whereIn('type',$in_type)->where('sell_time','< time',date("Y-m-d 23:59:59"));
+            }
+        })->whereOr(function ($query)use($in_type,$issue_mode){
+            if($issue_mode){
+                return $query->where('status',1)->where('is_deleted',0)->whereIn('type',$in_type)->where('id',2)->where('issue_mode',$issue_mode);
+            }else{
+                return $query->where('status',1)->where('is_deleted',0)->whereIn('type',$in_type)->where('id',2);
+            }
+        })->field('id,cover,name,type,label,price,inventory,now_inventory,state,sell_time,advance_info,auth_name,auth_img,issue_mode,apply_st,before_time')
             ->order('state asc,sell_time asc')
             ->limit($this->off_set,$this->page_num)
             ->select();
 
+
+
         foreach ($list as &$v){
             $advance_minutes = $v['before_time'];
             // 验证产品赋能优先购
@@ -123,7 +142,7 @@ class Index extends Base
             $v['now_inventory'] = $now_inventory<=0 ? 0 : $now_inventory;
             $v['is_remind'] = getRemind($this->uid,$v['id']) ? true : false;
         }
-       $this->success('成功',$list);
+        $this->success('成功',$list);
     }
 
     /**