店铺结算单金额问题
This commit is contained in:
parent
6ae9692358
commit
df505e0e17
@ -57,7 +57,8 @@ public class PriceDetailDTO implements Serializable {
|
|||||||
@ApiModelProperty(value = "平台收取交易佣金比例")
|
@ApiModelProperty(value = "平台收取交易佣金比例")
|
||||||
private Double platFormCommissionPoint;
|
private Double platFormCommissionPoint;
|
||||||
|
|
||||||
@ApiModelProperty(value = "平台收取交易佣金")
|
|
||||||
|
@ApiModelProperty(value = "平台收取交易佣金=(flowPrice(流水金额) * platFormCommissionPoint(平台佣金比例))/100")
|
||||||
private Double platFormCommission;
|
private Double platFormCommission;
|
||||||
|
|
||||||
//=========end distribution==========
|
//=========end distribution==========
|
||||||
@ -82,13 +83,15 @@ public class PriceDetailDTO implements Serializable {
|
|||||||
|
|
||||||
//=========end update price==========
|
//=========end update price==========
|
||||||
|
|
||||||
@ApiModelProperty(value = "流水金额(入账 出帐金额) = goodsPrice + freight - discountPrice - couponPrice + updatePrice")
|
@ApiModelProperty(value = "流水金额(入账 出帐金额) = " +
|
||||||
|
"goodsPrice(商品总金额(商品原价)) + freightPrice(配送费) - " +
|
||||||
|
"discountPrice(优惠金额) - couponPrice(优惠券金额) + updatePrice(订单修改金额)")
|
||||||
private Double flowPrice;
|
private Double flowPrice;
|
||||||
|
|
||||||
@ApiModelProperty(value = "结算价格 与 商家/供应商 结算价格(例如积分商品/砍价商品)")
|
@ApiModelProperty(value = "结算价格 与 商家/供应商 结算价格(例如积分商品/砍价商品)")
|
||||||
private Double settlementPrice;
|
private Double settlementPrice;
|
||||||
|
|
||||||
@ApiModelProperty(value = "最终结算金额 = flowPrice - platFormCommission - distributionCommission")
|
@ApiModelProperty(value = "最终结算金额 = flowPrice(流水金额) - platFormCommission(平台收取交易佣金) - distributionCommission(单品分销返现支出)")
|
||||||
private Double billPrice;
|
private Double billPrice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,7 +349,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|||||||
order.setCanReturn(!PaymentMethodEnum.BANK_TRANSFER.name().equals(order.getPaymentMethod()));
|
order.setCanReturn(!PaymentMethodEnum.BANK_TRANSFER.name().equals(order.getPaymentMethod()));
|
||||||
this.updateById(order);
|
this.updateById(order);
|
||||||
|
|
||||||
//记录订单流水
|
//记录店铺订单支付流水
|
||||||
storeFlowService.payOrder(orderSn);
|
storeFlowService.payOrder(orderSn);
|
||||||
|
|
||||||
//发送订单已付款消息
|
//发送订单已付款消息
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.lili.modules.order.order.serviceimpl;
|
package cn.lili.modules.order.order.serviceimpl;
|
||||||
|
|
||||||
import cn.hutool.core.text.CharSequenceUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import cn.lili.common.utils.BeanUtil;
|
import cn.lili.common.utils.BeanUtil;
|
||||||
import cn.lili.common.utils.CurrencyUtil;
|
import cn.lili.common.utils.CurrencyUtil;
|
||||||
import cn.lili.common.utils.SnowFlake;
|
import cn.lili.common.utils.SnowFlake;
|
||||||
@ -9,6 +10,7 @@ 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.Order;
|
||||||
import cn.lili.modules.order.order.entity.dos.OrderItem;
|
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.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.dto.StoreFlowQueryDTO;
|
||||||
import cn.lili.modules.order.order.entity.enums.FlowTypeEnum;
|
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.OrderPromotionTypeEnum;
|
||||||
@ -64,14 +66,16 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
|
|||||||
@Autowired
|
@Autowired
|
||||||
private BillService billService;
|
private BillService billService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺订单支付流水
|
||||||
|
* @param orderSn 订单编号
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void payOrder(String orderSn) {
|
public void payOrder(String orderSn) {
|
||||||
//根据订单编号获取子订单列表
|
//根据订单编号获取子订单列表
|
||||||
List<OrderItem> orderItems = orderItemService.getByOrderSn(orderSn);
|
List<OrderItem> orderItems = orderItemService.getByOrderSn(orderSn);
|
||||||
//根据订单编号获取订单数据
|
//根据订单编号获取订单数据
|
||||||
Order order = orderService.getBySn(orderSn);
|
Order order = orderService.getBySn(orderSn);
|
||||||
|
|
||||||
|
|
||||||
//获取订单促销类型,如果为促销订单则获取促销商品并获取结算价
|
//获取订单促销类型,如果为促销订单则获取促销商品并获取结算价
|
||||||
String orderPromotionType = order.getOrderPromotionType();
|
String orderPromotionType = order.getOrderPromotionType();
|
||||||
//循环子订单记录流水
|
//循环子订单记录流水
|
||||||
@ -92,13 +96,26 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
|
|||||||
storeFlow.setMemberId(order.getMemberId());
|
storeFlow.setMemberId(order.getMemberId());
|
||||||
storeFlow.setMemberName(order.getMemberName());
|
storeFlow.setMemberName(order.getMemberName());
|
||||||
storeFlow.setGoodsName(item.getGoodsName());
|
storeFlow.setGoodsName(item.getGoodsName());
|
||||||
|
|
||||||
storeFlow.setOrderPromotionType(item.getPromotionType());
|
storeFlow.setOrderPromotionType(item.getPromotionType());
|
||||||
|
//格式化订单价格详情
|
||||||
|
PriceDetailDTO priceDetailDTO = JSONUtil.toBean(item.getPriceDetail(), PriceDetailDTO.class);
|
||||||
|
//站点优惠券佣金
|
||||||
|
storeFlow.setSiteCouponCommission(priceDetailDTO.getSiteCouponCommission());
|
||||||
|
//平台优惠券 使用金额
|
||||||
|
storeFlow.setSiteCouponPrice(priceDetailDTO.getSiteCouponPrice());
|
||||||
|
//站点优惠券佣金比例
|
||||||
|
storeFlow.setSiteCouponPoint(priceDetailDTO.getSiteCouponPoint());
|
||||||
|
|
||||||
//计算平台佣金
|
/**
|
||||||
|
* @TODO 计算平台佣金
|
||||||
|
*/
|
||||||
|
//店铺流水金额=goodsPrice(商品总金额(商品原价))+ freightPrice(配送费) - discountPrice(优惠金额) - couponPrice(优惠券金额) + updatePrice(订单修改金额)
|
||||||
storeFlow.setFinalPrice(item.getPriceDetailDTO().getFlowPrice());
|
storeFlow.setFinalPrice(item.getPriceDetailDTO().getFlowPrice());
|
||||||
|
//平台收取交易佣金=(flowPrice(流水金额) * platFormCommissionPoint(平台佣金比例))/100
|
||||||
storeFlow.setCommissionPrice(item.getPriceDetailDTO().getPlatFormCommission());
|
storeFlow.setCommissionPrice(item.getPriceDetailDTO().getPlatFormCommission());
|
||||||
|
//单品分销返现支出
|
||||||
storeFlow.setDistributionRebate(item.getPriceDetailDTO().getDistributionCommission());
|
storeFlow.setDistributionRebate(item.getPriceDetailDTO().getDistributionCommission());
|
||||||
|
//最终结算金额=flowPrice(流水金额) - platFormCommission(平台收取交易佣金) - distributionCommission(单品分销返现支出)
|
||||||
storeFlow.setBillPrice(item.getPriceDetailDTO().getBillPrice());
|
storeFlow.setBillPrice(item.getPriceDetailDTO().getBillPrice());
|
||||||
//兼容为空,以及普通订单操作
|
//兼容为空,以及普通订单操作
|
||||||
if (CharSequenceUtil.isNotEmpty(orderPromotionType)) {
|
if (CharSequenceUtil.isNotEmpty(orderPromotionType)) {
|
||||||
@ -124,6 +141,10 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺订单退款流水
|
||||||
|
* @param afterSale 售后单
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void refundOrder(AfterSale afterSale) {
|
public void refundOrder(AfterSale afterSale) {
|
||||||
StoreFlow storeFlow = new StoreFlow();
|
StoreFlow storeFlow = new StoreFlow();
|
||||||
@ -147,19 +168,23 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
|
|||||||
//获取付款信息
|
//获取付款信息
|
||||||
StoreFlow payStoreFlow = this.getOne(new LambdaUpdateWrapper<StoreFlow>().eq(StoreFlow::getOrderItemSn, afterSale.getOrderItemSn())
|
StoreFlow payStoreFlow = this.getOne(new LambdaUpdateWrapper<StoreFlow>().eq(StoreFlow::getOrderItemSn, afterSale.getOrderItemSn())
|
||||||
.eq(StoreFlow::getFlowType, FlowTypeEnum.PAY));
|
.eq(StoreFlow::getFlowType, FlowTypeEnum.PAY));
|
||||||
|
//申请商品退款数量
|
||||||
storeFlow.setNum(afterSale.getNum());
|
storeFlow.setNum(afterSale.getNum());
|
||||||
|
//分类ID
|
||||||
storeFlow.setCategoryId(payStoreFlow.getCategoryId());
|
storeFlow.setCategoryId(payStoreFlow.getCategoryId());
|
||||||
//佣金
|
//佣金 = (佣金/订单商品数量)* 售后商品数量
|
||||||
storeFlow.setCommissionPrice(CurrencyUtil.mul(CurrencyUtil.div(payStoreFlow.getCommissionPrice(), payStoreFlow.getNum()), afterSale.getNum()));
|
storeFlow.setCommissionPrice(CurrencyUtil.mul(CurrencyUtil.div(payStoreFlow.getCommissionPrice(), payStoreFlow.getNum()), afterSale.getNum()));
|
||||||
//分销佣金
|
//分销佣金 =(分销佣金/订单商品数量)* 售后商品数量
|
||||||
storeFlow.setDistributionRebate(CurrencyUtil.mul(CurrencyUtil.div(payStoreFlow.getDistributionRebate(), payStoreFlow.getNum()), afterSale.getNum()));
|
storeFlow.setDistributionRebate(CurrencyUtil.mul(CurrencyUtil.div(payStoreFlow.getDistributionRebate(), payStoreFlow.getNum()), afterSale.getNum()));
|
||||||
//流水金额
|
//流水金额 = 实际退款金额
|
||||||
storeFlow.setFinalPrice(afterSale.getActualRefundPrice());
|
storeFlow.setFinalPrice(afterSale.getActualRefundPrice());
|
||||||
//最终结算金额
|
//最终结算金额 =店铺流水金额+店铺单品返现支出金额+平台收取佣金金额
|
||||||
storeFlow.setBillPrice(CurrencyUtil.add(storeFlow.getFinalPrice(), storeFlow.getDistributionRebate(), storeFlow.getCommissionPrice()));
|
storeFlow.setBillPrice(CurrencyUtil.add(storeFlow.getFinalPrice(), storeFlow.getDistributionRebate(), storeFlow.getCommissionPrice()));
|
||||||
//获取第三方支付流水号
|
//退款日志
|
||||||
RefundLog refundLog = refundLogService.queryByAfterSaleSn(afterSale.getSn());
|
RefundLog refundLog = refundLogService.queryByAfterSaleSn(afterSale.getSn());
|
||||||
|
//第三方流水单号
|
||||||
storeFlow.setTransactionId(refundLog.getReceivableNo());
|
storeFlow.setTransactionId(refundLog.getReceivableNo());
|
||||||
|
//支付方式
|
||||||
storeFlow.setPaymentName(refundLog.getPaymentName());
|
storeFlow.setPaymentName(refundLog.getPaymentName());
|
||||||
this.save(storeFlow);
|
this.save(storeFlow);
|
||||||
}
|
}
|
||||||
|
@ -76,14 +76,6 @@ public class Bill extends BaseIdEntity {
|
|||||||
@ApiModelProperty(value = "支行联行号")
|
@ApiModelProperty(value = "支行联行号")
|
||||||
private String bankCode;
|
private String bankCode;
|
||||||
|
|
||||||
/**
|
|
||||||
* 开始算钱啦
|
|
||||||
* billPrice=orderPrice-refundPrice
|
|
||||||
* -commissionPrice+refundCommissionPrice
|
|
||||||
* -distributionCommission+distributionRefundCommission
|
|
||||||
* +siteCouponCommission-siteCouponRefundCommission
|
|
||||||
* +kanjiaSettlementPrice+pointSettlementPrice
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "结算周期内订单付款总金额")
|
@ApiModelProperty(value = "结算周期内订单付款总金额")
|
||||||
private Double orderPrice;
|
private Double orderPrice;
|
||||||
|
|
||||||
@ -114,6 +106,16 @@ public class Bill extends BaseIdEntity {
|
|||||||
@ApiModelProperty(value = "砍价商品结算价格")
|
@ApiModelProperty(value = "砍价商品结算价格")
|
||||||
private Double kanjiaSettlementPrice;
|
private Double kanjiaSettlementPrice;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始算钱啦
|
||||||
|
* billPrice(最终结算金额) =
|
||||||
|
* orderPrice(结算周期内订单付款总金额) - refundPrice(退单金额)
|
||||||
|
* - commissionPrice(平台收取佣金) + refundCommissionPrice(退单产生退还佣金金额)
|
||||||
|
* - distributionCommission(分销返现支出) + distributionRefundCommission(分销订单退还,返现佣金返还)
|
||||||
|
* + siteCouponCommission(平台优惠券补贴) - siteCouponRefundCommission(退货平台优惠券补贴返还)
|
||||||
|
* + kanjiaSettlementPrice(砍价商品结算价格) + pointSettlementPrice(pointSettlementPrice)
|
||||||
|
*/
|
||||||
@ApiModelProperty(value = "最终结算金额")
|
@ApiModelProperty(value = "最终结算金额")
|
||||||
private Double billPrice;
|
private Double billPrice;
|
||||||
|
|
||||||
|
@ -68,14 +68,18 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
|
|||||||
StoreDetailVO store = storeDetailService.getStoreDetailVO(storeId);
|
StoreDetailVO store = storeDetailService.getStoreDetailVO(storeId);
|
||||||
Bill bill = new Bill();
|
Bill bill = new Bill();
|
||||||
|
|
||||||
//结算基础信息
|
/**
|
||||||
|
* @TODO 结算单基础信息
|
||||||
|
*/
|
||||||
bill.setStartTime(startTime);
|
bill.setStartTime(startTime);
|
||||||
bill.setEndTime(DateUtil.yesterday());
|
bill.setEndTime(endTime);
|
||||||
bill.setBillStatus(BillStatusEnum.OUT.name());
|
bill.setBillStatus(BillStatusEnum.OUT.name());
|
||||||
bill.setStoreId(storeId);
|
bill.setStoreId(storeId);
|
||||||
bill.setStoreName(store.getStoreName());
|
bill.setStoreName(store.getStoreName());
|
||||||
|
|
||||||
//设置结算信息
|
/**
|
||||||
|
* @TODO 结算单基础信息
|
||||||
|
*/
|
||||||
bill.setBankAccountName(store.getSettlementBankAccountName());
|
bill.setBankAccountName(store.getSettlementBankAccountName());
|
||||||
bill.setBankAccountNumber(store.getSettlementBankAccountNum());
|
bill.setBankAccountNumber(store.getSettlementBankAccountNum());
|
||||||
bill.setBankCode(store.getSettlementBankJointName());
|
bill.setBankCode(store.getSettlementBankJointName());
|
||||||
@ -84,40 +88,61 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
|
|||||||
//店铺结算单号
|
//店铺结算单号
|
||||||
bill.setSn(SnowFlake.createStr("B"));
|
bill.setSn(SnowFlake.createStr("B"));
|
||||||
|
|
||||||
//入账结算信息
|
|
||||||
Bill orderBill = this.baseMapper.getOrderBill(new QueryWrapper<Bill>()
|
|
||||||
.eq("store_id", storeId)
|
|
||||||
.eq("flow_type", FlowTypeEnum.PAY.name())
|
|
||||||
.between("create_time", startTime, endTime));
|
|
||||||
double orderPrice = 0D;
|
|
||||||
if (orderBill != null) {
|
|
||||||
bill.setOrderPrice(orderBill.getOrderPrice());
|
|
||||||
bill.setCommissionPrice(orderBill.getCommissionPrice());
|
|
||||||
bill.setDistributionCommission(orderBill.getDistributionCommission());
|
|
||||||
bill.setSiteCouponCommission(orderBill.getSiteCouponCommission());
|
|
||||||
bill.setPointSettlementPrice(orderBill.getPointSettlementPrice());
|
|
||||||
bill.setKanjiaSettlementPrice(orderBill.getKanjiaSettlementPrice());
|
|
||||||
//入账金额=订单金额
|
|
||||||
orderPrice = orderBill.getBillPrice();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//退款结算信息
|
//退款结算信息
|
||||||
Bill refundBill = this.baseMapper.getRefundBill(new QueryWrapper<Bill>()
|
Bill refundBill = this.baseMapper.getRefundBill(new QueryWrapper<Bill>()
|
||||||
.eq("store_id", storeId)
|
.eq("store_id", storeId)
|
||||||
.eq("flow_type", FlowTypeEnum.REFUND.name())
|
.eq("flow_type", FlowTypeEnum.REFUND.name())
|
||||||
.between("create_time", startTime, endTime));
|
.between("create_time", startTime, endTime));
|
||||||
|
//店铺退款金额
|
||||||
Double refundPrice = 0D;
|
Double refundPrice = 0D;
|
||||||
if (refundBill != null) {
|
if (refundBill != null) {
|
||||||
|
//退单金额
|
||||||
bill.setRefundPrice(refundBill.getRefundPrice());
|
bill.setRefundPrice(refundBill.getRefundPrice());
|
||||||
|
//退单产生退还佣金金额
|
||||||
bill.setRefundCommissionPrice(refundBill.getRefundCommissionPrice());
|
bill.setRefundCommissionPrice(refundBill.getRefundCommissionPrice());
|
||||||
|
//分销订单退还,返现佣金返还
|
||||||
bill.setDistributionRefundCommission(refundBill.getDistributionRefundCommission());
|
bill.setDistributionRefundCommission(refundBill.getDistributionRefundCommission());
|
||||||
|
//退货平台优惠券补贴返还
|
||||||
bill.setSiteCouponRefundCommission(refundBill.getSiteCouponRefundCommission());
|
bill.setSiteCouponRefundCommission(refundBill.getSiteCouponRefundCommission());
|
||||||
|
//退款金额=店铺最终退款结算金额
|
||||||
refundPrice = refundBill.getBillPrice();
|
refundPrice = refundBill.getBillPrice();
|
||||||
}
|
}
|
||||||
|
|
||||||
//最终结算金额=入款结算金额-退款结算金额
|
|
||||||
|
/**
|
||||||
|
* @TODO 入账结算信息
|
||||||
|
*/
|
||||||
|
Bill orderBill = this.baseMapper.getOrderBill(new QueryWrapper<Bill>()
|
||||||
|
.eq("store_id", storeId)
|
||||||
|
.eq("flow_type", FlowTypeEnum.PAY.name())
|
||||||
|
.between("create_time", startTime, endTime));
|
||||||
|
//店铺入款结算金额
|
||||||
|
double orderPrice = 0D;
|
||||||
|
|
||||||
|
if (orderBill != null) {
|
||||||
|
//结算周期内订单付款总金额
|
||||||
|
bill.setOrderPrice(orderBill.getOrderPrice());
|
||||||
|
//平台收取佣金
|
||||||
|
bill.setCommissionPrice(orderBill.getCommissionPrice());
|
||||||
|
//分销返现支出
|
||||||
|
bill.setDistributionCommission(orderBill.getDistributionCommission());
|
||||||
|
//平台优惠券补贴
|
||||||
|
bill.setSiteCouponCommission(orderBill.getSiteCouponCommission());
|
||||||
|
//积分商品结算价格
|
||||||
|
bill.setPointSettlementPrice(orderBill.getPointSettlementPrice());
|
||||||
|
//砍价商品结算价格
|
||||||
|
bill.setKanjiaSettlementPrice(orderBill.getKanjiaSettlementPrice());
|
||||||
|
//入款结算金额= 店铺支付结算金额 + 平台优惠券补贴 + 退单产生退还佣金金额 + 分销订单退还,返现佣金返还+退货平台优惠券补贴返还
|
||||||
|
orderPrice = CurrencyUtil.add(orderBill.getBillPrice(),
|
||||||
|
bill.getSiteCouponCommission(),
|
||||||
|
bill.getRefundCommissionPrice(),
|
||||||
|
bill.getDistributionRefundCommission(),
|
||||||
|
bill.getSiteCouponRefundCommission());
|
||||||
|
}
|
||||||
|
|
||||||
|
//最终结算金额=入款结算金额-退款结算金额-
|
||||||
Double finalPrice = CurrencyUtil.sub(orderPrice, refundPrice);
|
Double finalPrice = CurrencyUtil.sub(orderPrice, refundPrice);
|
||||||
|
//店铺最终结算金额=最终结算金额
|
||||||
bill.setBillPrice(finalPrice);
|
bill.setBillPrice(finalPrice);
|
||||||
|
|
||||||
//添加结算单
|
//添加结算单
|
||||||
|
Loading…
x
Reference in New Issue
Block a user