lqmac 10 months ago
parent d2ca65339c
commit 93cf873fee
  1. 12
      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('很抱歉,商品信息不存在');

Loading…
Cancel
Save