commit
4b5dcec08b
@ -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());
|
||||
|
||||
}
|
||||
}
|
@ -808,45 +808,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
||||
}
|
||||
List<OrderItem> items = orderItemService.getByOrderSn(order.getSn());
|
||||
List<StoreFlow> 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);
|
||||
|
@ -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<StoreFlowMapper, StoreFlow
|
||||
|
||||
/**
|
||||
* 店铺订单支付流水
|
||||
*
|
||||
* @param orderSn 订单编号
|
||||
*/
|
||||
@Override
|
||||
@ -76,67 +72,10 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
|
||||
List<OrderItem> 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<StoreFlowMapper, StoreFlow
|
||||
|
||||
/**
|
||||
* 店铺订单退款流水
|
||||
*
|
||||
* @param afterSale 售后单
|
||||
*/
|
||||
@Override
|
||||
@ -183,7 +123,7 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
|
||||
//最终结算金额 =店铺流水金额+店铺单品返现支出金额+平台收取佣金金额
|
||||
storeFlow.setBillPrice(CurrencyUtil.add(storeFlow.getFinalPrice(), storeFlow.getDistributionRebate(), storeFlow.getCommissionPrice()));
|
||||
//站点优惠券补贴返还金额=(站点优惠券补贴金额/购买商品数量)*退款商品数量
|
||||
storeFlow.setSiteCouponCommission(CurrencyUtil.mul(CurrencyUtil.div(payStoreFlow.getSiteCouponCommission(),payStoreFlow.getNum()),afterSale.getNum()));
|
||||
storeFlow.setSiteCouponCommission(CurrencyUtil.mul(CurrencyUtil.div(payStoreFlow.getSiteCouponCommission(), payStoreFlow.getNum()), afterSale.getNum()));
|
||||
//平台优惠券 使用金额
|
||||
storeFlow.setSiteCouponPrice(payStoreFlow.getSiteCouponPrice());
|
||||
//站点优惠券佣金比例
|
||||
|
Loading…
x
Reference in New Issue
Block a user