From 1be278da4dd942685493280218d7c9e35e4018b1 Mon Sep 17 00:00:00 2001 From: lqmac Date: Wed, 22 May 2024 12:37:11 +0800 Subject: [PATCH 1/2] 1 --- app/admin/controller/goods/Import.php | 2 +- app/api/controller/Goods.php | 2 +- app/common/model/Goods.php | 2 +- app/store/model/Store.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/admin/controller/goods/Import.php b/app/admin/controller/goods/Import.php index 9437a517..ba31bc5a 100644 --- a/app/admin/controller/goods/Import.php +++ b/app/admin/controller/goods/Import.php @@ -35,7 +35,7 @@ class Import extends Controller $params['store_id'] = 0; $model = new ImportModel; $platform = $this->getUserPlatform(); - $params['channels'] = $platform ? array_column($platform->toArray(), "code") : []; + $params['channels'] = $this->admin['user']['role'] == 0 ? [] : ($platform ? array_column($platform->toArray(), "code") : []); $list = $model->getList($params); return $this->renderSuccess(compact('list')); } diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index d94d3570..dee1faf1 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -411,7 +411,7 @@ class Goods extends Controller $wxConfig = WxappSettingModel::getConfigBasic($store_id); // 请求api获取短连接 $link_obj = new ShortLink($wxConfig['app_id'], $wxConfig['app_secret']); - $url = $link_obj->shortUrl($page_url, $page_title); + $url = $link_obj->shortUrl($page_url, ""); return $this->renderSuccess(['url' => $url]); } diff --git a/app/common/model/Goods.php b/app/common/model/Goods.php index 880bbc3b..286a6a82 100644 --- a/app/common/model/Goods.php +++ b/app/common/model/Goods.php @@ -584,7 +584,7 @@ class Goods extends BaseModel protected function setGoodsData($goodsInfo, callable $callback = null) { $channel = Channel::withoutGlobalScope()->where('code', $goodsInfo['channel'])->find(); - $goodsInfo['channel_name'] = $channel['name'] ?? ""; + $goodsInfo['channel_name'] = $channel['alias'] ?? ""; $goodsInfo['goods_images'] = helper::getArrayColumn($goodsInfo['images'], 'file'); // 商品主图 diff --git a/app/store/model/Store.php b/app/store/model/Store.php index 0bbf86e5..32fcc630 100644 --- a/app/store/model/Store.php +++ b/app/store/model/Store.php @@ -30,7 +30,7 @@ class Store extends StoreModel { // 是否删除图片 !isset($data['logo_image_id']) && $data['logo_image_id'] = 0; - $data['fliter_condition'] = json_encode($data['fliter_condition'], JSON_UNESCAPED_UNICODE); + $data['fliter_condition'] = isset($data['fliter_condition']) ? json_encode($data['fliter_condition'], JSON_UNESCAPED_UNICODE) : ""; return $this->save($data) !== false; } } From 3cf25d8c3f7bb5d496de363fe7a8670911e93b93 Mon Sep 17 00:00:00 2001 From: lqmac Date: Thu, 23 May 2024 01:09:26 +0800 Subject: [PATCH 2/2] 1 --- app/api/controller/Controller.php | 4 +++- app/api/controller/Goods.php | 6 +++--- app/store/model/Goods.php | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/api/controller/Controller.php b/app/api/controller/Controller.php index 828292ed..7a11aec1 100644 --- a/app/api/controller/Controller.php +++ b/app/api/controller/Controller.php @@ -34,6 +34,8 @@ class Controller extends BaseController protected $storeInfo; + protected $user; + /** * API基类初始化 * @throws BaseException @@ -49,7 +51,7 @@ class Controller extends BaseController $this->checkStore(); // 验证当前客户端状态 $this->checkClient(); - //$user = $this->getLoginUser(); + $this->user = $this->getLoginUser(false); // if ($user) { // if ($user->user_type == 0 || $user->status == 0) { // throwError('很抱歉,您没有权限进入系统'); diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index dee1faf1..c1fe2ced 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -294,11 +294,11 @@ class Goods extends Controller public function recommended(): Json { $service = new GoodsService; - $cache_key = "goods_recommended".$this->storeId; - if(Cache::has($cache_key)) { + $cache_key = "goods_recommended".$this->storeId.($this->user ? $this->user->user_type : 0); + if(Cache::has($cache_key)) { $goodsList = Cache::get($cache_key); return $this->renderSuccess(compact('goodsList')); - } + } $goodsList = $service->recommended(); Cache::set($cache_key, $goodsList, 60*60); return $this->renderSuccess(compact('goodsList')); diff --git a/app/store/model/Goods.php b/app/store/model/Goods.php index bd8d31c5..09a2e1b2 100644 --- a/app/store/model/Goods.php +++ b/app/store/model/Goods.php @@ -183,7 +183,7 @@ class Goods extends GoodsModel public function setIsPool(array $goodsIds, int $is_pool): bool { // 批量更新记录 - return static::updateBase(['is_pool' => $is_pool,'update_time' => time()], [['goods_id', 'in', $goodsIds]]); + return static::updateBase(['is_pool' => $is_pool,'update_time' => time(),'sale_time' => time()], [['goods_id', 'in', $goodsIds]]); } /** * 修改商品状态 @@ -194,7 +194,7 @@ class Goods extends GoodsModel public function setIsSale(array $goodsIds, int $is_sale): bool { // 批量更新记录 - return static::updateBase(['is_sale' => $is_sale,'update_time' => time()], [['goods_id', 'in', $goodsIds]]); + return static::updateBase(['is_sale' => $is_sale,'update_time' => time(),'sale_time' => time()], [['goods_id', 'in', $goodsIds]]); } /** * 修改商品状态