From 59f6928e3f7c6b87e618edcf967dfa876a257a42 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Thu, 28 Sep 2023 13:26:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/repositories/store/product/SpuRepository.php | 6 +++--- app/controller/api/store/product/CloudWarehouse.php | 3 ++- app/controller/api/store/product/StoreSpu.php | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/common/repositories/store/product/SpuRepository.php b/app/common/repositories/store/product/SpuRepository.php index 9f43b880..4ae0c9f2 100644 --- a/app/common/repositories/store/product/SpuRepository.php +++ b/app/common/repositories/store/product/SpuRepository.php @@ -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 = []; diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index df3d8922..fd96cca5 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -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'], diff --git a/app/controller/api/store/product/StoreSpu.php b/app/controller/api/store/product/StoreSpu.php index ac2b4975..e05b2658 100644 --- a/app/controller/api/store/product/StoreSpu.php +++ b/app/controller/api/store/product/StoreSpu.php @@ -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'])