From 99238e62b0c746a3155b777bb3de22630816e7c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E6=A1=83?= <1098598843@qq.com> Date: Sat, 25 Feb 2023 13:43:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/store/product/SpuDao.php | 11 ++++++++++- app/controller/api/store/product/StoreSpu.php | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/common/dao/store/product/SpuDao.php b/app/common/dao/store/product/SpuDao.php index 542dbc5e..69d61e3b 100644 --- a/app/common/dao/store/product/SpuDao.php +++ b/app/common/dao/store/product/SpuDao.php @@ -48,7 +48,7 @@ class SpuDao extends BaseDao if(isset($where['order']) && $where['order'] === 'none'){ $order = ''; } - $query = Spu::getDB()->alias('S')->join('StoreProduct P','S.product_id = P.product_id', 'left'); + $query = Spu::getDB()->alias('S')->join('StoreProduct P','S.product_id = P.product_id', 'left')->where('P.product_type',0); $query->when(isset($where['is_del']) && $where['is_del'] !== '',function($query)use($where){ $query->where('P.is_del',$where['is_del']); }) @@ -80,6 +80,15 @@ class SpuDao extends BaseDao $query->whereIn('P.mer_id',$merId); }) + ->when(isset($where['merchant_category_id']) && $where['merchant_category_id'] !== '',function($query)use($where){ + $merId = app()->make(MerchantRepository::class)->search([ + 'merchant_category_id' => $where['merchant_category_id'], + 'status' => 1, + 'mer_state' => 1, + 'is_del' => 1, + ])->column('mer_id'); + $query->whereIn('P.mer_id',$merId); + }) ->when(isset($where['cate_pid']) && $where['cate_pid'], function ($query) use ($where) { $storeCategoryRepository = app()->make(StoreCategoryRepository::class); if (is_array($where['cate_pid'])) { diff --git a/app/controller/api/store/product/StoreSpu.php b/app/controller/api/store/product/StoreSpu.php index 80c13535..d115d0ae 100644 --- a/app/controller/api/store/product/StoreSpu.php +++ b/app/controller/api/store/product/StoreSpu.php @@ -56,7 +56,8 @@ class StoreSpu extends BaseController 'common', 'is_trader', 'product_ids', - 'mer_id' + 'mer_id', + 'merchant_category_id' ]); $where['is_gift_bag'] = 0; $where['product_type'] = 0;