修复查询异常

This commit is contained in:
yaooo 2023-09-28 11:09:08 +08:00
parent 2ac7718aa1
commit 9b0c2141f3
2 changed files with 4 additions and 3 deletions

View File

@ -62,7 +62,7 @@ class SpuDao extends BaseDao
$query->whereIn('P.mer_id',$where['mer_array_id']); $query->whereIn('P.mer_id',$where['mer_array_id']);
}) })
->when(isset($where['mer_ids']) && $where['mer_ids'] !== '',function($query)use($where){ ->when(isset($where['mer_ids']) && $where['mer_ids'] !== '',function($query)use($where){
// $query->whereIn('P.mer_id',$where['mer_ids']); $query->whereIn('P.mer_id',$where['mer_ids']);
}) })
->when(isset($where['keyword']) && $where['keyword'] !== '',function($query)use($where){ ->when(isset($where['keyword']) && $where['keyword'] !== '',function($query)use($where){
$query->whereLike("S.store_name|S.keyword|S.product_id", "%{$where['keyword']}%"); $query->whereLike("S.store_name|S.keyword|S.product_id", "%{$where['keyword']}%");

View File

@ -42,7 +42,8 @@ class StoreSpu extends BaseController
public function lst() public function lst()
{ {
[$page, $limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$typeTownSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeTownSupplyChain'])->value('mer_type_id'); // 除了市级供应链都可以查询
$typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id');
$where = $this->request->params([ $where = $this->request->params([
'keyword', 'keyword',
'cate_id', 'cate_id',
@ -63,7 +64,7 @@ class StoreSpu extends BaseController
$where['is_gift_bag'] = 0; $where['is_gift_bag'] = 0;
$where['product_type'] = 0; $where['product_type'] = 0;
$where['order'] = $where['order'] ?: 'star'; $where['order'] = $where['order'] ?: 'star';
$where['mer_ids'] = Merchant::getInstance()->where('type_id', $typeTownSupplyChainId) $where['mer_ids'] = Merchant::getInstance()->whereNotIn('type_id', (string)$typeSupplyChainId)
->where(['status' => 1, 'mer_state' => 1, 'is_del' => 0])->column('mer_id'); ->where(['status' => 1, 'mer_state' => 1, 'is_del' => 0])->column('mer_id');
if ($where['is_trader'] != 1) unset($where['is_trader']); if ($where['is_trader'] != 1) unset($where['is_trader']);
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo); $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);