结算单-平台优惠券补贴金额错误修改

This commit is contained in:
fengtianyangyang 2022-05-11 19:20:35 +08:00
parent 850b124da3
commit 7ca351f7cd
2 changed files with 30 additions and 43 deletions

View File

@ -76,16 +76,18 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
List<OrderItem> orderItems = orderItemService.getByOrderSn(orderSn); List<OrderItem> orderItems = orderItemService.getByOrderSn(orderSn);
//根据订单编号获取订单数据 //根据订单编号获取订单数据
Order order = orderService.getBySn(orderSn); Order order = orderService.getBySn(orderSn);
//如果查询到多条支付记录打印日志
if (order.getPayStatus().equals(PayStatusEnum.PAID.name())) {
log.error("订单[{}]检测到重复付款,请处理", orderSn);
}
//获取订单促销类型,如果为促销订单则获取促销商品并获取结算价 //获取订单促销类型,如果为促销订单则获取促销商品并获取结算价
String orderPromotionType = order.getOrderPromotionType(); String orderPromotionType = order.getOrderPromotionType();
//循环子订单记录流水 //循环子订单记录流水
for (OrderItem item : orderItems) { for (OrderItem item : orderItems) {
StoreFlow storeFlow = new StoreFlow(); StoreFlow storeFlow = new StoreFlow();
BeanUtil.copyProperties(item, storeFlow); BeanUtil.copyProperties(item, storeFlow);
//去掉orderitem的时间
storeFlow.setCreateTime(null);
//入账 //入账
storeFlow.setId(SnowFlake.getIdStr()); storeFlow.setId(SnowFlake.getIdStr());
storeFlow.setFlowType(FlowTypeEnum.PAY.name()); storeFlow.setFlowType(FlowTypeEnum.PAY.name());
@ -100,28 +102,24 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
storeFlow.setOrderPromotionType(item.getPromotionType()); storeFlow.setOrderPromotionType(item.getPromotionType());
//格式化订单价格详情 //格式化订单价格详情
PriceDetailDTO priceDetailDTO = JSONUtil.toBean(item.getPriceDetail(), PriceDetailDTO.class); PriceDetailDTO priceDetailDTO = JSONUtil.toBean(item.getPriceDetail(), PriceDetailDTO.class);
//站点优惠券佣金 //站点优惠券佣金比例
storeFlow.setSiteCouponCommission(priceDetailDTO.getSiteCouponCommission()); storeFlow.setSiteCouponPoint(CurrencyUtil.sub(100,priceDetailDTO.getSiteCouponPoint()));
//平台优惠券 使用金额 //平台优惠券 使用金额
storeFlow.setSiteCouponPrice(priceDetailDTO.getSiteCouponPrice()); storeFlow.setSiteCouponPrice(priceDetailDTO.getSiteCouponPrice());
//站点优惠券佣金比例 //站点优惠券佣金站点优惠券承担金额=优惠券金额 * (站点承担比例/100)
storeFlow.setSiteCouponPoint(priceDetailDTO.getSiteCouponPoint()); 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.setCommissionPrice(item.getPriceDetailDTO().getPlatFormCommission());
//单品分销返现支出 //订单流水金额
storeFlow.setFinalPrice(item.getPriceDetailDTO().getFlowPrice());
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)) {
if (orderPromotionType.equals(OrderPromotionTypeEnum.NORMAL.name())) { if (orderPromotionType.equals(OrderPromotionTypeEnum.NORMAL.name())) {
//普通订单操作 //普通订单操作
} }
//如果为砍价活动填写砍价结算价 //如果为砍价活动填写砍价结算价
else if (orderPromotionType.equals(OrderPromotionTypeEnum.KANJIA.name())) { else if (orderPromotionType.equals(OrderPromotionTypeEnum.KANJIA.name())) {
@ -142,6 +140,7 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
} }
} }
/** /**
* 店铺订单退款流水 * 店铺订单退款流水
* @param afterSale 售后单 * @param afterSale 售后单

View File

@ -89,59 +89,49 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
bill.setSn(SnowFlake.createStr("B")); bill.setSn(SnowFlake.createStr("B"));
//退款结算信息 //退款结算信息
Bill refundBill = this.baseMapper.getRefundBill(new QueryWrapper<Bill>() Bill refundBill = this.baseMapper.getRefundBill(new QueryWrapper<Bill>().eq("store_id", storeId).eq("flow_type", FlowTypeEnum.REFUND.name()).between("create_time", startTime, endTime));
.eq("store_id", storeId)
.eq("flow_type", FlowTypeEnum.REFUND.name())
.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() != 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 入账结算信息 * @TODO 入账结算信息
*/ */
Bill orderBill = this.baseMapper.getOrderBill(new QueryWrapper<Bill>() Bill orderBill = this.baseMapper.getOrderBill(new QueryWrapper<Bill>().eq("store_id", storeId).eq("flow_type", FlowTypeEnum.PAY.name()).between("create_time", startTime, endTime));
.eq("store_id", storeId)
.eq("flow_type", FlowTypeEnum.PAY.name())
.between("create_time", startTime, endTime));
//店铺入款结算金额 //店铺入款结算金额
double orderPrice = 0D; double orderPrice = 0D;
if (orderBill != null) { 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(), 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());
bill.getSiteCouponCommission(),
bill.getDistributionRefundCommission(),
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); bill.setBillPrice(finalPrice);
@ -276,9 +266,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
writer.setColumnWidth(12, 20); writer.setColumnWidth(12, 20);
List<StoreFlowRefundDownloadVO> storeFlowRefundDownloadVOList = storeFlowService.getStoreFlowRefundDownloadVO( List<StoreFlowRefundDownloadVO> storeFlowRefundDownloadVOList = storeFlowService.getStoreFlowRefundDownloadVO(StoreFlowQueryDTO.builder().type(FlowTypeEnum.REFUND.name()).bill(bill).build());
StoreFlowQueryDTO.builder().type(FlowTypeEnum.REFUND.name()).bill(bill).build()
);
writer.write(storeFlowRefundDownloadVOList, true); writer.write(storeFlowRefundDownloadVOList, true);
ServletOutputStream out = null; ServletOutputStream out = null;