From 0d5f871da712ef5ff3007732c26c931ec1921d11 Mon Sep 17 00:00:00 2001 From: paulGao Date: Wed, 2 Mar 2022 20:39:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A3=80=E6=B5=8B=E4=BF=83?= =?UTF-8?q?=E9=94=80=E5=95=86=E5=93=81=E5=BA=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cart/render/impl/SkuPromotionRender.java | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java index cdb2acfe..82f3cde9 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuPromotionRender.java @@ -190,40 +190,43 @@ public class SkuPromotionRender implements CartRenderStep { List joinPromotion = cartSkuVO.getPriceDetailDTO().getJoinPromotion(); if (!joinPromotion.isEmpty()) { for (PromotionSkuVO promotionSkuVO : joinPromotion) { - - 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 + "]"); - } + this.checkPromotionGoodsQuantity(cartSkuVO, promotionSkuVO); } } } } + 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 + "]"); + } + } + /** * 购物车促销类型 */