From 1424eaa90fab0aea7af000c17359b0cd8d0ecd37 Mon Sep 17 00:00:00 2001 From: Chopper Date: Fri, 20 Aug 2021 16:12:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=AF=E5=88=86=E5=85=91=E6=8D=A2=EF=BC=8C?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E9=A1=B5=E9=9D=A2=E7=A7=AF=E5=88=86=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=B1=95=E7=A4=BA=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= =?UTF-8?q?=E3=80=82=20=E5=BA=97=E9=93=BA=E5=95=86=E5=93=81=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E5=BA=97=E9=93=BA=E5=95=86=E5=93=81=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E5=90=8C=E6=AD=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/listener/GoodsMessageListener.java | 16 ++++++++++-- .../order/cart/entity/vo/PriceDetailVO.java | 2 +- .../cart/render/impl/SkuPromotionRender.java | 26 +++++++++++++++---- .../order/entity/dto/PriceDetailDTO.java | 10 +++---- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java index 5a9c67ad..e003cbbc 100644 --- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java +++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java @@ -107,10 +107,12 @@ public class GoodsMessageListener implements RocketMQListener { break; //审核商品 case GOODS_AUDIT: + updateGoodsNum(messageExt); break; //删除商品 case GOODS_DELETE: deleteGoods(messageExt); + updateGoodsNum(messageExt); break; //规格删除 case SKU_DELETE: @@ -156,8 +158,6 @@ public class GoodsMessageListener implements RocketMQListener { */ private void deleteGoods(MessageExt messageExt) { Goods goods = JSONUtil.toBean(new String(messageExt.getBody()), Goods.class); - //更新店铺商品数量 - storeService.updateStoreGoodsNum(goods.getStoreId()); //删除获取分销商品 DistributionGoods distributionGoods = distributionGoodsService.getOne(new LambdaQueryWrapper() @@ -171,6 +171,18 @@ public class GoodsMessageListener implements RocketMQListener { distributionGoodsService.removeById(distributionGoods.getId()); } + /** + * 修改商品数量 + * + * @param messageExt + */ + private void updateGoodsNum(MessageExt messageExt) { + + Goods goods = JSONUtil.toBean(new String(messageExt.getBody()), Goods.class); + //更新店铺商品数量 + storeService.updateStoreGoodsNum(goods.getStoreId()); + } + /** * 商品购买完成 * 1.更新商品购买数量 diff --git a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/PriceDetailVO.java b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/PriceDetailVO.java index 0ca210d4..47d5ebf9 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/PriceDetailVO.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/PriceDetailVO.java @@ -27,7 +27,7 @@ public class PriceDetailVO implements Serializable { private Double discountPrice; @ApiModelProperty(value = "支付积分") - private Integer payPoint; + private Long payPoint; @ApiModelProperty(value = "最终成交金额") private Double finalePrice; 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 f6162890..69c25d01 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 @@ -67,16 +67,32 @@ public class SkuPromotionRender implements CartRenderStep { */ private void renderSkuPromotion(TradeDTO tradeDTO) { + + switch (tradeDTO.getCartTypeEnum()) { + case POINTS: + for (CartVO cartVO : tradeDTO.getCartList()) { + for (CartSkuVO cartSkuVO : cartVO.getSkuList()) { + cartSkuVO.getPriceDetailDTO().setPayPoint(cartSkuVO.getPoint()); + } + } + case CART: + case BUY_NOW: + case VIRTUAL: + for (CartVO cartVO : tradeDTO.getCartList()) { + for (CartSkuVO cartSkuVO : cartVO.getSkuList()) { + promotionGoodsService.updatePromotion(cartSkuVO); + } + } + return; + default: + } + //非积分商品、拼团、砍价商品可渲染满优惠活动 //这里普通购物车也只渲染满优惠,其他优惠都是商品级别的,都写在商品属性里 if (!tradeDTO.getCartTypeEnum().equals(CartTypeEnum.POINTS) && !tradeDTO.getCartTypeEnum().equals(CartTypeEnum.PINTUAN) && !tradeDTO.getCartTypeEnum().equals(CartTypeEnum.KANJIA)) { - for (CartVO cartVO : tradeDTO.getCartList()) { - for (CartSkuVO cartSkuVO : cartVO.getSkuList()) { - promotionGoodsService.updatePromotion(cartSkuVO); - } - } + } } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java index f94f418d..5e44ff10 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/PriceDetailDTO.java @@ -37,7 +37,7 @@ public class PriceDetailDTO implements Serializable { //============discount price============ @ApiModelProperty(value = "支付积分") - private Integer payPoint; + private Long payPoint; @ApiModelProperty(value = "优惠金额") private Double discountPrice; @@ -113,7 +113,7 @@ public class PriceDetailDTO implements Serializable { goodsPrice = 0d; freightPrice = 0d; - payPoint = 0; + payPoint = 0L; discountPrice = 0d; couponPrice = 0d; @@ -230,9 +230,9 @@ public class PriceDetailDTO implements Serializable { return freightPrice; } - public Integer getPayPoint() { + public Long getPayPoint() { if (payPoint == null || payPoint <= 0) { - return 0; + return 0L; } return payPoint; } @@ -343,7 +343,7 @@ public class PriceDetailDTO implements Serializable { this.recount(); } - public void setPayPoint(Integer payPoint) { + public void setPayPoint(Long payPoint) { this.payPoint = payPoint; }