更新查询

This commit is contained in:
yaooo 2023-09-28 13:26:03 +08:00
parent 2209bac2f0
commit 59f6928e3f
3 changed files with 7 additions and 6 deletions

View File

@ -153,7 +153,7 @@ class SpuRepository extends BaseRepository
'product.attrValue',
]);
$productMake = app()->make(ProductRepository::class);
$count = $query->count();
$count = $query->fetchSql(false)->count();
$list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->select();
$append = ['stop_time','svip_price','show_svip_info','is_svip_price'];
if ($productMake->getUserIsPromoter($userInfo))
@ -190,12 +190,12 @@ class SpuRepository extends BaseRepository
// $where['product_id'] = $this->getSpuFromCache($where['mer_rand_id'], $page, $limit);
// 查询
$query = $this->dao->search($where);
$randPidList = $query->setOption('field', [])->field(['P.product_id'])->page(1)->limit(500)->column('P.product_id');
$randPidList = $query->setOption('field', [])->field(['P.product_id'])->fetchSql(false)->page(1)->limit(500)->column('P.product_id');
$randNum = count($randPidList);
// 最多10条随机数据
if ($randNum > 10) {
array_rand($randPidList, 10);
} else if ($randNum == 0) {
} elseif ($randNum > 0) {
array_rand($randPidList, $randNum);
} else {
$randPidList = [];

View File

@ -46,7 +46,8 @@ class CloudWarehouse extends BaseController
*/
public function index()
{
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
// 除了市级供应链都可以查询
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', 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'],

View File

@ -43,7 +43,7 @@ class StoreSpu extends BaseController
{
[$page, $limit] = $this->getPage();
// 除了市级供应链都可以查询
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', (string)Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
$where = $this->request->params([
'keyword',
'cate_id',
@ -143,7 +143,7 @@ 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();
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
$typeIdArray = Db::name('MerchantType')->whereIn('type_code', (string)Merchant::TypeCode['TypeTownSupplyChain'])->column('mer_type_id');
$merIdArray = Db::name('merchant')
->where('street_id',$currentMerchant['street_id'])