From c35e212e426d6a5867968b701d3e0bcbc3b9d98b Mon Sep 17 00:00:00 2001 From: lqmac Date: Sat, 3 Feb 2024 16:51:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Goods.php | 4 +++- app/admin/controller/Store.php | 7 +------ config/app.php | 6 ++++++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/admin/controller/Goods.php b/app/admin/controller/Goods.php index a4652339..088ca85a 100644 --- a/app/admin/controller/Goods.php +++ b/app/admin/controller/Goods.php @@ -65,7 +65,9 @@ class Goods extends Controller ->where($where) ->order($sort." ".$order) ->paginate($this->request->param('per_page', 15))->each(function ($item, $key){ - + $item['create_time'] = date("Y-m-d H:i:s", $item['create_time']); + $item['update_time'] = date("Y-m-d H:i:s", $item['update_time']); + $item['channel'] = config('app.platformList')[$item['channel']] ?? ""; return $item; }); return $this->renderSuccess(compact('list')); diff --git a/app/admin/controller/Store.php b/app/admin/controller/Store.php index 965d95bb..8d681534 100644 --- a/app/admin/controller/Store.php +++ b/app/admin/controller/Store.php @@ -162,12 +162,7 @@ class Store extends Controller */ public function platformList(): Json { - $platformList = [ - 'sn' => "苏宁", - 'jd' => "京东", - 'tb' => "淘宝", - 'pdd' => "拼多多", - ]; + $platformList = config('app.platformList'); return $this->renderSuccess($platformList); } /** diff --git a/config/app.php b/config/app.php index 53f49625..48dc42e5 100644 --- a/config/app.php +++ b/config/app.php @@ -39,4 +39,10 @@ return [ 'error_message' => '页面错误!请稍后再试~', // 显示错误信息 'show_error_msg' => true, + 'platformList' => [ + 'sn' => "苏宁", + 'jd' => "京东", + 'tb' => "淘宝", + 'pdd' => "拼多多", + ], ]; From 1cd1f0b3e02ff714224c616b13a3de82e75355c2 Mon Sep 17 00:00:00 2001 From: "wangmingchuan321@qq.com" Date: Sat, 3 Feb 2024 16:58:47 +0800 Subject: [PATCH 2/2] 123123 --- app/api/model/Goods.php | 34 +++++++++++++++++++--------------- app/common/model/Category.php | 2 +- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php index 3b882253..97571209 100644 --- a/app/api/model/Goods.php +++ b/app/api/model/Goods.php @@ -197,28 +197,32 @@ class Goods extends GoodsModel 'store_id' => request()->header()['storeid'], 'is_delete' => 0 ])->column('goods_id'); - foreach ($spe as $v) { - $sku1 = $this->getSpecData($v)['skuList']->toArray()[0]; - -// foreach ($sku1['spec_value_ids'] as $k3 => &$v3) { -// $v3 = (int)$v3; -// } + foreach ($spe as $k => $v) { + //$sku1 = $this->getSpecData($v)['skuList']->toArray()[0]; + // $skuList[] = $sku1; + $spe1 = $this->getSpecData($v)['specList'][0]; + $spe1['valueList'][0]['goods_id'] = $v; + $aa = 0; + foreach ($specList as &$v2) { + if ($v2['spec_name'] == $spe1['spec_name']) { + $aa = 1; + $v2['valueList'][] = $spe1['valueList']; + break; + } + } - $skuList[] = $sku1; - $specList[] = $this->getSpecData($v)['specList'][0]; + if ($aa == 0) { + $specList[] = $spe1; + } } - $newList = [ - 'skuList' => $skuList, - 'specList' => $specList - ]; - $goodsInfo->specifications = $newList; } $goodsInfo = $goodsInfo->toArray(); //替换原规格数组 - $goodsInfo['skuList2'] = $skuList; - $goodsInfo['specList2'] = $specList; +// $goodsInfo['skuList2'] = $skuList; + $goodsInfo['specList2'] = $specList ?? []; + //加入足迹 $userId = UserService::getCurrentLoginUserId(false) ?? ''; if ($userId) { diff --git a/app/common/model/Category.php b/app/common/model/Category.php index 150bd2e8..b297bb28 100644 --- a/app/common/model/Category.php +++ b/app/common/model/Category.php @@ -86,7 +86,7 @@ class Category extends BaseModel // 设置检索条件 $filter = []; $params['status'] > -1 && $filter[] = ['status', '=', $params['status']]; - if ($_GET['is_hot'] == 1) { + if (!empty($_GET['is_hot']) && $_GET['is_hot'] == 1) { $filter[] = ['is_hot','=',1]; }