From a96d3bb9d99a6e7c26c044ff108d5819547c9438 Mon Sep 17 00:00:00 2001 From: liuqing Date: Wed, 13 Mar 2024 11:41:33 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Goods.php | 8 ++++++- app/api/service/Goods.php | 42 ++++++++++++++++++++++++++++++------ app/common/model/Store.php | 24 +++++++++++++++++++++ 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index ff6778f2..7ef550ba 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -12,7 +12,7 @@ declare (strict_types=1); namespace app\api\controller; -use app\api\model\{Goods as GoodsModel}; +use app\api\model\{Goods as GoodsModel, Store as StoreModel}; use app\api\service\{Goods as GoodsService, User as UserService}; use app\common\service\qrcode\Goods as GoodsPoster; use cores\exception\BaseException; @@ -222,6 +222,12 @@ class Goods extends Controller public function getCommonConfig(): Json { $service = new GoodsService; + $storeid = request()->header()['storeid']; + $storeInfo = StoreModel::where("store_id",$storeid)->find(); + if(empty($storeInfo)){ + return $this->renderError("商铺信息不存在"); + } + $goodsList = $service->getCommonConfig($storeInfo); $goodsList = $service->getCommonConfig(); return $this->renderSuccess($goodsList); } diff --git a/app/api/service/Goods.php b/app/api/service/Goods.php index 923456d2..000fefd3 100644 --- a/app/api/service/Goods.php +++ b/app/api/service/Goods.php @@ -54,12 +54,14 @@ class Goods extends GoodsService return $detail; } - public function getCommonConfig() + public function getCommonConfig($storeInfo) { - //todo wmc1新品首发背景图 2限时秒杀背景图 3排行榜背景图 4大牌正品是轮播 5预售规则 - switch (request()->get('type')) { + //todo wmc1新品首发背景图 2限时秒杀背景图 3排行榜背景图 4大牌正品是轮播 5预售规则 6 新人首单 + $type = request()->get('type'); + switch ($type) { case 1: - $data['imgurl'] = 'https://www.saas.njrenzhou.com/uploads/10001/20240131/bdc5f17f3ff8c53ce0853177bc4f1917.png'; + $data['imgurl'] = $this->getStoreImgUrl($storeInfo['new_product_img_id']); + //$data['imgurl'] = 'https://www.saas.njrenzhou.com/uploads/10001/20240131/bdc5f17f3ff8c53ce0853177bc4f1917.png'; return $data; break; case 2: @@ -71,9 +73,10 @@ class Goods extends GoodsService return $data; break; case 4: - $data['imgurl'] = [ - 'https://www.saas.njrenzhou.com/uploads/10001/20240131/5c4ec6ffeb23223936295e290dc3d1f9.png', - ]; + $data['imgurl'] = $this->getStoreImgUrl($storeInfo['big_brand_img_id']); +// $data['imgurl'] = [ +// 'https://www.saas.njrenzhou.com/uploads/10001/20240131/5c4ec6ffeb23223936295e290dc3d1f9.png', +// ]; return $data; break; case 5: @@ -82,10 +85,35 @@ class Goods extends GoodsService ]; return $data; break; + case 6: + $data['imgurl'] = $this->getStoreImgUrl($storeInfo['new_people_order_img_id']); +// $data['imgurl'] = [ +// 'http://qiniu.shop.royaum.com.cn/10001/20240201/13f2e675794e25176352fc039dfb6dcb.jpg', +// ]; + return $data; + break; + } return []; } + /** + * 获取(新品首发,大牌正品,新人首单)商铺的url + */ + public function getStoreImgUrl($img_id){ + $data = []; + if(!empty($img_id)){ + $img_ids = explode(",",$img_id); + $infos = \app\common\model\UploadFile::where('file_id','in' ,$img_ids)->field('file_path,domain')->select(); + if(!empty($infos)){ + foreach($infos as $info){ + $data[] = getUrl($info['file_path'], $info['domain']); + } + } + } + return $data; + } + /** * 推荐的商品列表 * @return array diff --git a/app/common/model/Store.php b/app/common/model/Store.php index 4531faf0..47703a1d 100644 --- a/app/common/model/Store.php +++ b/app/common/model/Store.php @@ -49,6 +49,30 @@ class Store extends BaseModel ->with(['logoImage']) ->where('store_id', '=', $storeId) ->find(); + if($list){ + if($list['new_product_img_id']){ + $new_product_img_id = explode(",",$list['new_product_img_id']); + $file1 = UploadFile::where('file_id','in' ,$new_product_img_id)->select(); + $list['newProductImg'] = $file1 ?: null; + }else{ + $list['newProductImg'] = null; + } + if($list['big_brand_img_id']){ + $big_brand_img_id = explode(",",$list['big_brand_img_id']); + $file2 = UploadFile::where('file_id','in' ,$big_brand_img_id)->select(); + $list['bigBrandImg'] = $file2 ?: null; + }else{ + $list['bigBrandImg'] = null; + } + if($list['new_people_order_img_id']){ + $new_people_order_img_id = explode(",",$list['new_people_order_img_id']); + $file3 = UploadFile::where('file_id','in' ,$new_people_order_img_id)->select(); + $list['newPeopleOrderImg'] = $file3 ?: null; + }else{ + $list['newPeopleOrderImg'] = null; + } + } + return $list ?? null; } catch (\Exception $e) { return null; } From fc4ddd643eab2d54363345a4143bf3b17d91c420 Mon Sep 17 00:00:00 2001 From: liuqing Date: Wed, 13 Mar 2024 11:49:12 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/Store.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/model/Store.php b/app/common/model/Store.php index 47703a1d..fecdb945 100644 --- a/app/common/model/Store.php +++ b/app/common/model/Store.php @@ -45,7 +45,7 @@ class Store extends BaseModel public static function detail(int $storeId) { try { - return self::withoutGlobalScope() + $list = self::withoutGlobalScope() ->with(['logoImage']) ->where('store_id', '=', $storeId) ->find(); From e3abd038d8f4f44bdfc2d3a291d716948b69cb13 Mon Sep 17 00:00:00 2001 From: liuqing Date: Wed, 13 Mar 2024 11:52:38 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Goods.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 7ef550ba..fb72994d 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -228,7 +228,6 @@ class Goods extends Controller return $this->renderError("商铺信息不存在"); } $goodsList = $service->getCommonConfig($storeInfo); - $goodsList = $service->getCommonConfig(); return $this->renderSuccess($goodsList); } From fa1383b98ca983a558b661341360e906932a6068 Mon Sep 17 00:00:00 2001 From: liuqing Date: Wed, 13 Mar 2024 11:59:31 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Goods.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index fb72994d..4873f3f9 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -222,6 +222,7 @@ class Goods extends Controller public function getCommonConfig(): Json { $service = new GoodsService; + // 获取店铺信息 $storeid = request()->header()['storeid']; $storeInfo = StoreModel::where("store_id",$storeid)->find(); if(empty($storeInfo)){