From 520a6878cf6396625b70918593436bc824103eb4 Mon Sep 17 00:00:00 2001 From: cloudroam <cloudroam> Date: 星期五, 01 十一月 2024 13:19:54 +0800 Subject: [PATCH] fix: 钱包供应商财务2 --- src/main/java/com/mzl/flower/service/payment/OrderSettlementService.java | 59 +++++++++++++++++++++++++++++++---------------------------- 1 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/mzl/flower/service/payment/OrderSettlementService.java b/src/main/java/com/mzl/flower/service/payment/OrderSettlementService.java index 9bad835..1f1e32c 100644 --- a/src/main/java/com/mzl/flower/service/payment/OrderSettlementService.java +++ b/src/main/java/com/mzl/flower/service/payment/OrderSettlementService.java @@ -732,41 +732,44 @@ serviceFee = serviceFee.add(ois.getServiceFee()); serviceFeeRate = ois.getServiceFeeRate(); settlementAmount = settlementAmount.add(ois.getIncomeSupplier()); - WalletDO walletDO = walletService.getBySupplierId(supplierId); + WalletDO walletDO = walletService.getOrCreateBySupplierId(supplierId); RLock lock = redissonClient.getLock(String.format(LockConstants.WALLET_ID_KEY, walletDO.getId())); try { if (lock.tryLock(10, 30, TimeUnit.SECONDS)) { try { //2024-10-28 直接保存到walletBillRecord //新增WalletBillRecordDO - WalletBillRecordDO walletBillRecord = new WalletBillRecordDO(); - walletBillRecord.setId(UUIDGenerator.getUUID()); - WalletDO walletDOInfo = walletService.getBySupplierId(supplierId); - //增加供应商结算金额保存到钱包 - walletBillRecord.setSupplierId(supplierId); - walletBillRecord.setWalletId(walletDOInfo.getId()); - walletBillRecord.setSettlementId(settlement.getId()); - walletBillRecord.setOrderItemId(detail.getOrderItemId()); - //变动金额等于供应商收入 - walletBillRecord.setTotalAmount(ois.getIncomeSupplier()); - walletBillRecord.setType(Constants.BILL_CHANGE_TYPE.settlement.name()); - walletBillRecord.setMethod(Constants.BILL_CHANGE_METHOD.add.name()); - walletBillRecord.setOriginalAmount(walletDOInfo.getTotalAmount()); - walletBillRecord.setChangeAmount(ois.getIncomeSupplier()); - walletBillRecord.setBalance(walletDOInfo.getWithdrawableAmount().add(ois.getIncomeSupplier())); - Order order = orderMapper.selectById(detail.getOrderId()); - if (!ObjectUtils.isEmpty(order)) { - walletBillRecord.setRemark("订单完成(订单号" + order.getOrderNo() + ")" + ",获得收入"); - walletBillRecord.setOrderNo(order.getOrderNo()); + if(ois.getIncomeSupplier().compareTo(BigDecimal.ZERO) > 0) { + WalletBillRecordDO walletBillRecord = new WalletBillRecordDO(); + walletBillRecord.setId(UUIDGenerator.getUUID()); + WalletDO walletDOInfo = walletService.getBySupplierId(supplierId); + //增加供应商结算金额保存到钱包 + walletBillRecord.setSupplierId(supplierId); + walletBillRecord.setWalletId(walletDOInfo.getId()); + walletBillRecord.setSettlementId(settlement.getId()); + walletBillRecord.setOrderItemId(detail.getOrderItemId()); + //变动金额等于供应商收入 + walletBillRecord.setTotalAmount(ois.getIncomeSupplier()); + walletBillRecord.setType(Constants.BILL_CHANGE_TYPE.settlement.name()); + walletBillRecord.setMethod(Constants.BILL_CHANGE_METHOD.add.name()); + walletBillRecord.setOriginalAmount(walletDOInfo.getTotalAmount()); + walletBillRecord.setChangeAmount(ois.getIncomeSupplier()); + walletBillRecord.setBalance(walletDOInfo.getWithdrawableAmount().add(ois.getIncomeSupplier())); + Order order = orderMapper.selectById(detail.getOrderId()); + if (!ObjectUtils.isEmpty(order)) { + walletBillRecord.setRemark("订单完成(订单号" + order.getOrderNo() + ")" + ",获得收入"); + walletBillRecord.setOrderNo(order.getOrderNo()); + } + //更新钱包 + //可提现金额=钱包余额=结算金额 + walletDOInfo.setWithdrawableAmount(walletDOInfo.getWithdrawableAmount().add(ois.getIncomeSupplier())); + walletDOInfo.setTotalAmount(walletDOInfo.getWithdrawableAmount()); + //已结算金额 + walletDOInfo.setSettledAmount(walletDOInfo.getSettledAmount().add(ois.getIncomeSupplier())); + walletMapper.updateById(walletDOInfo); + walletBillRecord.create(); + walletBillRecordMapper.insert(walletBillRecord); } - //更新钱包 - //可提现金额=钱包余额=结算金额 - walletDOInfo.setWithdrawableAmount(walletDOInfo.getWithdrawableAmount().add(ois.getIncomeSupplier())); - walletDOInfo.setTotalAmount(walletDOInfo.getWithdrawableAmount()); - //已结算金额 - walletDOInfo.setSettledAmount(walletDOInfo.getSettledAmount().add(ois.getIncomeSupplier())); - walletMapper.updateById(walletDOInfo); - walletBillRecordMapper.insert(walletBillRecord); } finally { lock.unlock(); } -- Gitblit v1.9.3