更新查询

This commit is contained in:
yaooo 2023-09-28 12:58:56 +08:00
parent 7b83e6119d
commit 24200a926d
3 changed files with 14 additions and 15 deletions

View File

@ -52,13 +52,13 @@ class SpuDao extends BaseDao
$query->where('P.is_del',$where['is_del']);
})
->when(isset($where['product_id']) && $where['product_id'] !== '',function($query)use($where){
// $query->where('P.product_id','in',$where['product_id']);
$query->where('P.product_id','in',$where['product_id']);
})
->when(isset($where['mer_id']) && $where['mer_id'] !== '',function($query)use($where){
// $query->where('P.mer_id',$where['mer_id']);
$query->where('P.mer_id',$where['mer_id']);
})
->when(isset($where['mer_array_id']),function($query)use($where){
// $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){
$query->whereIn('P.mer_id',$where['mer_ids']);

View File

@ -46,11 +46,11 @@ class CloudWarehouse extends BaseController
*/
public function index()
{
$typeTownSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeTownSupplyChain'])->value('mer_type_id');
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
$params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword']);
$search = [
'street_id' => $params['street_code'],
'type_id' => $typeTownSupplyChainId,
'type_id' => $typeIdArray ?? [],
'status' => 1,
'is_del' => 0,
'mer_state' => 1,

View File

@ -43,7 +43,7 @@ class StoreSpu extends BaseController
{
[$page, $limit] = $this->getPage();
// 除了市级供应链都可以查询
$typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id');
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
$where = $this->request->params([
'keyword',
'cate_id',
@ -64,8 +64,7 @@ class StoreSpu extends BaseController
$where['is_gift_bag'] = 0;
$where['product_type'] = 0;
$where['order'] = $where['order'] ?: 'star';
$where['mer_ids'] = Merchant::getInstance()->whereNotIn('type_id', (string)$typeSupplyChainId)
->where(['status' => 1, 'mer_state' => 1, 'is_del' => 0])->column('mer_id');
$where['mer_ids'] = Merchant::getInstance()->whereNotIn('type_id', $implode(',', $typeIdArray ?? []))->where(['status' => 1, 'mer_state' => 1, 'is_del' => 0])->column('mer_id');
if ($where['is_trader'] != 1) unset($where['is_trader']);
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
return app('json')->success($data);
@ -80,7 +79,7 @@ class StoreSpu extends BaseController
public function streetLst($id)
{
[$page, $limit] = $this->getPage();
$typeStoreId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeStore'])->value('mer_type_id');
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
$where = $this->request->params([
'keyword',
'cate_id',
@ -101,7 +100,7 @@ class StoreSpu extends BaseController
$where['is_gift_bag'] = 0;
$where['product_type'] = 0;
$where['order'] = $where['order'] ?: 'star';
$where['mer_ids'] = Merchant::getInstance()->where('type_id', $typeStoreId)->where('street_id', $id)
$where['mer_ids'] = Merchant::getInstance()->whereNotIn('type_id', $implode(',', $typeIdArray ?? []))->where('street_id', $id)
->where(['status' => 1, 'mer_state' => 1, 'is_del' => 0])->column('mer_id');
if ($where['is_trader'] != 1) unset($where['is_trader']);
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
@ -109,7 +108,7 @@ class StoreSpu extends BaseController
}
/**
* TODO 商户的商品搜索列表
* TODO 商户的商品搜索列表 new
* @param $id
* @return mixed
* @author Qinii
@ -144,13 +143,13 @@ class StoreSpu extends BaseController
]);
if ($where['action']) unset($where['product_type']);
$currentMerchant = Db::name('merchant')->where('mer_id',$id)->field('category_id,street_id')->find();
$typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id');
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
$merIdArray = Db::name('merchant')
->where('street_id',$currentMerchant['street_id'])
->where('mer_state',1)
->where('status',1)
->where('category_id',$currentMerchant['category_id'])
->whereNotIn('type_id', (string)$typeSupplyChainId)
->whereNotIn('type_id', $implode(',', $typeIdArray ?? []))
->column('mer_id');
$where['mer_array_id'] = $merIdArray;
@ -171,7 +170,7 @@ class StoreSpu extends BaseController
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['common','mer_id']);
$typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id');
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
$where['is_gift_bag'] = 0;
//1:星级
//2:用户收藏
@ -197,7 +196,7 @@ class StoreSpu extends BaseController
}
$where['product_type'] = 0;
$where['is_stock'] = 1;
$where['mer_ids'] = Merchant::getInstance()->whereNotIn('type_id', (string)$typeSupplyChainId)
$where['mer_ids'] = Merchant::getInstance()->whereNotIn('type_id', $implode(',', $typeIdArray ??[]))
->where(['status' => 1, 'mer_state' => 1, 'is_del' => 0])->column('mer_id');
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
return app('json')->success($data);