fix : good cache

This commit is contained in:
2025-08-06 15:21:18 +08:00
parent 30bed90d27
commit cf4a2d9436

View File

@@ -114,9 +114,11 @@ class OptionalListService extends BaseService
$favorable = [];
$skuList = [];
foreach ($data as &$item) {
foreach ($item['sku_list'] as &$v) {
$v['surplus_stock'] = $this->redisCache->zScore($stockKey,$v['id']) ?? 0;
$v['category_id'] = $item['category_id'];
if (!empty($item['sku_list'])) {
foreach ($item['sku_list'] as &$v) {
$v['surplus_stock'] = $this->redisCache->zScore($stockKey,$v['id']) ?? 0;
$v['category_id'] = $item['category_id'];
}
}
if ($item['favorable'] == GoodCode::IS_FAVORABLE) {
@@ -136,10 +138,10 @@ class OptionalListService extends BaseService
}
$res[$item['category_id']]['spu_list'][] = $item;
$skuList = array_merge($skuList, $item['sku_list']);
$skuList = array_merge($skuList, $item['sku_list'] ?? []);
}
if (empty($skuList)) throw new ErrException('数据错误');
if (empty($skuList)) return array_values($res);
$skuList = array_column($skuList,null,'id');
if (!empty($purchaseData)) {