结算单-平台优惠券补贴金额错误修改
This commit is contained in:
parent
850b124da3
commit
7ca351f7cd
@ -76,16 +76,18 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
|
||||
List<OrderItem> orderItems = orderItemService.getByOrderSn(orderSn);
|
||||
//根据订单编号获取订单数据
|
||||
Order order = orderService.getBySn(orderSn);
|
||||
//如果查询到多条支付记录,打印日志
|
||||
if (order.getPayStatus().equals(PayStatusEnum.PAID.name())) {
|
||||
log.error("订单[{}]检测到重复付款,请处理", 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());
|
||||
@ -100,28 +102,24 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
|
||||
storeFlow.setOrderPromotionType(item.getPromotionType());
|
||||
//格式化订单价格详情
|
||||
PriceDetailDTO priceDetailDTO = JSONUtil.toBean(item.getPriceDetail(), PriceDetailDTO.class);
|
||||
//站点优惠券佣金
|
||||
storeFlow.setSiteCouponCommission(priceDetailDTO.getSiteCouponCommission());
|
||||
//站点优惠券佣金比例
|
||||
storeFlow.setSiteCouponPoint(CurrencyUtil.sub(100,priceDetailDTO.getSiteCouponPoint()));
|
||||
//平台优惠券 使用金额
|
||||
storeFlow.setSiteCouponPrice(priceDetailDTO.getSiteCouponPrice());
|
||||
//站点优惠券佣金比例
|
||||
storeFlow.setSiteCouponPoint(priceDetailDTO.getSiteCouponPoint());
|
||||
//站点优惠券佣金(站点优惠券承担金额=优惠券金额 * (站点承担比例/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.setFinalPrice(item.getPriceDetailDTO().getFlowPrice());
|
||||
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())) {
|
||||
@ -142,6 +140,7 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 店铺订单退款流水
|
||||
* @param afterSale 售后单
|
||||
|
@ -89,59 +89,49 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
|
||||
bill.setSn(SnowFlake.createStr("B"));
|
||||
|
||||
//退款结算信息
|
||||
Bill refundBill = this.baseMapper.getRefundBill(new QueryWrapper<Bill>()
|
||||
.eq("store_id", storeId)
|
||||
.eq("flow_type", FlowTypeEnum.REFUND.name())
|
||||
.between("create_time", startTime, endTime));
|
||||
Bill refundBill = this.baseMapper.getRefundBill(new QueryWrapper<Bill>().eq("store_id", storeId).eq("flow_type", FlowTypeEnum.REFUND.name()).between("create_time", startTime, endTime));
|
||||
//店铺退款金额
|
||||
Double refundPrice = 0D;
|
||||
if (refundBill != null) {
|
||||
//退单金额
|
||||
bill.setRefundPrice(refundBill.getRefundPrice());
|
||||
bill.setRefundPrice(refundBill.getRefundPrice() != null ? refundBill.getRefundPrice() : 0D);
|
||||
//退单产生退还佣金金额
|
||||
bill.setRefundCommissionPrice(refundBill.getRefundCommissionPrice());
|
||||
bill.setRefundCommissionPrice(refundBill.getRefundCommissionPrice() != null ? refundBill.getRefundCommissionPrice() : 0D);
|
||||
//分销订单退还,返现佣金返还
|
||||
bill.setDistributionRefundCommission(refundBill.getDistributionRefundCommission());
|
||||
bill.setDistributionRefundCommission(refundBill.getDistributionRefundCommission() != null ? refundBill.getRefundCommissionPrice() : 0D);
|
||||
//退货平台优惠券补贴返还
|
||||
bill.setSiteCouponRefundCommission(refundBill.getSiteCouponRefundCommission());
|
||||
bill.setSiteCouponRefundCommission(refundBill.getSiteCouponRefundCommission() != null ? refundBill.getSiteCouponRefundCommission() : 0D);
|
||||
//退款金额=店铺最终退款结算金额
|
||||
refundPrice = refundBill.getBillPrice();
|
||||
refundPrice = refundBill.getBillPrice() != null ? refundBill.getBillPrice() : 0D;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @TODO 入账结算信息
|
||||
*/
|
||||
Bill orderBill = this.baseMapper.getOrderBill(new QueryWrapper<Bill>()
|
||||
.eq("store_id", storeId)
|
||||
.eq("flow_type", FlowTypeEnum.PAY.name())
|
||||
.between("create_time", startTime, endTime));
|
||||
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.setOrderPrice(orderBill.getOrderPrice() != null ? orderBill.getOrderPrice() : 0D);
|
||||
//平台收取佣金
|
||||
bill.setCommissionPrice(orderBill.getCommissionPrice());
|
||||
bill.setCommissionPrice(orderBill.getCommissionPrice() != null ? orderBill.getCommissionPrice() : 0D);
|
||||
//分销返现支出
|
||||
bill.setDistributionCommission(orderBill.getDistributionCommission());
|
||||
bill.setDistributionCommission(orderBill.getDistributionCommission() != null ? orderBill.getDistributionCommission() : 0D);
|
||||
//平台优惠券补贴
|
||||
bill.setSiteCouponCommission(orderBill.getSiteCouponCommission());
|
||||
bill.setSiteCouponCommission(orderBill.getSiteCouponCommission() != null ? orderBill.getSiteCouponCommission() : 0D);
|
||||
//积分商品结算价格
|
||||
bill.setPointSettlementPrice(orderBill.getPointSettlementPrice());
|
||||
bill.setPointSettlementPrice(orderBill.getPointSettlementPrice() != null ? orderBill.getPointSettlementPrice() : 0D);
|
||||
//砍价商品结算价格
|
||||
bill.setKanjiaSettlementPrice(orderBill.getKanjiaSettlementPrice());
|
||||
bill.setKanjiaSettlementPrice(orderBill.getKanjiaSettlementPrice() != null ? orderBill.getKanjiaSettlementPrice() : 0D);
|
||||
|
||||
//入款结算金额= 店铺支付结算金额 + 平台优惠券补贴 + 分销订单退还,返现佣金返还+退单产生退还佣金金额
|
||||
orderPrice = CurrencyUtil.add(orderBill.getBillPrice(),
|
||||
bill.getSiteCouponCommission(),
|
||||
bill.getDistributionRefundCommission(),
|
||||
bill.getRefundCommissionPrice());
|
||||
orderPrice = CurrencyUtil.add(orderBill.getBillPrice() == null ? 0 : orderBill.getBillPrice(), bill.getSiteCouponCommission() == null ? 0 : bill.getSiteCouponCommission(), bill.getDistributionRefundCommission() == null ? 0 : bill.getDistributionRefundCommission(), bill.getRefundCommissionPrice() == null ? 0 : bill.getRefundCommissionPrice());
|
||||
}
|
||||
|
||||
//最终结算金额=入款结算金额-退款结算金额-退货平台优惠券补贴返还
|
||||
Double finalPrice = CurrencyUtil.sub(orderPrice, refundPrice,bill.getSiteCouponRefundCommission());
|
||||
Double finalPrice = CurrencyUtil.sub(orderPrice, refundPrice, bill.getSiteCouponRefundCommission() == null ? 0 : bill.getSiteCouponRefundCommission());
|
||||
//店铺最终结算金额=最终结算金额
|
||||
bill.setBillPrice(finalPrice);
|
||||
|
||||
@ -276,9 +266,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
|
||||
writer.setColumnWidth(12, 20);
|
||||
|
||||
|
||||
List<StoreFlowRefundDownloadVO> storeFlowRefundDownloadVOList = storeFlowService.getStoreFlowRefundDownloadVO(
|
||||
StoreFlowQueryDTO.builder().type(FlowTypeEnum.REFUND.name()).bill(bill).build()
|
||||
);
|
||||
List<StoreFlowRefundDownloadVO> storeFlowRefundDownloadVOList = storeFlowService.getStoreFlowRefundDownloadVO(StoreFlowQueryDTO.builder().type(FlowTypeEnum.REFUND.name()).bill(bill).build());
|
||||
writer.write(storeFlowRefundDownloadVOList, true);
|
||||
|
||||
ServletOutputStream out = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user