From fb50a7accdc4f72d2bd3a1bdba44056e052f4d05 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Wed, 24 May 2023 16:40:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=91=E4=BB=93=E5=95=86=E5=93=81=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=85=B3=E9=94=AE=E5=AD=97=E6=A3=80=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repositories/store/product/SpuRepository.php | 16 +++++++++++++++- .../api/store/product/CloudWarehouse.php | 4 +++- config/app.php | 2 ++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/common/repositories/store/product/SpuRepository.php b/app/common/repositories/store/product/SpuRepository.php index 12556241..dd4ca0be 100644 --- a/app/common/repositories/store/product/SpuRepository.php +++ b/app/common/repositories/store/product/SpuRepository.php @@ -34,6 +34,9 @@ class SpuRepository extends BaseRepository public $dao; public $merchantFiled = 'mer_id,mer_name,mer_avatar,is_trader,mer_info,mer_keyword,type_id'; public $productFiled = 'P.bar_code,S.product_id,S.store_name,S.image,activity_id,S.keyword,S.price,S.mer_id,spu_id,S.status,store_info,brand_id,cate_id,unit_name,S.star,S.rank,S.sort,sales,S.product_type,rate,reply_count,extension_type,S.sys_labels,S.mer_labels,P.delivery_way,P.delivery_free,P.ot_price,svip_price_type,stock,mer_svip_status'; + + public $userInfo; + public function __construct(SpuDao $dao) { $this->dao = $dao; @@ -163,6 +166,17 @@ class SpuRepository extends BaseRepository { $where['spu_status'] = 1; $where['mer_status'] = 1; + if (!empty($where['keyword'])) { + if (preg_match('/^(\/@[1-9]{1}).*\*\//', $where['keyword'])) { + $command = app()->make(CopyCommand::class)->getMassage($where['keyword']); + if (!$command || in_array($command['type'], [30, 40])) return ['count' => 0, 'list' => []]; + if ($this->userInfo && $command['uid']) app()->make(UserRepository::class)->bindSpread($this->userInfo, $command['uid']); + $where['spu_id'] = $command['id']; + unset($where['keyword']); + } else { + app()->make(UserVisitRepository::class)->searchProduct($this->userInfo ? $this->userInfo['uid'] : 0, $where['keyword'], (int)($where['mer_id'] ?? 0)); + } + } if ($rand) { $RedisCacheService = app()->make(RedisCacheService::class); $exists=$RedisCacheService->exists('CloudMerchantSpu'.$where['mer_id']); @@ -175,7 +189,7 @@ class SpuRepository extends BaseRepository } unset($where['mer_id']); } - $entryMerId = $where['entry_mer_id']; + $entryMerId = $where['entry_mer_id'] ?? ''; unset($where['entry_mer_id']); $query = $this->dao->search($where); diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index 605ecd6b..5a262d7f 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -36,6 +36,7 @@ class CloudWarehouse extends BaseController $this->repository = $repository; $this->merchantDao = $merchantDao; $this->spuRepository = $spuRepository; + $this->spuRepository->userInfo = $this->request->isLogin() ? $this->request->userInfo() : null; } /** @@ -44,7 +45,7 @@ class CloudWarehouse extends BaseController */ public function index() { - $params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0]]); + $params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword']); $search = [ 'street_id' => $params['street_code'], 'type_id' => Merchant::TypeStore, @@ -55,6 +56,7 @@ class CloudWarehouse extends BaseController if (empty($merchantIds)) { return app('json')->success(['count' => 0, 'list' => []]); } + $where['keyword'] = $params['keyword']; $where['mer_ids'] = $merchantIds; $where['product_type'] = $params['product_type']; $where['is_gift_bag'] = 0; diff --git a/config/app.php b/config/app.php index 5270a42e..0cc46466 100644 --- a/config/app.php +++ b/config/app.php @@ -44,4 +44,6 @@ return [ 'error_message' => '页面错误!请稍后再试~', // 显示错误信息 'show_error_msg' => false, + //应用加解密秘钥 + 'app_secret' => '789XH80PTSb8pHjH', ];