feat: sku
This commit is contained in:
@@ -103,7 +103,7 @@ class GoodCache
|
||||
if (!empty($this->stockArr)) {
|
||||
$stockKey = ApiRedisKey::goodStockKey($this->cycleId,$this->kitchenId);
|
||||
foreach ($this->stockArr as $one) {
|
||||
$this->redis->zAdd($stockKey,$one['id'],$one['stock']);
|
||||
$this->redis->zAdd($stockKey,$one['stock'],$one['id']);
|
||||
$this->redis->expire($stockKey,$this->expireTime);
|
||||
}
|
||||
}
|
||||
@@ -136,10 +136,10 @@ class GoodCache
|
||||
{
|
||||
$spuIds = array_column($list, 'id');
|
||||
|
||||
$skuList = $this->skuModel
|
||||
->whereIn('spu_id',$spuIds)
|
||||
->where('is_del',GoodCode::SKU_IS_NO_DEL)
|
||||
->get();
|
||||
$skuList = $this->skuModel->getListBySpuIds($spuIds);
|
||||
// ->whereIn('spu_id',$spuIds)
|
||||
// ->where('is_del',GoodCode::SKU_IS_NO_DEL)
|
||||
// ->get();
|
||||
if (empty($skuList)) return $list;
|
||||
|
||||
$skuList = $skuList->toArray();
|
||||
@@ -160,7 +160,7 @@ class GoodCache
|
||||
];
|
||||
}
|
||||
|
||||
$sku['image_list'] = $imageOneArr;
|
||||
// $sku['image_list'] = $imageOneArr;
|
||||
|
||||
if (empty($skuListArr[$sku['spu_id']])) {
|
||||
$skuListArr[$sku['spu_id']] = [];
|
||||
@@ -175,7 +175,9 @@ class GoodCache
|
||||
];
|
||||
}
|
||||
|
||||
$this->stockArr = $stockArr;
|
||||
if (!empty($stockArr)) {
|
||||
$this->stockArr = $stockArr;
|
||||
}
|
||||
|
||||
foreach ($list as &$item) {
|
||||
$item['sku_list'] = $skuListArr[$item['id']] ?? [];
|
||||
@@ -247,7 +249,7 @@ class GoodCache
|
||||
|
||||
$data = json_decode($data,true);
|
||||
|
||||
$this->buildData($data);
|
||||
$this->buildStockData($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -261,8 +263,8 @@ class GoodCache
|
||||
private function buildStockData(&$data): mixed
|
||||
{
|
||||
foreach ($data as &$spu) {
|
||||
foreach ($spu as &$sku) {
|
||||
$sku['stock'] = $this->getStock((int)$sku['id']);
|
||||
foreach ($spu['sku_list'] as &$sku) {
|
||||
$sku['stock'] = $this->getStock($sku['id']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,7 +286,7 @@ class GoodCache
|
||||
|
||||
$data = json_decode($data,true);
|
||||
|
||||
$this->buildData($data);
|
||||
$this->buildStockData($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user