diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index c3fe0315..576fd5d4 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -45,19 +45,21 @@ class CloudWarehouse extends BaseController */ public function index($street_code, $page = 1, $category_id = 0, $cate_pid = 0,$cate_id = 0,$location = '') { + + $cloud_where['street_code']=$street_code; + $cloud_where['status']=1; + if($cate_pid!=0){ + $cate_id=Db::name('store_category')->where('pid',$cate_pid)->where('is_show',1)->column('store_category_id'); + } + if($cate_id>0){ + $cloud_where['cate_id']=$cate_id; + } $cloud_product_arr = Db::name('cloud_product') - ->where('street_code', $street_code) - ->where(function($query)use($cate_pid,$cate_id){ - if($cate_pid!=0){ - $cate_id=Db::name('store_category')->where('pid',$cate_pid)->where('is_show',1)->column('store_category_id'); - } - if($cate_id>0){ - $query ->whereIn('cate_id', $cate_id); - } + ->where($cloud_where) + ->where(function($query){ $query->whereOr('mer_labels', '') ->whereOr('mer_labels',',5,'); - }) - ->where('status', 1)->page($page)->field('product_id,mer_labels')->select(); + })->page($page)->field('product_id,mer_labels')->select(); $cloud_product = []; foreach ($cloud_product_arr as $key => $value) { $cloud_product[] = $value['product_id']; @@ -75,18 +77,11 @@ class CloudWarehouse extends BaseController return app('json')->success(['count' => 0, 'list' => []]); } $count = Db::name('cloud_product') - ->where('street_code', $street_code) - ->where(function($query) use($cate_pid,$cate_id){ - if($cate_pid!=0){ - $cate_id=Db::name('store_category')->where('pid',$cate_pid)->where('is_show',1)->column('store_category_id'); - } - if($cate_id>0){ - $query ->whereIn('cate_id', $cate_id); - } + ->where($cloud_where) + ->where(function($query){ $query->whereOr('mer_labels', '') ->whereOr('mer_labels',',5,'); - }) - ->where('status', 1)->count(); + })->count(); $products = $this->spuRepository->getApiSearch($where, $page, 10, false, true); if ($products['list']) {