From 0dd4d58348ea76cb24bbe3b862fec6ebbd35b78a Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Fri, 23 Jan 2026 12:40:00 +0800
Subject: [PATCH] 1

---
 src/main/java/com/nq/service/impl/UserWithdrawServiceImpl.java |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/nq/service/impl/UserWithdrawServiceImpl.java b/src/main/java/com/nq/service/impl/UserWithdrawServiceImpl.java
index 38a5d61..a97e665 100644
--- a/src/main/java/com/nq/service/impl/UserWithdrawServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/UserWithdrawServiceImpl.java
@@ -132,7 +132,9 @@
 
             SiteSetting siteSetting = this.iSiteSettingService.getSiteSetting();
 
-            if ((new BigDecimal(amt)).compareTo(new BigDecimal(siteSetting.getWithMinAmt().intValue())) == -1) {
+            BigDecimal outAmt = new BigDecimal(amt);
+
+            if (outAmt.compareTo(new BigDecimal(siteSetting.getWithMinAmt().intValue())) == -1) {
 
                 return ServerResponse.createByErrorMsg("出金金额不得低于" + siteSetting.getWithMinAmt() + "元");
 
@@ -169,19 +171,26 @@
 
             synchronized (UserWithdrawServiceImpl.class){
             //可取港币资金
-            BigDecimal hkAmt=user.getHkAmt();
+            BigDecimal hkAmt=user.getEnaleWithdrawAmt();
 
-            int compareAmt = hkAmt.compareTo(new BigDecimal(amt));
+            BigDecimal userAmt=user.getEnableAmt();
+
+            int compareAmt = hkAmt.compareTo(outAmt);
 
             if (compareAmt == -1) {
 
-                return ServerResponse.createByErrorMsg("提现失败,用户可取港币资金不足");
+                return ServerResponse.createByErrorMsg("提现失败,用户可取资金不足");
 
             }
 
-            BigDecimal reckon_hkAmt = hkAmt.subtract(new BigDecimal(amt));
+            if (userAmt.compareTo(outAmt) < 0) {
+                return ServerResponse.createByErrorMsg("提现失败,用户可用资金不足");
+            }
 
-            user.setHkAmt(reckon_hkAmt);
+            BigDecimal reckon_hkAmt = hkAmt.subtract(outAmt);
+
+            user.setEnaleWithdrawAmt(reckon_hkAmt);
+            user.setEnableAmt(userAmt.subtract(outAmt));
 
             log.info("提现前,港币金额={},提现后,港币金额={}",hkAmt,reckon_hkAmt);
 
@@ -208,7 +217,7 @@
 
             userWithdraw.setAgentId(user.getAgentId());
 
-            userWithdraw.setWithAmt(new BigDecimal(amt));
+            userWithdraw.setWithAmt(outAmt);
 
             userWithdraw.setApplyTime(new Date());
 
@@ -223,7 +232,7 @@
             userWithdraw.setWithStatus(Integer.valueOf(0));
 
 
-            BigDecimal withfee = siteSetting.getWithFeePercent().multiply(new BigDecimal(amt)).add(new BigDecimal(siteSetting.getWithFeeSingle().intValue()));
+            BigDecimal withfee = siteSetting.getWithFeePercent().multiply(outAmt).add(new BigDecimal(siteSetting.getWithFeeSingle().intValue()));
 
             //userWithdraw.setWithFee(withfee);
 
@@ -448,12 +457,14 @@
 
             }
 
-            //计算返还的总港币金额
-            BigDecimal hkAmt = user.getHkAmt().add(userWithdraw.getWithAmt());
+            //计算返还的可取金额
+            BigDecimal hkAmt = user.getEnaleWithdrawAmt().add(userWithdraw.getWithAmt());
 
-            log.info("管理员确认提现订单失败,返还用户 {} 总资金,原金额 = {} , 返还后 = {}", new Object[]{user.getId(), user.getHkAmt(), hkAmt});
+            log.info("管理员确认提现订单失败,返还用户 {} 可取资金,原金额 = {} , 返还后 = {}", new Object[]{user.getId(), user.getEnaleWithdrawAmt(), hkAmt});
 
-            user.setHkAmt(hkAmt);
+            user.setEnaleWithdrawAmt(hkAmt);
+            user.setEnableAmt(user.getEnableAmt().add(userWithdraw.getWithAmt()));
+
             int updateCount = this.userMapper.updateByPrimaryKeySelective(user);
 
             if (updateCount > 0) {

--
Gitblit v1.9.3