增加检测促销商品库存
This commit is contained in:
parent
1688a7ba15
commit
0d5f871da7
@ -190,40 +190,43 @@ public class SkuPromotionRender implements CartRenderStep {
|
|||||||
List<PromotionSkuVO> joinPromotion = cartSkuVO.getPriceDetailDTO().getJoinPromotion();
|
List<PromotionSkuVO> joinPromotion = cartSkuVO.getPriceDetailDTO().getJoinPromotion();
|
||||||
if (!joinPromotion.isEmpty()) {
|
if (!joinPromotion.isEmpty()) {
|
||||||
for (PromotionSkuVO promotionSkuVO : joinPromotion) {
|
for (PromotionSkuVO promotionSkuVO : joinPromotion) {
|
||||||
|
this.checkPromotionGoodsQuantity(cartSkuVO, promotionSkuVO);
|
||||||
String promotionGoodsStockCacheKey = PromotionGoodsService.getPromotionGoodsStockCacheKey(PromotionTypeEnum.valueOf(promotionSkuVO.getPromotionType()), promotionSkuVO.getActivityId(), cartSkuVO.getGoodsSku().getId());
|
|
||||||
Object quantity = cache.get(promotionGoodsStockCacheKey);
|
|
||||||
|
|
||||||
if (quantity == null) {
|
|
||||||
//如果促销有库存信息
|
|
||||||
PromotionTypeEnum promotionTypeEnum = PromotionTypeEnum.valueOf(promotionSkuVO.getPromotionType());
|
|
||||||
switch (promotionTypeEnum) {
|
|
||||||
case KANJIA:
|
|
||||||
quantity = kanjiaActivityGoodsService.getKanjiaGoodsBySkuId(cartSkuVO.getGoodsSku().getId()).getStock();
|
|
||||||
break;
|
|
||||||
case POINTS_GOODS:
|
|
||||||
quantity = pointsGoodsService.getPointsGoodsDetailBySkuId(cartSkuVO.getGoodsSku().getId()).getActiveStock();
|
|
||||||
break;
|
|
||||||
case SECKILL:
|
|
||||||
case PINTUAN:
|
|
||||||
quantity = promotionGoodsService.getPromotionGoodsStock(PromotionTypeEnum.valueOf(promotionSkuVO.getPromotionType()), promotionSkuVO.getActivityId(), cartSkuVO.getGoodsSku().getId());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (quantity != null && cartSkuVO.getNum() > (Integer) quantity) {//设置购物车未选中
|
|
||||||
cartSkuVO.setChecked(false);
|
|
||||||
//设置失效消息
|
|
||||||
cartSkuVO.setErrorMessage("促销商品库存不足,现有库存数量[" + quantity + "]");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkPromotionGoodsQuantity(CartSkuVO cartSkuVO, PromotionSkuVO promotionSkuVO) {
|
||||||
|
String promotionGoodsStockCacheKey = PromotionGoodsService.getPromotionGoodsStockCacheKey(PromotionTypeEnum.valueOf(promotionSkuVO.getPromotionType()), promotionSkuVO.getActivityId(), cartSkuVO.getGoodsSku().getId());
|
||||||
|
Object quantity = cache.get(promotionGoodsStockCacheKey);
|
||||||
|
|
||||||
|
if (quantity == null) {
|
||||||
|
//如果促销有库存信息
|
||||||
|
PromotionTypeEnum promotionTypeEnum = PromotionTypeEnum.valueOf(promotionSkuVO.getPromotionType());
|
||||||
|
switch (promotionTypeEnum) {
|
||||||
|
case KANJIA:
|
||||||
|
quantity = kanjiaActivityGoodsService.getKanjiaGoodsBySkuId(cartSkuVO.getGoodsSku().getId()).getStock();
|
||||||
|
break;
|
||||||
|
case POINTS_GOODS:
|
||||||
|
quantity = pointsGoodsService.getPointsGoodsDetailBySkuId(cartSkuVO.getGoodsSku().getId()).getActiveStock();
|
||||||
|
break;
|
||||||
|
case SECKILL:
|
||||||
|
case PINTUAN:
|
||||||
|
quantity = promotionGoodsService.getPromotionGoodsStock(PromotionTypeEnum.valueOf(promotionSkuVO.getPromotionType()), promotionSkuVO.getActivityId(), cartSkuVO.getGoodsSku().getId());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (quantity != null && cartSkuVO.getNum() > (Integer) quantity) {//设置购物车未选中
|
||||||
|
cartSkuVO.setChecked(false);
|
||||||
|
//设置失效消息
|
||||||
|
cartSkuVO.setErrorMessage("促销商品库存不足,现有库存数量[" + quantity + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 购物车促销类型
|
* 购物车促销类型
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user