From 93cf873fee65d27db12a7d9e420b7553fe40636f Mon Sep 17 00:00:00 2001 From: lqmac Date: Thu, 28 Mar 2024 21:17:17 +0800 Subject: [PATCH] 1 --- app/api/model/Goods.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php index 44e7c673..f6e96851 100644 --- a/app/api/model/Goods.php +++ b/app/api/model/Goods.php @@ -460,6 +460,18 @@ class Goods extends GoodsModel { // 获取商品记录 $goodsInfo = static::detail($goodsId, $with); + if ($goodsInfo->skuList) { + foreach ($goodsInfo->skuList as &$value) { + $goods_image = GoodsImage::where('goods_id', $value['goods_id'])->order("id asc")->find(); + $file_path = UploadFile::where('file_id',$goods_image['image_id'] ?? 0)->find(); + if ($file_path) { + $value['image_url'] = getUrl($file_path['file_path'], $file_path['domain']); + } + $goods = GoodsModel::where('goods_id',$value['goods_id'])->find(); + $value['stock_num'] = $goods['stock_total'] ?? 0; + + } + } // 判断商品是否存在 if (empty($goodsInfo) || $goodsInfo['is_delete']) { throwError('很抱歉,商品信息不存在');