feat : spu
This commit is contained in:
@@ -88,6 +88,7 @@ class SpuService extends BaseService
|
|||||||
if (empty($list['data'])) return $this->return->success('success', ['list' => $list]);
|
if (empty($list['data'])) return $this->return->success('success', ['list' => $list]);
|
||||||
|
|
||||||
$spuIds = array_column($list['data'], 'id');
|
$spuIds = array_column($list['data'], 'id');
|
||||||
|
$spuImageIds = array_column($list['data'], 'image_id');
|
||||||
|
|
||||||
$skuList = $this->skuModel
|
$skuList = $this->skuModel
|
||||||
->whereIn('spu_id',$spuIds)
|
->whereIn('spu_id',$spuIds)
|
||||||
@@ -99,7 +100,7 @@ class SpuService extends BaseService
|
|||||||
|
|
||||||
$imageIdArr = array_column($skuList,'image_ids');
|
$imageIdArr = array_column($skuList,'image_ids');
|
||||||
$imageIds = array_unique(explode(',',implode(',',$imageIdArr)));
|
$imageIds = array_unique(explode(',',implode(',',$imageIdArr)));
|
||||||
$imageList = $this->getOssObjects($imageIds);
|
$imageList = $this->getOssObjects(array_merge($imageIds,$spuImageIds));
|
||||||
|
|
||||||
$skuListArr = [];
|
$skuListArr = [];
|
||||||
foreach ($skuList as $sku) {
|
foreach ($skuList as $sku) {
|
||||||
@@ -126,6 +127,7 @@ class SpuService extends BaseService
|
|||||||
|
|
||||||
foreach ($list['data'] as &$item) {
|
foreach ($list['data'] as &$item) {
|
||||||
$item['sku_list'] = $skuListArr[$item['id']] ?? [];
|
$item['sku_list'] = $skuListArr[$item['id']] ?? [];
|
||||||
|
$item['image_url'] = $imageList[$item['image_id']] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->return->success('success', ['list' => $list]);
|
return $this->return->success('success', ['list' => $list]);
|
||||||
|
|||||||
Reference in New Issue
Block a user