From 07fae7a5316303b3803d6798d839974e2ca4e67c Mon Sep 17 00:00:00 2001 From: Chopper Date: Sat, 28 Aug 2021 03:42:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E4=BB=B7=E6=A0=BCDTO?= =?UTF-8?q?=E5=8F=82=E4=B8=8E=E6=B4=BB=E5=8A=A8=E9=97=AE=E9=A2=98=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/cart/entity/vo/CartSkuVO.java | 6 ++-- .../cart/render/impl/SkuPromotionRender.java | 19 ++++++++++-- .../order/cart/service/CartServiceImpl.java | 2 ++ .../order/order/entity/dos/OrderItem.java | 14 ++++----- .../order/entity/dto/PriceDetailDTO.java | 4 +-- .../promotion/entity/vos/PromotionSkuVO.java | 31 +++++++++++++++++++ 6 files changed, 61 insertions(+), 15 deletions(-) create mode 100644 framework/src/main/java/cn/lili/modules/promotion/entity/vos/PromotionSkuVO.java diff --git a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java index 9900612a..f7fcd45c 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java @@ -57,9 +57,6 @@ public class CartSkuVO extends CartBase implements Serializable { @ApiModelProperty(value = "是否免运费") private Boolean isFreeFreight; - @ApiModelProperty(value = "积分购买 积分数量") - private Long point; - @ApiModelProperty(value = "是否失效 ") private Boolean invalid; @@ -79,6 +76,9 @@ public class CartSkuVO extends CartBase implements Serializable { @ApiModelProperty(value = "积分兑换ID") private String pointsId; + @ApiModelProperty(value = "积分购买 积分数量") + private Long point; + @ApiModelProperty(value = "可参与的单品活动") private List promotions; 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 96e243e0..0122712a 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 @@ -1,5 +1,6 @@ package cn.lili.modules.order.cart.render.impl; +import cn.lili.common.enums.PromotionTypeEnum; import cn.lili.common.security.context.UserContext; import cn.lili.common.utils.CurrencyUtil; import cn.lili.modules.order.cart.entity.dto.TradeDTO; @@ -9,6 +10,7 @@ import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.cart.render.CartRenderStep; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.promotion.entity.enums.KanJiaStatusEnum; +import cn.lili.modules.promotion.entity.vos.PromotionSkuVO; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivitySearchParams; import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityVO; import cn.lili.modules.promotion.service.KanjiaActivityService; @@ -76,16 +78,18 @@ public class SkuPromotionRender implements CartRenderStep { switch (tradeDTO.getCartTypeEnum()) { + + //这里是双重循环,但是实际积分购买或者是砍价购买时,购物车只有一个商品,所以没有循环操作数据库或者其他的问题 case POINTS: //处理积分商品购买 for (CartVO cartVO : tradeDTO.getCartList()) { for (CartSkuVO cartSkuVO : cartVO.getSkuList()) { cartSkuVO.getPriceDetailDTO().setPayPoint(cartSkuVO.getPoint()); + PromotionSkuVO promotionSkuVO = new PromotionSkuVO(PromotionTypeEnum.PINTUAN.name(), cartSkuVO.getPointsId()); + cartSkuVO.getPriceDetailDTO().getJoinPromotion().add(promotionSkuVO); } } return; - - case KANJIA: for (CartVO cartVO : tradeDTO.getCartList()) { for (CartSkuVO cartSkuVO : cartVO.getSkuList()) { @@ -101,11 +105,20 @@ public class SkuPromotionRender implements CartRenderStep { cartSkuVO.setSubTotal(kanjiaActivityVO.getPurchasePrice()); cartSkuVO.getPriceDetailDTO().setGoodsPrice(kanjiaActivityVO.getPurchasePrice()); } + + PromotionSkuVO promotionSkuVO = new PromotionSkuVO(PromotionTypeEnum.KANJIA.name(), cartSkuVO.getKanjiaId()); + cartSkuVO.getPriceDetailDTO().getJoinPromotion().add(promotionSkuVO); } } return; - case PINTUAN: + for (CartVO cartVO : tradeDTO.getCartList()) { + for (CartSkuVO cartSkuVO : cartVO.getSkuList()) { + PromotionSkuVO promotionSkuVO = new PromotionSkuVO(PromotionTypeEnum.PINTUAN.name(), cartSkuVO.getPintuanId()); + cartSkuVO.getPriceDetailDTO().getJoinPromotion().add(promotionSkuVO); + } + } + return; case CART: case BUY_NOW: case VIRTUAL: diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 023bcfa4..ae42c72c 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -730,6 +730,7 @@ public class CartServiceImpl implements CartService { throw new ServiceException(ResultCode.KANJIA_ACTIVITY_NOT_PASS_ERROR); } //砍价商品默认一件货物 + cartSkuVO.setKanjiaId(kanjiaActivity.getId()); cartSkuVO.setNum(1); } @@ -745,6 +746,7 @@ public class CartServiceImpl implements CartService { if (pointsGoodsVO != null) { cartSkuVO.setPoint(pointsGoodsVO.getPoints()); cartSkuVO.setPurchasePrice(0D); + cartSkuVO.setPointsId(pointsGoodsVO.getId()); } } } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/OrderItem.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/OrderItem.java index b2ab11dd..06d95d24 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/OrderItem.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/OrderItem.java @@ -2,17 +2,17 @@ package cn.lili.modules.order.order.entity.dos; import cn.hutool.core.collection.CollUtil; import cn.hutool.json.JSONUtil; -import cn.lili.mybatis.BaseEntity; import cn.lili.common.utils.BeanUtil; import cn.lili.common.utils.SnowFlake; +import cn.lili.modules.order.cart.entity.dto.TradeDTO; +import cn.lili.modules.order.cart.entity.vo.CartSkuVO; +import cn.lili.modules.order.cart.entity.vo.CartVO; import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.order.order.entity.enums.CommentStatusEnum; import cn.lili.modules.order.order.entity.enums.OrderComplaintStatusEnum; import cn.lili.modules.order.order.entity.enums.OrderItemAfterSaleStatusEnum; -import cn.lili.modules.promotion.entity.dto.BasePromotion; -import cn.lili.modules.order.cart.entity.dto.TradeDTO; -import cn.lili.modules.order.cart.entity.vo.CartSkuVO; -import cn.lili.modules.order.cart.entity.vo.CartVO; +import cn.lili.modules.promotion.entity.vos.PromotionSkuVO; +import cn.lili.mybatis.BaseEntity; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -126,8 +126,8 @@ public class OrderItem extends BaseEntity { BeanUtil.copyProperties(cartSkuVO, this); this.setId(oldId); if (cartSkuVO.getPriceDetailDTO().getJoinPromotion() != null && !cartSkuVO.getPriceDetailDTO().getJoinPromotion().isEmpty()) { - this.setPromotionType(CollUtil.join(cartSkuVO.getPriceDetailDTO().getJoinPromotion().stream().map(BasePromotion::getPromotionName).collect(Collectors.toList()), ",")); - this.setPromotionId(CollUtil.join(cartSkuVO.getPriceDetailDTO().getJoinPromotion().stream().map(BasePromotion::getId).collect(Collectors.toList()), ",")); + this.setPromotionType(CollUtil.join(cartSkuVO.getPriceDetailDTO().getJoinPromotion().stream().map(PromotionSkuVO::getPromotionType).collect(Collectors.toList()), ",")); + this.setPromotionId(CollUtil.join(cartSkuVO.getPriceDetailDTO().getJoinPromotion().stream().map(PromotionSkuVO::getActivityId).collect(Collectors.toList()), ",")); } this.setAfterSaleStatus(OrderItemAfterSaleStatusEnum.NEW.name()); this.setCommentStatus(CommentStatusEnum.NEW.name()); 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 5e44ff10..b03e1a51 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 @@ -2,7 +2,7 @@ package cn.lili.modules.order.order.entity.dto; import cn.lili.common.utils.CurrencyUtil; -import cn.lili.modules.promotion.entity.dto.BasePromotion; +import cn.lili.modules.promotion.entity.vos.PromotionSkuVO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -95,7 +95,7 @@ public class PriceDetailDTO implements Serializable { * 参与的促销活动 */ @ApiModelProperty(value = "参与的促销活动") - private List joinPromotion; + private List joinPromotion; public Double getOriginalPrice() { diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/vos/PromotionSkuVO.java b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/PromotionSkuVO.java new file mode 100644 index 00000000..57c54dad --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/vos/PromotionSkuVO.java @@ -0,0 +1,31 @@ +package cn.lili.modules.promotion.entity.vos; + +import cn.lili.common.enums.PromotionTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 促销skuVO + * + * @author Chopper + * @version v1.0 + * 2021-08-28 03:24 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PromotionSkuVO { + + /** + * 促销类型 + * @see PromotionTypeEnum + */ + private String promotionType; + + /** + * 促销活动 + */ + private String activityId; + +}