From 6b68d921bcdb83ac4e33c521f0d5f8b4f6f18584 Mon Sep 17 00:00:00 2001 From: cloudroam <cloudroam> Date: 星期五, 08 十一月 2024 15:37:37 +0800 Subject: [PATCH] add:钱包功能调整1108 --- src/main/java/com/mzl/flower/service/impl/wallet/WalletBillRecordServiceImpl.java | 101 ++++++++++++++++++++++++++++---------------------- 1 files changed, 57 insertions(+), 44 deletions(-) diff --git a/src/main/java/com/mzl/flower/service/impl/wallet/WalletBillRecordServiceImpl.java b/src/main/java/com/mzl/flower/service/impl/wallet/WalletBillRecordServiceImpl.java index aa203b1..cff42cd 100644 --- a/src/main/java/com/mzl/flower/service/impl/wallet/WalletBillRecordServiceImpl.java +++ b/src/main/java/com/mzl/flower/service/impl/wallet/WalletBillRecordServiceImpl.java @@ -35,6 +35,7 @@ import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.net.URLEncoder; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; @@ -100,45 +101,45 @@ walletBillRecordDO.update("sys"); walletBillRecordMapper.updateById(walletBillRecordDO); //更新钱包 - WalletDO walletDO = walletService.getOrCreateBySupplierId(walletBillRecordDO.getWalletId()); - RLock lock = redissonClient.getLock(String.format(LockConstants.WALLET_ID_KEY, walletDO.getId())); - try { - if (lock.tryLock(10, 30, TimeUnit.SECONDS)) { - try { - if (!ObjectUtils.isEmpty(walletDO)) { - WalletBillRecordDO walletBillRecordDO2 = new WalletBillRecordDO(); - walletBillRecordDO2.setId(UUIDGenerator.getUUID()); - walletBillRecordDO2.setSupplierId(walletDO.getSupplierId()); - walletBillRecordDO2.setWalletId(walletDO.getId()); - walletBillRecordDO2.setType(Constants.BILL_CHANGE_TYPE.withdraw.name()); - // 发起提现 - walletBillRecordDO2.setWithdrawType(Constants.BILL_WITHDRAW_TYPE.success.name()); - walletBillRecordDO2.setMethod(Constants.BILL_CHANGE_METHOD.reduce.name()); - walletBillRecordDO2.setOriginalAmount(walletDO.getWithdrawableAmount()); - walletBillRecordDO2.setChangeAmount(BigDecimal.ZERO); - walletBillRecordDO2.setBalance(walletDO.getWithdrawableAmount()); - walletBillRecordDO2.create(SecurityUtils.getUserId()); - walletBillRecordDO.setId(UUIDGenerator.getUUID()); - // 保存账单明细 - walletBillRecordService.save(walletBillRecordDO); - //提现中金额:减少提现中金额 - walletDO.setWithdrawingAmount(walletDO.getWithdrawingAmount().subtract(walletBillRecordDO.getChangeAmount())); - //已提现金额:增加已提现金额 - walletDO.setWithdrawnAmount(walletDO.getWithdrawnAmount().add(walletBillRecordDO.getChangeAmount())); - walletMapper.updateById(walletDO); - } - } finally { - lock.unlock(); - } - } - } catch (InterruptedException e) { - throw new RuntimeException(e); - } +// WalletDO walletDO = walletService.getOrCreateBySupplierId(walletBillRecordDO.getWalletId()); +// RLock lock = redissonClient.getLock(String.format(LockConstants.WALLET_ID_KEY, walletDO.getId())); +// try { +// if (lock.tryLock(10, 30, TimeUnit.SECONDS)) { +// try { +// if (!ObjectUtils.isEmpty(walletDO)) { +// WalletBillRecordDO walletBillRecordDO2 = new WalletBillRecordDO(); +// walletBillRecordDO2.setId(UUIDGenerator.getUUID()); +// walletBillRecordDO2.setSupplierId(walletDO.getSupplierId()); +// walletBillRecordDO2.setWalletId(walletDO.getId()); +// walletBillRecordDO2.setType(Constants.BILL_CHANGE_TYPE.withdraw.name()); +// // 发起提现 +// walletBillRecordDO2.setWithdrawType(Constants.BILL_WITHDRAW_TYPE.success.name()); +// walletBillRecordDO2.setMethod(Constants.BILL_CHANGE_METHOD.reduce.name()); +// walletBillRecordDO2.setOriginalAmount(walletDO.getWithdrawableAmount()); +// walletBillRecordDO2.setChangeAmount(BigDecimal.ZERO); +// walletBillRecordDO2.setBalance(walletDO.getWithdrawableAmount()); +// walletBillRecordDO2.create(SecurityUtils.getUserId()); +// walletBillRecordDO.setId(UUIDGenerator.getUUID()); +// // 保存账单明细 +// walletBillRecordService.save(walletBillRecordDO); +// //提现中金额:减少提现中金额 +// walletDO.setWithdrawingAmount(walletDO.getWithdrawingAmount().subtract(walletBillRecordDO.getChangeAmount())); +// //已提现金额:增加已提现金额 +// walletDO.setWithdrawnAmount(walletDO.getWithdrawnAmount().add(walletBillRecordDO.getChangeAmount())); +// walletMapper.updateById(walletDO); +// } +// } finally { +// lock.unlock(); +// } +// } +// } catch (InterruptedException e) { +// throw new RuntimeException(e); +// } //回写提现状态 - if (StringUtils.isEmpty(walletBillRecordDO.getWithdrawRecordId())) { + if (!StringUtils.isEmpty(walletBillRecordDO.getWithdrawRecordId())) { WalletWithdrawRecordDO withdrawRecordDO = walletWithdrawRecordMapper.selectById(walletBillRecordDO.getWithdrawRecordId()); - withdrawRecordDO.setWithdrawState(Constants.WALLET_WITHDRAW_STATE.SUCCESS.name()); - walletBillRecordDO.setRemark("账户资金提现完成"); + withdrawRecordDO.setWithdrawState(Constants.BILL_WITHDRAW_TYPE.success.name()); + walletBillRecordDO.setRemark("微信商户转账成功"); walletWithdrawRecordMapper.updateById(withdrawRecordDO); } @@ -165,9 +166,12 @@ walletBillRecordDO2.setChangeAmount(walletBillRecordDO.getActualTransferAmount()); walletBillRecordDO2.setBalance(walletDO.getWithdrawableAmount().add(walletBillRecordDO.getActualTransferAmount())); walletBillRecordDO2.create(SecurityUtils.getUserId()); - walletBillRecordDO.setId(UUIDGenerator.getUUID()); + walletBillRecordDO2.setId(UUIDGenerator.getUUID()); + walletBillRecordDO2.setRemark("微信商户转账失败,余额返还钱包"); + walletBillRecordDO2.setApproveBy("sys"); + walletBillRecordDO2.setApproveTime(LocalDateTime.now()); // 保存账单明细 - walletBillRecordService.save(walletBillRecordDO); + walletBillRecordService.save(walletBillRecordDO2); //提现中金额:减少提现中金额 walletDO.setWithdrawingAmount(walletDO.getWithdrawingAmount().subtract(walletBillRecordDO.getActualTransferAmount())); //可提现金额:增加可提现金额 @@ -182,10 +186,9 @@ throw new RuntimeException(e); } //回写提现状态 - if (StringUtils.isEmpty(walletBillRecordDO.getWithdrawRecordId())) { + if (!StringUtils.isEmpty(walletBillRecordDO.getWithdrawRecordId())) { WalletWithdrawRecordDO withdrawRecordDO = walletWithdrawRecordMapper.selectById(walletBillRecordDO.getWithdrawRecordId()); - withdrawRecordDO.setWithdrawState(Constants.WALLET_WITHDRAW_STATE.FAILURE.name()); - walletBillRecordDO.setRemark("账户资金提现失败"); + withdrawRecordDO.setWithdrawState(Constants.BILL_WITHDRAW_TYPE.fail.name()); walletWithdrawRecordMapper.updateById(withdrawRecordDO); } } @@ -203,7 +206,7 @@ public void exportSupplierFinanceList(HttpServletResponse response, QueryWalletBillRecordDTO queryWalletBillRecordDTO) { List<WalletBillRecordVO> list = walletBillRecordMapper.queryWalletBillRecordList(queryWalletBillRecordDTO); - String[] rowsName = new String[]{"序号","供应商信息", "变动类型", "原金额", "变动金额", "现余额", "提交时间", "审核时间", "备注"}; + String[] rowsName = new String[]{"序号","供应商信息", "变动类型", "原金额", "变动金额", "现余额", "提交时间", "审核时间", "备注", "操作人"}; List<Object[]> dataList = new ArrayList<>(); int sn = 1; for (WalletBillRecordVO o : list) { @@ -213,11 +216,16 @@ objs[a++] = o.getSupplierName()+":"+o.getSupplierId(); // 供应商信息 objs[a++] = o.getTypeName(); // 变动类型 objs[a++] = o.getOriginalAmount(); // 原金额 - objs[a++] = o.getChangeAmount(); // 变动金额 + if (Constants.BILL_CHANGE_METHOD.reduce.name().equals(o.getMethod())) { + objs[a++] = "-" + o.getChangeAmount(); // 变动金额 + } else { + objs[a++] = "+" + o.getChangeAmount(); // 变动金额 + } objs[a++] = o.getBalance(); //现余额 objs[a++] = o.getCreateTime();//提交时间 objs[a++] = o.getApproveTime(); // 审核时间 objs[a++] = o.getRemark(); //备注 + objs[a++] = o.getApproveName(); //操作人 dataList.add(objs); sn++; } @@ -245,4 +253,9 @@ page.setRecords(list); return page; } + + @Override + public WalletBillRecordDO getBillRecordByWithdrawRecordId(Long withdrawRecordId) { + return walletBillRecordMapper.getBillRecordByWithdrawRecordId(withdrawRecordId); + } } -- Gitblit v1.9.3