From 13a7a875a40de1d94f915578b2639b3bf2389bdb Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 7 Jul 2022 18:10:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=96=E6=B6=88=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=94=9F=E6=88=90=E5=BA=97=E9=93=BA=E6=B5=81=E6=B0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/order/entity/dos/StoreFlow.java | 71 ++++++++++++++++++- .../order/serviceimpl/OrderServiceImpl.java | 39 +--------- .../serviceimpl/StoreFlowServiceImpl.java | 68 ++---------------- 3 files changed, 75 insertions(+), 103 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java index 0f9a9ab7..8404acc9 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dos/StoreFlow.java @@ -1,6 +1,13 @@ package cn.lili.modules.order.order.entity.dos; +import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.json.JSONUtil; +import cn.lili.common.utils.BeanUtil; +import cn.lili.common.utils.CurrencyUtil; +import cn.lili.common.utils.SnowFlake; +import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.order.order.entity.enums.FlowTypeEnum; +import cn.lili.modules.order.order.entity.enums.OrderPromotionTypeEnum; import cn.lili.modules.payment.entity.enums.PaymentMethodEnum; import cn.lili.mybatis.BaseIdEntity; import com.baomidou.mybatisplus.annotation.FieldFill; @@ -10,6 +17,8 @@ import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; import org.springframework.data.annotation.CreatedDate; import org.springframework.format.annotation.DateTimeFormat; @@ -24,6 +33,8 @@ import java.util.Date; @Data @TableName("li_store_flow") @ApiModel(value = "商家订单流水") +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) public class StoreFlow extends BaseIdEntity { private static final long serialVersionUID = -5998757398902747939L; @@ -115,7 +126,7 @@ public class StoreFlow extends BaseIdEntity { private String transactionId; /** - * @see PaymentMethodEnum + * @see PaymentMethodEnum */ @ApiModelProperty(value = "支付方式名称") private String paymentName; @@ -129,4 +140,62 @@ public class StoreFlow extends BaseIdEntity { @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间", hidden = true) private Date createTime; + + + public StoreFlow(Order order, OrderItem item, FlowTypeEnum flowTypeEnum) { + //获取订单促销类型,如果为促销订单则获取促销商品并获取结算价 + String promotionType = order.getOrderPromotionType(); + BeanUtil.copyProperties(item, this); + + //去掉orderitem的时间。 + this.setCreateTime(null); + //入账 + this.setId(SnowFlake.getIdStr()); + this.setFlowType(flowTypeEnum.name()); + this.setSn(SnowFlake.createStr("SF")); + this.setOrderSn(item.getOrderSn()); + this.setOrderItemSn(item.getSn()); + this.setStoreId(order.getStoreId()); + this.setStoreName(order.getStoreName()); + this.setMemberId(order.getMemberId()); + this.setMemberName(order.getMemberName()); + this.setGoodsName(item.getGoodsName()); + this.setOrderPromotionType(item.getPromotionType()); + //格式化订单价格详情 + PriceDetailDTO priceDetailDTO = JSONUtil.toBean(item.getPriceDetail(), PriceDetailDTO.class); + //站点优惠券比例=最大比例(100)-店铺承担比例 + this.setSiteCouponPoint(CurrencyUtil.sub(100, priceDetailDTO.getSiteCouponPoint())); + //平台优惠券 使用金额 + this.setSiteCouponPrice(priceDetailDTO.getSiteCouponPrice()); + //站点优惠券佣金(站点优惠券承担金额=优惠券金额 * (站点承担比例/100)) + this.setSiteCouponCommission(CurrencyUtil.mul(this.getSiteCouponPrice(), CurrencyUtil.div(this.getSiteCouponPoint(), 100))); + + /** + * @TODO 计算平台佣金 + */ + //店铺流水金额=goodsPrice(商品总金额(商品原价))+ freightPrice(配送费) - discountPrice(优惠金额) - couponPrice(优惠券金额) + updatePrice(订单修改金额) + this.setFinalPrice(item.getPriceDetailDTO().getFlowPrice()); + //平台收取交易佣金=(flowPrice(流水金额) * platFormCommissionPoint(平台佣金比例))/100 + this.setCommissionPrice(item.getPriceDetailDTO().getPlatFormCommission()); + //单品分销返现支出 + this.setDistributionRebate(item.getPriceDetailDTO().getDistributionCommission()); + //最终结算金额=flowPrice(流水金额) - platFormCommission(平台收取交易佣金) - distributionCommission(单品分销返现支出) + this.setBillPrice(item.getPriceDetailDTO().getBillPrice()); + //兼容为空,以及普通订单操作 + if (CharSequenceUtil.isNotEmpty(promotionType)) { + //如果为砍价活动,填写砍价结算价 + if (promotionType.equals(OrderPromotionTypeEnum.KANJIA.name())) { + this.setKanjiaSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); + } + //如果为砍价活动,填写砍价结算价 + else if (promotionType.equals(OrderPromotionTypeEnum.POINTS.name())) { + this.setPointSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); + } + } + //添加支付方式 + this.setPaymentName(order.getPaymentMethod()); + //添加第三方支付流水号 + this.setTransactionId(order.getReceivableNo()); + + } } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index 1b59db38..01c61f60 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -808,45 +808,8 @@ public class OrderServiceImpl extends ServiceImpl implements } List items = orderItemService.getByOrderSn(order.getSn()); List storeFlows = new ArrayList<>(); - String orderPromotionType = order.getOrderPromotionType(); for (OrderItem item : items) { - StoreFlow storeFlow = new StoreFlow(); - BeanUtil.copyProperties(item, storeFlow); - - //入账 - storeFlow.setId(SnowFlake.getIdStr()); - storeFlow.setFlowType(FlowTypeEnum.REFUND.name()); - storeFlow.setSn(SnowFlake.createStr("SF")); - storeFlow.setOrderSn(item.getOrderSn()); - storeFlow.setOrderItemSn(item.getSn()); - storeFlow.setStoreId(order.getStoreId()); - storeFlow.setStoreName(order.getStoreName()); - storeFlow.setMemberId(order.getMemberId()); - storeFlow.setMemberName(order.getMemberName()); - storeFlow.setGoodsName(item.getGoodsName()); - - storeFlow.setOrderPromotionType(item.getPromotionType()); - - //计算平台佣金 - storeFlow.setFinalPrice(item.getPriceDetailDTO().getFlowPrice()); - storeFlow.setCommissionPrice(item.getPriceDetailDTO().getPlatFormCommission()); - storeFlow.setDistributionRebate(item.getPriceDetailDTO().getDistributionCommission()); - storeFlow.setBillPrice(item.getPriceDetailDTO().getBillPrice()); - //兼容为空,以及普通订单操作 - if (CharSequenceUtil.isNotEmpty(orderPromotionType)) { - //如果为砍价活动,填写砍价结算价 - if (orderPromotionType.equals(OrderPromotionTypeEnum.KANJIA.name())) { - storeFlow.setKanjiaSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); - } - //如果为砍价活动,填写砍价结算价 - else if (orderPromotionType.equals(OrderPromotionTypeEnum.POINTS.name())) { - storeFlow.setPointSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); - } - } - //添加支付方式 - storeFlow.setPaymentName(order.getPaymentMethod()); - //添加第三方支付流水号 - storeFlow.setTransactionId(order.getReceivableNo()); + StoreFlow storeFlow = new StoreFlow(order, item, FlowTypeEnum.REFUND); storeFlows.add(storeFlow); } storeFlowService.saveBatch(storeFlows); diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java index dfe3e1af..a9ec6265 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/StoreFlowServiceImpl.java @@ -1,8 +1,6 @@ package cn.lili.modules.order.order.serviceimpl; import cn.hutool.core.text.CharSequenceUtil; -import cn.hutool.json.JSONUtil; -import cn.lili.common.utils.BeanUtil; import cn.lili.common.utils.CurrencyUtil; import cn.lili.common.utils.SnowFlake; import cn.lili.common.vo.PageVO; @@ -10,11 +8,8 @@ import cn.lili.modules.order.aftersale.entity.dos.AfterSale; import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.OrderItem; import cn.lili.modules.order.order.entity.dos.StoreFlow; -import cn.lili.modules.order.order.entity.dto.PriceDetailDTO; import cn.lili.modules.order.order.entity.dto.StoreFlowQueryDTO; import cn.lili.modules.order.order.entity.enums.FlowTypeEnum; -import cn.lili.modules.order.order.entity.enums.OrderPromotionTypeEnum; -import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.mapper.StoreFlowMapper; import cn.lili.modules.order.order.service.OrderItemService; import cn.lili.modules.order.order.service.OrderService; @@ -68,6 +63,7 @@ public class StoreFlowServiceImpl extends ServiceImpl orderItems = orderItemService.getByOrderSn(orderSn); //根据订单编号获取订单数据 Order order = orderService.getBySn(orderSn); - //获取订单促销类型,如果为促销订单则获取促销商品并获取结算价 - String orderPromotionType = order.getOrderPromotionType(); //循环子订单记录流水 for (OrderItem item : orderItems) { - StoreFlow storeFlow = new StoreFlow(); - BeanUtil.copyProperties(item, storeFlow); - - //去掉orderitem的时间。 - storeFlow.setCreateTime(null); - //入账 - storeFlow.setId(SnowFlake.getIdStr()); - storeFlow.setFlowType(FlowTypeEnum.PAY.name()); - storeFlow.setSn(SnowFlake.createStr("SF")); - storeFlow.setOrderSn(item.getOrderSn()); - storeFlow.setOrderItemSn(item.getSn()); - storeFlow.setStoreId(order.getStoreId()); - storeFlow.setStoreName(order.getStoreName()); - storeFlow.setMemberId(order.getMemberId()); - storeFlow.setMemberName(order.getMemberName()); - storeFlow.setGoodsName(item.getGoodsName()); - storeFlow.setOrderPromotionType(item.getPromotionType()); - //格式化订单价格详情 - PriceDetailDTO priceDetailDTO = JSONUtil.toBean(item.getPriceDetail(), PriceDetailDTO.class); - //站点优惠券比例=最大比例(100)-店铺承担比例 - storeFlow.setSiteCouponPoint(CurrencyUtil.sub(100,priceDetailDTO.getSiteCouponPoint())); - //平台优惠券 使用金额 - storeFlow.setSiteCouponPrice(priceDetailDTO.getSiteCouponPrice()); - //站点优惠券佣金(站点优惠券承担金额=优惠券金额 * (站点承担比例/100)) - storeFlow.setSiteCouponCommission(CurrencyUtil.mul(storeFlow.getSiteCouponPrice(),CurrencyUtil.div(storeFlow.getSiteCouponPoint(),100))); - - /** - * @TODO 计算平台佣金 - */ - //店铺流水金额=goodsPrice(商品总金额(商品原价))+ freightPrice(配送费) - discountPrice(优惠金额) - couponPrice(优惠券金额) + updatePrice(订单修改金额) - storeFlow.setFinalPrice(item.getPriceDetailDTO().getFlowPrice()); - //平台收取交易佣金=(flowPrice(流水金额) * platFormCommissionPoint(平台佣金比例))/100 - storeFlow.setCommissionPrice(item.getPriceDetailDTO().getPlatFormCommission()); - //单品分销返现支出 - storeFlow.setDistributionRebate(item.getPriceDetailDTO().getDistributionCommission()); - //最终结算金额=flowPrice(流水金额) - platFormCommission(平台收取交易佣金) - distributionCommission(单品分销返现支出) - storeFlow.setBillPrice(item.getPriceDetailDTO().getBillPrice()); - //兼容为空,以及普通订单操作 - if (CharSequenceUtil.isNotEmpty(orderPromotionType)) { - if (orderPromotionType.equals(OrderPromotionTypeEnum.NORMAL.name())) { - //普通订单操作 - } - //如果为砍价活动,填写砍价结算价 - else if (orderPromotionType.equals(OrderPromotionTypeEnum.KANJIA.name())) { - storeFlow.setKanjiaSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); - } - //如果为砍价活动,填写砍价结算价 - else if (orderPromotionType.equals(OrderPromotionTypeEnum.POINTS.name())) { - storeFlow.setPointSettlementPrice(item.getPriceDetailDTO().getSettlementPrice()); - } - } - //添加支付方式 - storeFlow.setPaymentName(order.getPaymentMethod()); - //添加第三方支付流水号 - storeFlow.setTransactionId(order.getReceivableNo()); - + StoreFlow storeFlow = new StoreFlow(order, item, FlowTypeEnum.PAY); //添加付款交易流水 this.save(storeFlow); } @@ -145,6 +84,7 @@ public class StoreFlowServiceImpl extends ServiceImpl