|
|
@ -612,6 +612,18 @@ class Goods extends BaseModel |
|
|
|
} |
|
|
|
} |
|
|
|
return $arr; |
|
|
|
return $arr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 使用总后台的商品信息 |
|
|
|
|
|
|
|
* [storeUsePlatformGoodsImage description] |
|
|
|
|
|
|
|
* @param array $origin_goods_ids [description] |
|
|
|
|
|
|
|
* @return [type] [description] |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function storeUsePlatformGoods(array $origin_goods_ids){ |
|
|
|
|
|
|
|
$goods = self::withoutGlobalScope()->whereIn('goods_id', $origin_goods_ids)->field('goods_id,goods_name,goods_no,content')->select()->toArray(); |
|
|
|
|
|
|
|
$goods = array_column($goods, null, "goods_id"); |
|
|
|
|
|
|
|
return $goods; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 设置商品展示的数据 |
|
|
|
* 设置商品展示的数据 |
|
|
|
* @param Collection|Paginator $list 商品列表 |
|
|
|
* @param Collection|Paginator $list 商品列表 |
|
|
@ -625,12 +637,17 @@ class Goods extends BaseModel |
|
|
|
} |
|
|
|
} |
|
|
|
//使用总后台的商品的图片作为商城商品的图片 |
|
|
|
//使用总后台的商品的图片作为商城商品的图片 |
|
|
|
$goodsList = $list->toArray()['data'] ?? $list->toArray(); |
|
|
|
$goodsList = $list->toArray()['data'] ?? $list->toArray(); |
|
|
|
$goods_images = $this->storeUsePlatformGoodsImage(array_column($goodsList, 'origin_goods_id')); |
|
|
|
$origin_goods_ids = array_column($goodsList, 'origin_goods_id'); |
|
|
|
|
|
|
|
$goods_images = $this->storeUsePlatformGoodsImage($origin_goods_ids); |
|
|
|
|
|
|
|
$goodsList = $this->storeUsePlatformGoods($origin_goods_ids); |
|
|
|
|
|
|
|
|
|
|
|
// 遍历商品列表整理数据 |
|
|
|
// 遍历商品列表整理数据 |
|
|
|
foreach ($list as &$goods) { |
|
|
|
foreach ($list as &$goods) { |
|
|
|
if ($goods->origin_goods_id && $goods->store_id > 0) { |
|
|
|
if ($goods->origin_goods_id && $goods->store_id > 0) { |
|
|
|
$goods->images = $goods_images[$goods->origin_goods_id] ?? []; |
|
|
|
$goods->images = $goods_images[$goods->origin_goods_id] ?? []; |
|
|
|
|
|
|
|
$goods->content = $goodsList[$goods->origin_goods_id]['content'] ?? ""; |
|
|
|
|
|
|
|
$goods->goods_no = $goodsList[$goods->origin_goods_id]['goods_no'] ?? ""; |
|
|
|
|
|
|
|
$goods->goods_name = $goodsList[$goods->origin_goods_id]['goods_name'] ?? ""; |
|
|
|
} |
|
|
|
} |
|
|
|
$goods = $this->setGoodsData($goods, $callback); |
|
|
|
$goods = $this->setGoodsData($goods, $callback); |
|
|
|
} |
|
|
|
} |
|
|
|