From c00a035370037ff953f8869e3b95c1c97c62de77 Mon Sep 17 00:00:00 2001 From: shengchanzhe <179998674@qq.com> Date: Mon, 25 Dec 2023 14:07:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/store/product/CloudWarehouse.php | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) 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']) {