商品列表

This commit is contained in:
彭桃 2023-02-25 13:43:22 +08:00
parent 003d76c504
commit 99238e62b0
2 changed files with 12 additions and 2 deletions

View File

@ -48,7 +48,7 @@ class SpuDao extends BaseDao
if(isset($where['order']) && $where['order'] === 'none'){ if(isset($where['order']) && $where['order'] === 'none'){
$order = ''; $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->when(isset($where['is_del']) && $where['is_del'] !== '',function($query)use($where){
$query->where('P.is_del',$where['is_del']); $query->where('P.is_del',$where['is_del']);
}) })
@ -80,6 +80,15 @@ class SpuDao extends BaseDao
$query->whereIn('P.mer_id',$merId); $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) { ->when(isset($where['cate_pid']) && $where['cate_pid'], function ($query) use ($where) {
$storeCategoryRepository = app()->make(StoreCategoryRepository::class); $storeCategoryRepository = app()->make(StoreCategoryRepository::class);
if (is_array($where['cate_pid'])) { if (is_array($where['cate_pid'])) {

View File

@ -56,7 +56,8 @@ class StoreSpu extends BaseController
'common', 'common',
'is_trader', 'is_trader',
'product_ids', 'product_ids',
'mer_id' 'mer_id',
'merchant_category_id'
]); ]);
$where['is_gift_bag'] = 0; $where['is_gift_bag'] = 0;
$where['product_type'] = 0; $where['product_type'] = 0;