From efb6f9d656f72c3016d738f079c92de021b9f14f Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期三, 04 十二月 2024 10:04:41 +0800
Subject: [PATCH] 1.常规配置-基本配置 2.分类-修改分类名称批量修改商品名称
---
src/main/java/com/mzl/flower/service/impl/wallet/WalletBillRecordServiceImpl.java | 74 +++++++++++++++++-------------------
1 files changed, 35 insertions(+), 39 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 f878321..f3a17c7 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
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.mzl.flower.config.exception.ValidationException;
import com.mzl.flower.config.security.SecurityUtils;
import com.mzl.flower.constant.Constants;
import com.mzl.flower.constant.LockConstants;
@@ -102,45 +103,29 @@
walletBillRecordDO.setRemark("微信商户转账成功");
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.getSupplierId());
+ 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)) {
+ //提现中金额:减少提现中金额
+ 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.BILL_WITHDRAW_TYPE.success.name());
- walletBillRecordDO.setRemark("微信商户转账成功");
walletWithdrawRecordMapper.updateById(withdrawRecordDO);
}
@@ -148,7 +133,7 @@
walletBillRecordDO.setTransferState(Constants.SETTLEMENT_STATUS.FAILED.name());
walletBillRecordDO.update("sys");
walletBillRecordMapper.updateById(walletBillRecordDO);
- WalletDO walletDO = walletService.getOrCreateBySupplierId(walletBillRecordDO.getWalletId());
+ WalletDO walletDO = walletService.getOrCreateBySupplierId(walletBillRecordDO.getSupplierId());
RLock lock = redissonClient.getLock(String.format(LockConstants.WALLET_ID_KEY, walletDO.getId()));
try {
if (lock.tryLock(10, 30, TimeUnit.SECONDS)) {
@@ -187,10 +172,9 @@
throw new RuntimeException(e);
}
//回写提现状态
- if (StringUtils.isEmpty(walletBillRecordDO.getWithdrawRecordId())) {
+ if (!StringUtils.isEmpty(walletBillRecordDO.getWithdrawRecordId())) {
WalletWithdrawRecordDO withdrawRecordDO = walletWithdrawRecordMapper.selectById(walletBillRecordDO.getWithdrawRecordId());
withdrawRecordDO.setWithdrawState(Constants.BILL_WITHDRAW_TYPE.fail.name());
- walletBillRecordDO.setRemark("微信商户转账失败,余额返还钱包");
walletWithdrawRecordMapper.updateById(withdrawRecordDO);
}
}
@@ -199,6 +183,13 @@
@Override
public Page<WalletBillRecordVO> queryPage(QueryWalletBillRecordDTO queryWalletBillRecordDTO, Page page) {
+ try {
+ if (!StringUtils.isEmpty(queryWalletBillRecordDTO.getSupplierId())) {
+ Long supplierId = Long.parseLong(queryWalletBillRecordDTO.getSupplierId());
+ }
+ } catch (Exception e) {
+ throw new ValidationException("供应商ID格式不正确");
+ }
List<WalletBillRecordVO> list = walletBillRecordMapper.queryPage(queryWalletBillRecordDTO, page);
page.setRecords(list);
return page;
@@ -260,4 +251,9 @@
public WalletBillRecordDO getBillRecordByWithdrawRecordId(Long withdrawRecordId) {
return walletBillRecordMapper.getBillRecordByWithdrawRecordId(withdrawRecordId);
}
+
+ @Override
+ public BigDecimal getHistoryAmount(Long walletId, Long supplierId) {
+ return walletBillRecordMapper.getHistoryAmount(walletId,supplierId);
+ }
}
--
Gitblit v1.9.3