From 7ca351f7cd43d7ebb291598e7bd617cf6b261961 Mon Sep 17 00:00:00 2001 From: fengtianyangyang <5411465+feng_tianyangyang@user.noreply.gitee.com> Date: Wed, 11 May 2022 19:20:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=93=E7=AE=97=E5=8D=95-=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E8=A1=A5=E8=B4=B4=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/StoreFlowServiceImpl.java | 29 ++++++------ .../store/serviceimpl/BillServiceImpl.java | 44 +++++++------------ 2 files changed, 30 insertions(+), 43 deletions(-) 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 8f888acd..3a1e6c8b 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 @@ -76,16 +76,18 @@ public class StoreFlowServiceImpl extends ServiceImpl 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 implements Bi bill.setSn(SnowFlake.createStr("B")); //退款结算信息 - Bill refundBill = this.baseMapper.getRefundBill(new QueryWrapper() - .eq("store_id", storeId) - .eq("flow_type", FlowTypeEnum.REFUND.name()) - .between("create_time", startTime, endTime)); + Bill refundBill = this.baseMapper.getRefundBill(new QueryWrapper().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() - .eq("store_id", storeId) - .eq("flow_type", FlowTypeEnum.PAY.name()) - .between("create_time", startTime, endTime)); + Bill orderBill = this.baseMapper.getOrderBill(new QueryWrapper().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 implements Bi writer.setColumnWidth(12, 20); - List storeFlowRefundDownloadVOList = storeFlowService.getStoreFlowRefundDownloadVO( - StoreFlowQueryDTO.builder().type(FlowTypeEnum.REFUND.name()).bill(bill).build() - ); + List storeFlowRefundDownloadVOList = storeFlowService.getStoreFlowRefundDownloadVO(StoreFlowQueryDTO.builder().type(FlowTypeEnum.REFUND.name()).bill(bill).build()); writer.write(storeFlowRefundDownloadVOList, true); ServletOutputStream out = null;