feat : spu
This commit is contained in:
@@ -10,8 +10,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Api\Good;
|
||||
|
||||
use App\Cache\Redis\Api\ApiRedisKey;
|
||||
use App\Cache\Redis\Api\GoodCache;
|
||||
use App\Cache\Redis\Api\SiteCache;
|
||||
use App\Cache\Redis\RedisCache;
|
||||
use App\Service\Api\BaseService;
|
||||
use App\Service\ServiceTrait\Common\CycleTrait;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
@@ -34,6 +36,12 @@ class OptionalListService extends BaseService
|
||||
#[Inject]
|
||||
protected SiteCache $siteCache;
|
||||
|
||||
/**
|
||||
* @var RedisCache
|
||||
*/
|
||||
#[Inject]
|
||||
protected RedisCache $redisCache;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
@@ -53,6 +61,15 @@ class OptionalListService extends BaseService
|
||||
$this->goodCache->kitchenId = (int)$siteInfo['kitchen_id'];
|
||||
$data = $this->goodCache->getOptionalGoodList();
|
||||
|
||||
if (empty($data)) return $this->return->success('success', ['list' => []]);
|
||||
|
||||
$stockKey = ApiRedisKey::goodStockKey($cycleId,(int)$siteInfo['kitchen_id']);
|
||||
foreach ($data as &$item) {
|
||||
foreach ($item['sku_list'] as &$v) {
|
||||
$v['surplus_stock'] = $this->redisCache->zScore($stockKey,$v['id']) ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->return->success('success', ['list' => $data]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user