当价格配置未命中缓存时,不返回空

This commit is contained in:
2025-04-27 04:35:18 +08:00
parent 46a8b254b5
commit bb26fa43bf

View File

@ -25,10 +25,10 @@ public class PriceRepository {
priceConfigEntity = JSON.parseObject(redisTemplate.opsForValue().get(cacheKey), PriceConfigEntity.class);
}
if (priceConfigEntity == null) {
PriceConfigEntity priceConfig = mapper.getPriceByScenicTypeGoods(scenicId, type, goodsId);
if (priceConfig != null) {
redisTemplate.opsForValue().set(cacheKey, JSON.toJSONString(priceConfig));
redisTemplate.opsForValue().set(String.format(PRICE_ID_CACHE, priceConfig.getId()), JSON.toJSONString(priceConfig));
priceConfigEntity = mapper.getPriceByScenicTypeGoods(scenicId, type, goodsId);
if (priceConfigEntity != null) {
redisTemplate.opsForValue().set(cacheKey, JSON.toJSONString(priceConfigEntity));
redisTemplate.opsForValue().set(String.format(PRICE_ID_CACHE, priceConfigEntity.getId()), JSON.toJSONString(priceConfigEntity));
}
}
return priceConfigEntity;