From d615fc515fc52d6ed970c11d59a017e48de4be32 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Tue, 16 Jun 2026 16:43:58 +0800
Subject: [PATCH] 1
---
src/main/java/com/nq/service/impl/UserWithdrawServiceImpl.java | 78 +++++++++++++++++++++++++++++---------
1 files changed, 59 insertions(+), 19 deletions(-)
diff --git a/src/main/java/com/nq/service/impl/UserWithdrawServiceImpl.java b/src/main/java/com/nq/service/impl/UserWithdrawServiceImpl.java
index 7b33ddf..9c86ec8 100644
--- a/src/main/java/com/nq/service/impl/UserWithdrawServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/UserWithdrawServiceImpl.java
@@ -16,6 +16,7 @@
import com.nq.dao.UserWithdrawMapper;
+import com.nq.utils.TradingDayUtil;
import com.nq.utils.stock.WithDrawUtils;
import java.math.BigDecimal;
@@ -159,7 +160,7 @@
// return ServerResponse.createByErrorMsg("提款失败,当前不能出金!");
// }
- if(siteProduct.getHolidayDisplay() && siteProduct.getTranWithdrawDisplay()){
+ if(siteProduct.getTranWithdrawDisplay() && TradingDayUtil.shouldBlockTradingToday(siteProduct)){
return ServerResponse.createByErrorMsg("周末或节假日不能出金!");
}
@@ -171,22 +172,27 @@
synchronized (UserWithdrawServiceImpl.class){
- //可取港币资金
- BigDecimal hkAmt=user.getEnaleWithdrawAmt();
+ BigDecimal withdrawAmt = new BigDecimal(amt);
+ BigDecimal enableWithdrawAmt = user.getEnaleWithdrawAmt() == null ? BigDecimal.ZERO : user.getEnaleWithdrawAmt();
+ BigDecimal enableAmt = user.getEnableAmt() == null ? BigDecimal.ZERO : user.getEnableAmt();
- int compareAmt = hkAmt.compareTo(new BigDecimal(amt));
-
- if (compareAmt == -1) {
+ if (enableWithdrawAmt.compareTo(withdrawAmt) < 0) {
return ServerResponse.createByErrorMsg("提现失败,用户可取港币资金不足");
}
- BigDecimal reckon_hkAmt = hkAmt.subtract(new BigDecimal(amt));
+ if (enableAmt.compareTo(withdrawAmt) < 0) {
- user.setEnaleWithdrawAmt(reckon_hkAmt);
+ return ServerResponse.createByErrorMsg("提现失败,用户可用资金不足");
- log.info("提现前,港币金额={},提现后,港币金额={}",hkAmt,reckon_hkAmt);
+ }
+
+ BigDecimal reckonEnableWithdrawAmt = enableWithdrawAmt.subtract(withdrawAmt);
+
+ user.setEnaleWithdrawAmt(reckonEnableWithdrawAmt);
+
+ log.info("提现申请,用户 {} 冻结可取资金,原金额 = {} , 冻结后 = {}", user.getId(), enableWithdrawAmt, reckonEnableWithdrawAmt);
int updateUserCount = this.userMapper.updateByPrimaryKeySelective(user);
@@ -305,17 +311,14 @@
User user = this.userMapper.selectByPrimaryKey(userWithdraw.getUserId());
- user.setUserAmt(user.getUserAmt().add(userWithdraw.getWithAmt()));
-
- user.setEnableAmt(user.getEnableAmt().add(userWithdraw.getWithAmt()));
-
- user.setEnaleWithdrawAmt(user.getEnaleWithdrawAmt().add(userWithdraw.getWithAmt()));
+ BigDecimal enableWithdrawAmt = user.getEnaleWithdrawAmt() == null ? BigDecimal.ZERO : user.getEnaleWithdrawAmt();
+ user.setEnaleWithdrawAmt(enableWithdrawAmt.add(userWithdraw.getWithAmt()));
int updateUserCount = this.userMapper.updateByPrimaryKeySelective(user);
if (updateUserCount > 0) {
- log.info("反还用户资金,总 {} 可用 {}", user.getUserAmt(), user.getEnableAmt());
+ log.info("用户取消提现,返还可取资金 {}", userWithdraw.getWithAmt());
return ServerResponse.createBySuccessMsg("取消成功");
@@ -413,6 +416,7 @@
}
+ @Transactional
public ServerResponse updateState(Integer withId, Integer state, String authMsg) throws Exception {
UserWithdraw userWithdraw = this.userWithdrawMapper.selectByPrimaryKey(withId);
@@ -440,6 +444,42 @@
}
+ if (state.intValue() == 1) {
+
+ User user = this.userMapper.selectByPrimaryKey(userWithdraw.getUserId());
+
+ if (user == null) {
+
+ return ServerResponse.createByErrorMsg("用户不存在");
+
+ }
+
+ BigDecimal withAmt = userWithdraw.getWithAmt();
+ BigDecimal enableAmt = user.getEnableAmt() == null ? BigDecimal.ZERO : user.getEnableAmt();
+
+ if (enableAmt.compareTo(withAmt) < 0) {
+
+ return ServerResponse.createByErrorMsg("用户可用资金不足,无法完成提现");
+
+ }
+
+ BigDecimal afterEnableAmt = enableAmt.subtract(withAmt);
+
+ user.setEnableAmt(afterEnableAmt);
+
+ log.info("管理员确认提现成功,扣减用户 {} 可用资金,原金额 = {} , 扣减后 = {}", user.getId(), enableAmt, afterEnableAmt);
+
+ int updateCount = this.userMapper.updateByPrimaryKeySelective(user);
+
+ if (updateCount <= 0) {
+
+ throw new Exception("修改用户资金出错,抛出异常");
+
+ }
+
+ }
+
+
if (state.intValue() == 2) {
@@ -451,12 +491,12 @@
}
- //计算返还的总港币金额
- BigDecimal hkAmt = user.getHkAmt().add(userWithdraw.getWithAmt());
+ BigDecimal enableWithdrawAmt = user.getEnaleWithdrawAmt() == null ? BigDecimal.ZERO : user.getEnaleWithdrawAmt();
+ BigDecimal refundAmt = enableWithdrawAmt.add(userWithdraw.getWithAmt());
- log.info("管理员确认提现订单失败,返还用户 {} 总资金,原金额 = {} , 返还后 = {}", new Object[]{user.getId(), user.getHkAmt(), hkAmt});
+ log.info("管理员确认提现订单失败,返还用户 {} 可取资金,原金额 = {} , 返还后 = {}", user.getId(), enableWithdrawAmt, refundAmt);
- user.setHkAmt(hkAmt);
+ user.setEnaleWithdrawAmt(refundAmt);
int updateCount = this.userMapper.updateByPrimaryKeySelective(user);
if (updateCount > 0) {
--
Gitblit v1.9.3