wang hou sheng 7 months ago
parent f692fa325b
commit d390b5581e
  1. 22
      app/common/model/sharp/Goods.php

@ -12,8 +12,8 @@ declare (strict_types=1);
namespace app\common\model\sharp;
use cores\BaseModel;
use app\common\service\Goods as GoodsService;
use cores\BaseModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;
@ -104,15 +104,17 @@ class Goods extends BaseModel
$data = GoodsService::setGoodsData($data, $isMultiple, ['goods_images']);
if (!$isMultiple) $dataSource = [&$data]; else $dataSource = &$data;
// 整理商品数据
foreach ($dataSource as &$item) {
// 商品名称
$item['goods_name'] = $item['goods']['goods_name'];
// 商品图片
$item['goods_image'] = $item['goods']['goods_image'];
// 秒杀商品原价 (获取主商品价格)
$item['original_price'] = $item['goods']['goods_price_min'];
// 回调函数
is_callable($callback) && call_user_func($callback, $item);
if (!empty($dataSource)) {
foreach ($dataSource as &$item) {
// 商品名称
$item['goods_name'] = !empty($item['goods']['goods_name']) ? $item['goods']['goods_name'] : '';
// 商品图片
$item['goods_image'] = !empty($item['goods']['goods_image']) ? $item['goods']['goods_image'] : '';
// 秒杀商品原价 (获取主商品价格)
$item['original_price'] = !empty($item['goods']['original_price']) ? $item['goods']['original_price'] : 0;
// 回调函数
is_callable($callback) && call_user_func($callback, $item);
}
}
return $data;
}

Loading…
Cancel
Save