陈伟 10 months ago
commit ecb35a7cd4
  1. 10
      app/api/controller/Goods.php
  2. 42
      app/api/service/Goods.php
  3. 26
      app/common/model/Store.php

@ -12,7 +12,7 @@ declare (strict_types=1);
namespace app\api\controller; 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\api\service\{Goods as GoodsService, User as UserService};
use app\common\service\qrcode\Goods as GoodsPoster; use app\common\service\qrcode\Goods as GoodsPoster;
use cores\exception\BaseException; use cores\exception\BaseException;
@ -222,7 +222,13 @@ class Goods extends Controller
public function getCommonConfig(): Json public function getCommonConfig(): Json
{ {
$service = new GoodsService; $service = new GoodsService;
$goodsList = $service->getCommonConfig(); // 获取店铺信息
$storeid = request()->header()['storeid'];
$storeInfo = StoreModel::where("store_id",$storeid)->find();
if(empty($storeInfo)){
return $this->renderError("商铺信息不存在");
}
$goodsList = $service->getCommonConfig($storeInfo);
return $this->renderSuccess($goodsList); return $this->renderSuccess($goodsList);
} }

@ -54,12 +54,14 @@ class Goods extends GoodsService
return $detail; return $detail;
} }
public function getCommonConfig() public function getCommonConfig($storeInfo)
{ {
//todo wmc1新品首发背景图 2限时秒杀背景图 3排行榜背景图 4大牌正品是轮播 5预售规则 //todo wmc1新品首发背景图 2限时秒杀背景图 3排行榜背景图 4大牌正品是轮播 5预售规则 6 新人首单
switch (request()->get('type')) { $type = request()->get('type');
switch ($type) {
case 1: 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; return $data;
break; break;
case 2: case 2:
@ -71,9 +73,10 @@ class Goods extends GoodsService
return $data; return $data;
break; break;
case 4: case 4:
$data['imgurl'] = [ $data['imgurl'] = $this->getStoreImgUrl($storeInfo['big_brand_img_id']);
'https://www.saas.njrenzhou.com/uploads/10001/20240131/5c4ec6ffeb23223936295e290dc3d1f9.png', // $data['imgurl'] = [
]; // 'https://www.saas.njrenzhou.com/uploads/10001/20240131/5c4ec6ffeb23223936295e290dc3d1f9.png',
// ];
return $data; return $data;
break; break;
case 5: case 5:
@ -82,10 +85,35 @@ class Goods extends GoodsService
]; ];
return $data; return $data;
break; 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 []; 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 * @return array

@ -45,10 +45,34 @@ class Store extends BaseModel
public static function detail(int $storeId) public static function detail(int $storeId)
{ {
try { try {
return self::withoutGlobalScope() $list = self::withoutGlobalScope()
->with(['logoImage']) ->with(['logoImage'])
->where('store_id', '=', $storeId) ->where('store_id', '=', $storeId)
->find(); ->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) { } catch (\Exception $e) {
return null; return null;
} }

Loading…
Cancel
Save