feat: good
This commit is contained in:
@@ -35,6 +35,8 @@ class GoodRequest extends FormRequest
|
|||||||
'image_ids' => 'required|string',
|
'image_ids' => 'required|string',
|
||||||
'stock' => 'required|integer',
|
'stock' => 'required|integer',
|
||||||
'price' => 'required|string',
|
'price' => 'required|string',
|
||||||
|
'search_kitchen_id' => 'required|integer|exists:kitchen,id',
|
||||||
|
'search_city_id' => 'required|integer|exists:city,id',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +53,11 @@ class GoodRequest extends FormRequest
|
|||||||
'edit_spu' => ['id','kitchen_id', 'chef_id', 'title', 'sub_title', 'category_id', 'saleable'],
|
'edit_spu' => ['id','kitchen_id', 'chef_id', 'title', 'sub_title', 'category_id', 'saleable'],
|
||||||
'del_spu' => ['id'],
|
'del_spu' => ['id'],
|
||||||
'spu' => ['id'],
|
'spu' => ['id'],
|
||||||
'list_spu' => ['cycle_id'],
|
'list_spu' => ['cycle_id','search_kitchen_id','search_city_id'],
|
||||||
|
'add_sku' => ['spu_id','title', 'stock', 'price', 'saleable', 'image_ids'],
|
||||||
|
'edit_sku' => ['id','title', 'stock', 'price', 'saleable', 'image_ids'],
|
||||||
|
'del_sku' => ['id'],
|
||||||
|
'sku' => ['id'],
|
||||||
|
'list_sku' => ['spu_id'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,8 +60,55 @@ class SpuService extends BaseService
|
|||||||
{
|
{
|
||||||
$limit = (int)$this->request->input('limit', 10);
|
$limit = (int)$this->request->input('limit', 10);
|
||||||
$cycleId = (int)$this->request->input('cycle_id');
|
$cycleId = (int)$this->request->input('cycle_id');
|
||||||
|
$kitchenId = (int)$this->request->input('search_kitchen_id');
|
||||||
|
$cityId = (int)$this->request->input('search_city_id');
|
||||||
|
|
||||||
$list = $this->spuModel->where('cycle_id',$cycleId)->where('city_id',$this->cityId)->paginate($limit)->toArray();
|
$list = $this->spuModel
|
||||||
|
->where('cycle_id',$cycleId)
|
||||||
|
->where('city_id',$cityId)
|
||||||
|
->where('kitchen_id',$kitchenId)
|
||||||
|
->where('is_del',GoodCode::SPU_IS_NO_DEL)
|
||||||
|
->paginate($limit)
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
if (empty($list['data'])) return $this->return->success('success', ['list' => $list]);
|
||||||
|
|
||||||
|
$spuIds = array_column($list['data'], 'id');
|
||||||
|
|
||||||
|
$skuList = $this->skuModel
|
||||||
|
->whereIn('spu_id',$spuIds)
|
||||||
|
->where('is_del',GoodCode::SKU_IS_NO_DEL)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (empty($skuList)) return $this->return->success('success', ['list' => $list]);
|
||||||
|
$skuList = $skuList->toArray();
|
||||||
|
|
||||||
|
$imageIdArr = array_column($skuList,'image_ids');
|
||||||
|
$imageIds = array_unique(explode(',',implode(',',$imageIdArr)));
|
||||||
|
$imageList = $this->getOssObjects($imageIds);
|
||||||
|
|
||||||
|
$skuListArr = [];
|
||||||
|
foreach ($skuList as $sku) {
|
||||||
|
$imageOneArr = [];
|
||||||
|
foreach (explode(',',$sku['image_ids']) as $imageId) {
|
||||||
|
$imageOneArr[] = [
|
||||||
|
'id' => $imageId,
|
||||||
|
'url' => $imageList[$imageId]['url']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sku['image_list'] = $imageOneArr;
|
||||||
|
|
||||||
|
if (empty($skuListArr[$sku['spu_id']])) {
|
||||||
|
$skuListArr[$sku['spu_id']] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$skuListArr[$sku['spu_id']][] = $sku;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($list['data'] as &$item) {
|
||||||
|
$item['sku_list'] = $skuListArr[$item['id']];
|
||||||
|
}
|
||||||
|
|
||||||
return $this->return->success('success', ['list' => $list]);
|
return $this->return->success('success', ['list' => $list]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user