From 42ba802e77dea3e36fb24468919bdca111468a5c Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Fri, 17 Jan 2025 13:54:59 +0800
Subject: [PATCH] 1

---
 src/main/java/project/web/admin/AdminWithdrawController.java          |    5 
 src/main/java/project/withdraw/AdminWithdrawService.java              |    2 
 src/main/java/project/withdraw/internal/WithdrawServiceImpl.java      |   62 ++++-----------
 src/main/java/project/web/api/WithdrawController.java                 |   35 ++++----
 src/main/java/project/withdraw/internal/AdminWithdrawServiceImpl.java |   80 ++++++++++++--------
 src/main/java/project/withdraw/WithdrawService.java                   |    3 
 6 files changed, 88 insertions(+), 99 deletions(-)

diff --git a/src/main/java/project/web/admin/AdminWithdrawController.java b/src/main/java/project/web/admin/AdminWithdrawController.java
index 2ff1f1e..5e3f5c0 100644
--- a/src/main/java/project/web/admin/AdminWithdrawController.java
+++ b/src/main/java/project/web/admin/AdminWithdrawController.java
@@ -229,8 +229,7 @@
 			lock = true;
 
 			// 统一处理失败接口
-			WalletGatherService walletGatherService = new WalletGatherServiceImpl(jdbcTemplate,redisHandler,walletService);
-			this.adminWithdrawService.saveReject(id, failure_msg, this.getUsername_login(), this.getLoginPartyId(),walletGatherService);
+			this.adminWithdrawService.saveReject(id, failure_msg, this.getUsername_login(), this.getLoginPartyId());
 			ThreadUtils.sleep(300);
 		} catch (BusinessException e) {
 			modelAndView.addObject("error", e.getMessage());
@@ -244,7 +243,7 @@
 				LockFilter.remove(id);
 			}
 		}
-		
+
 		modelAndView.addObject("message", "操作成功");
 		return modelAndView;
 	}
diff --git a/src/main/java/project/web/api/WithdrawController.java b/src/main/java/project/web/api/WithdrawController.java
index fc6e02c..978b75a 100644
--- a/src/main/java/project/web/api/WithdrawController.java
+++ b/src/main/java/project/web/api/WithdrawController.java
@@ -133,7 +133,7 @@
 		if (!"0".equals(resultObject.getCode())) {
 			return resultObject;
 		}
-		
+
 		String partyId = this.getLoginPartyId();
 		boolean lock = false;
 		try {
@@ -141,17 +141,17 @@
 			if (!StringUtils.isNullOrEmpty(error)) {
 				throw new BusinessException(error);
 			}
-			
+
 			double amount_double = Double.valueOf(amount).doubleValue();
-			
+
 			// 交易所提现是否需要资金密码
 			String exchange_withdraw_need_safeword = this.sysparaService.find("exchange_withdraw_need_safeword").getValue();
 			if(StringUtils.isEmptyString(exchange_withdraw_need_safeword)) {
 				throw new BusinessException("系统参数错误");
 			}
-			
+
 			if ("true".equals(exchange_withdraw_need_safeword)) {
-				
+
 				if (StringUtils.isEmptyString(safeword)) {
 					throw new BusinessException("资金密码不能为空");
 				}
@@ -159,18 +159,18 @@
 				if (safeword.length() < 6 || safeword.length() > 12) {
 					throw new BusinessException("资金密码必须6-12位");
 				}
-								
+
 				if (!this.partyService.checkSafeword(safeword, partyId)) {
 					throw new BusinessException("资金密码错误");
-				}				
+				}
 			}
 
 			if (!LockFilter.add(partyId)) {
 				throw new BusinessException(error);
 			}
-			
+
 			lock = true;
-			
+
 			Object object = this.sessionTokenService.cacheGet(session_token);
 			this.sessionTokenService.del(session_token);
 			if (null == object || !this.getLoginPartyId().equals((String) object)) {
@@ -183,11 +183,10 @@
 			withdraw.setAddress(from);
 			withdraw.setCurrency(currency);
 			withdraw.setDeviceIp(this.getIp());
-			
+
 			// 保存
-			WalletGatherService walletGatherService = new WalletGatherServiceImpl(jdbcTemplate,redisHandler,walletService);
-			this.withdrawService.saveApply(withdraw, channel, null, googleCode,walletGatherService);
-			
+			this.withdrawService.saveApply(withdraw, channel, null, googleCode);
+
 			Log log = new Log();
 			Party party = this.partyService.cachePartyBy(partyId, false);
 			log.setCategory(Constants.LOG_CATEGORY_SECURITY);
@@ -200,13 +199,13 @@
 
 		} catch (BusinessException e) {
 			if (105 == e.getSign()) {
-				resultObject.setCode("105");				
+				resultObject.setCode("105");
 			} else if (401 == e.getSign()) {
-				resultObject.setCode("401");				
+				resultObject.setCode("401");
 			} else if (506 == e.getSign()) {
-				resultObject.setCode("506");				
+				resultObject.setCode("506");
 			} else {
-				resultObject.setCode("1");				
+				resultObject.setCode("1");
 			}
 			resultObject.setMsg(e.getMessage());
 		} catch (Throwable t) {
@@ -220,7 +219,7 @@
 				LockFilter.remove(partyId);
 			}
 		}
-		
+
 		return resultObject;
 	}
 
diff --git a/src/main/java/project/withdraw/AdminWithdrawService.java b/src/main/java/project/withdraw/AdminWithdrawService.java
index fc72916..35b7dba 100644
--- a/src/main/java/project/withdraw/AdminWithdrawService.java
+++ b/src/main/java/project/withdraw/AdminWithdrawService.java
@@ -12,7 +12,7 @@
 	 * @param id
 	 * @param failure_msg 驳回原因
 	 */
-	public void saveReject(String id, String failure_msg, String userName, String partyId, WalletGatherService walletGatherService);
+	public void saveReject(String id, String failure_msg,String userName,String partyId);
 
 	/**
 	 * 通过
diff --git a/src/main/java/project/withdraw/WithdrawService.java b/src/main/java/project/withdraw/WithdrawService.java
index 973e597..0487a40 100644
--- a/src/main/java/project/withdraw/WithdrawService.java
+++ b/src/main/java/project/withdraw/WithdrawService.java
@@ -9,7 +9,8 @@
 	/**
 	 * 代付,通过web申请一个代付订单
 	 */
-	public void saveApply(Withdraw entity, String channel, String method_id, String googleCode, WalletGatherService walletGatherService);
+	public void saveApply(Withdraw entity, String channel, String method_id, String googleCode);
+//	public void saveApply(Withdraw entity, String channel, String method_id, String googleCode, WalletGatherService walletGatherService);
 
 	/**
 	 * 查找订单 order_no 订单号
diff --git a/src/main/java/project/withdraw/internal/AdminWithdrawServiceImpl.java b/src/main/java/project/withdraw/internal/AdminWithdrawServiceImpl.java
index e1796a8..0c6f10e 100644
--- a/src/main/java/project/withdraw/internal/AdminWithdrawServiceImpl.java
+++ b/src/main/java/project/withdraw/internal/AdminWithdrawServiceImpl.java
@@ -48,7 +48,7 @@
 	private TipService tipService;
 	
 	@Override
-	public void saveReject(String id, String failure_msg, String userName, String partyId, WalletGatherService walletGatherService) {
+	public void saveReject(String id, String failure_msg, String userName, String partyId) {
 		Withdraw withdraw = this.get(id);
 
 		if (withdraw.getSucceeded() == 2 ) {// 通过后不可驳回
@@ -67,41 +67,56 @@
 			symbol = "btc";
 		} else if (withdraw.getMethod().indexOf("ETH") != -1) {
 			symbol = "eth";
-		}  else if (withdraw.getMethod().indexOf("USDC") != -1) {
-			symbol = "eth";
 		} else {
 			symbol = "usdt";
 		}
-		WalletGather walletGather = walletGatherService.getWalletGatherByPartyId(withdraw.getPartyId(),null);
-		double amount_before = 0;
-		if("usdt".equals(symbol)){
-			amount_before = walletGather.getUsdtMoney();
-		} else if ("btc".equals(symbol)) {
-			amount_before = walletGather.getBtcMoney();
-		} else if ("eth".equals(symbol)) {
-			amount_before = walletGather.getEthMoney();
-		} else if ("usdc".equals(symbol)) {
-			amount_before = walletGather.getUsdcMoney();
+		if ("usdt".equals(symbol)) {
+			Wallet wallet = walletService.saveWalletByPartyId(withdraw.getPartyId());
+
+			double amount_before = wallet.getMoney();
+
+			walletService.update(wallet.getPartyId().toString(),
+					Arith.add(withdraw.getAmount(), withdraw.getAmount_fee()));
+
+			/*
+			 * 保存资金日志
+			 */
+			MoneyLog moneyLog = new MoneyLog();
+			moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN);
+			moneyLog.setAmount_before(amount_before);
+			moneyLog.setAmount(Arith.add(withdraw.getAmount(), withdraw.getAmount_fee()));
+			moneyLog.setAmount_after(
+					Arith.add(amount_before, Arith.add(withdraw.getAmount(), withdraw.getAmount_fee())));
+
+			moneyLog.setLog("驳回提现[" + withdraw.getOrder_no() + "]");
+			// moneyLog.setExtra(withdraw.getOrder_no());
+			moneyLog.setPartyId(withdraw.getPartyId());
+			moneyLog.setWallettype(Constants.WALLET);
+			moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_WITHDRAW);
+
+			moneyLogService.save(moneyLog);
+		} else {
+			WalletExtend walletExtend = walletService.saveExtendByPara(withdraw.getPartyId(), symbol);
+			double amount_before = walletExtend.getAmount();
+			walletService.updateExtend(withdraw.getPartyId().toString(), symbol, withdraw.getVolume());
+
+			/*
+			 * 保存资金日志
+			 */
+			MoneyLog moneyLog = new MoneyLog();
+			moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN);
+			moneyLog.setAmount_before(amount_before);
+			moneyLog.setAmount(withdraw.getVolume());
+			moneyLog.setAmount_after(Arith.add(amount_before, withdraw.getVolume()));
+
+			moneyLog.setLog("驳回提现[" + withdraw.getOrder_no() + "]");
+			// moneyLog.setExtra(withdraw.getOrder_no());
+			moneyLog.setPartyId(withdraw.getPartyId());
+			moneyLog.setWallettype(symbol.toUpperCase());
+			moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_WITHDRAW);
+
+			moneyLogService.save(moneyLog);
 		}
-		//修改资金账户
-		walletGatherService.update(walletGather.getPartyId().toString(),symbol,withdraw.getAmount(),"add");
-		/*
-		 * 保存资金日志
-		 */
-		MoneyLog moneyLog = new MoneyLog();
-		moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN);
-		moneyLog.setAmount_before(amount_before);
-		moneyLog.setAmount(Arith.add(withdraw.getAmount(), withdraw.getAmount_fee()));
-		moneyLog.setAmount_after(
-				Arith.add(amount_before, Arith.add(withdraw.getAmount(), withdraw.getAmount_fee())));
-
-		moneyLog.setLog("驳回提现[" + withdraw.getOrder_no() + "]");
-		// moneyLog.setExtra(withdraw.getOrder_no());
-		moneyLog.setPartyId(withdraw.getPartyId());
-		moneyLog.setWallettype(Constants.WALLET);
-		moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_WITHDRAW);
-
-		moneyLogService.save(moneyLog);
 		this.walletLogService.updateStatus(withdraw.getOrder_no(), withdraw.getSucceeded());
 
 		SecUser SecUser = secUserService.findUserByPartyId(withdraw.getPartyId());
@@ -117,6 +132,7 @@
 		tipService.deleteTip(withdraw.getId().toString());
 	}
 
+
 	@Override
 	public void saveSucceeded(String id, String safeword, String userName, String partyId) {
 		SecUser var5 = this.secUserService.findUserByLoginName(userName);
diff --git a/src/main/java/project/withdraw/internal/WithdrawServiceImpl.java b/src/main/java/project/withdraw/internal/WithdrawServiceImpl.java
index a8b133c..9ac4194 100644
--- a/src/main/java/project/withdraw/internal/WithdrawServiceImpl.java
+++ b/src/main/java/project/withdraw/internal/WithdrawServiceImpl.java
@@ -67,7 +67,7 @@
 	protected TipService tipService;
 
 	@Override
-	public void saveApply(Withdraw withdraw, String channel, String method_id, String googleCode,WalletGatherService walletGatherService) {
+	public void saveApply(Withdraw withdraw, String channel, String method_id, String googleCode) {
 		Party party = this.partyService.cachePartyBy(withdraw.getPartyId(), false);
 		if (Constants.SECURITY_ROLE_TEST.equals(party.getRolename())) {
 			throw new BusinessException(1, "无权限");
@@ -120,16 +120,16 @@
 // 			+withdrawList.get(0).getDeviceIp()+"]不同, 请注意核对!!!");
 // 			}
 // 		}
-		System.out.println("打印信息");
+
 		withdraw.setMethod(channel);
 		if (channel.indexOf("BTC") != -1) {
-			saveApplyOtherChannel(withdraw, "btc",walletGatherService);
+			saveApplyOtherChannel(withdraw, "btc");
 			return;
 		} else if (channel.indexOf("ETH") != -1) {
-			saveApplyOtherChannel(withdraw, "eth",walletGatherService);
+			saveApplyOtherChannel(withdraw, "eth");
 			return;
 		}else  if(channel.indexOf("USDC") !=-1){
-			saveApplyOtherChannel(withdraw, "usdc",walletGatherService);
+			saveApplyOtherChannel(withdraw, "usdc");
 			return;
 		}
 		Kyc party_kyc = this.kycService.get(withdraw.getPartyId().toString());
@@ -154,12 +154,8 @@
 			throw new BusinessException(506, "Your account has been frozen");
 		}
 
-//		Wallet wallet = walletService.saveWalletByPartyId(withdraw.getPartyId());
-		System.out.println("获取walletGather前");
-		WalletGather walletGather = walletGatherService.getWalletGatherByPartyId(withdraw.getPartyId(),null);
-		System.out.println("获取walletGather后");
-		System.out.println("walletGather-usdt"+walletGather.getUsdtMoney());
-		if (walletGather.getUsdtMoney() < withdraw.getVolume()) {
+		Wallet wallet = walletService.saveWalletByPartyId(withdraw.getPartyId());
+		if (wallet.getMoney() < withdraw.getVolume()) {
 			throw new BusinessException(1, "余额不足");
 		}
 
@@ -398,12 +394,10 @@
 
 		withdraw.setQdcode(withdraw_qr);
 
-		double amount_before = walletGather.getUsdtMoney();
+		double amount_before = wallet.getMoney();
 
-//		wallet.setMoney(Arith.sub(wallet.getMoney(), withdraw.getVolume()));
-//		walletService.update(wallet.getPartyId().toString(), Arith.sub(0, withdraw.getVolume()));
-		//修改资金账户
-		walletGatherService.update(walletGather.getPartyId().toString(),"usdt",withdraw.getVolume(),"sub");
+		wallet.setMoney(Arith.sub(wallet.getMoney(), withdraw.getVolume()));
+		walletService.update(wallet.getPartyId().toString(), Arith.sub(0, withdraw.getVolume()));
 
 		withdraw.setId(ApplicationUtil.getCurrentTimeUUID());
 		insertWithdraw(withdraw);
@@ -415,7 +409,7 @@
 		moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN);
 		moneyLog.setAmount_before(amount_before);
 		moneyLog.setAmount(Arith.sub(0, withdraw.getVolume()));
-		moneyLog.setAmount_after(Arith.sub(amount_before, withdraw.getVolume()));
+		moneyLog.setAmount_after(wallet.getMoney());
 
 		moneyLog.setLog("提现订单[" + withdraw.getOrder_no() + "]");
 		// moneyLog.setExtra(withdraw.getOrder_no());
@@ -530,7 +524,7 @@
 		return userWithdraw;
 	}
 
-	public void saveApplyOtherChannel(Withdraw withdraw, String symbol,WalletGatherService walletGatherService) {
+	public void saveApplyOtherChannel(Withdraw withdraw, String symbol) {
 
 		Party party = this.partyService.cachePartyBy(withdraw.getPartyId(), false);
 		if (Constants.SECURITY_ROLE_TEST.equals(party.getRolename())) {
@@ -557,29 +551,11 @@
 		if (!party.getEnabled()) {
 			throw new BusinessException(506, "Your account has been frozen");
 		}
-		double amount_before = 0;
-		WalletGather walletGather = walletGatherService.getWalletGatherByPartyId(withdraw.getPartyId(),null);
-		if("btc".equals(symbol)){
-			if (walletGather.getBtcMoney() < withdraw.getVolume()) {
-				throw new BusinessException(1, "余额不足");
-			}
-			amount_before = walletGather.getBtcMoney();
-		}else if("eth".equals(symbol)){
-			if (walletGather.getEthMoney() < withdraw.getVolume()) {
-				throw new BusinessException(1, "余额不足");
-			}
-			amount_before = walletGather.getBtcMoney();
-		}else if("usdc".equals(symbol)){
-			if (walletGather.getUsdcMoney() < withdraw.getVolume()) {
-				throw new BusinessException(1, "余额不足");
-			}
-			amount_before = walletGather.getBtcMoney();
-		}
 
-//		WalletExtend walletExtend = walletService.saveExtendByPara(party.getId(), symbol);
-//		if (walletExtend.getAmount() < withdraw.getVolume()) {
-//			throw new BusinessException(1, "余额不足");
-//		}
+		WalletExtend walletExtend = walletService.saveExtendByPara(party.getId(), symbol);
+		if (walletExtend.getAmount() < withdraw.getVolume()) {
+			throw new BusinessException(1, "余额不足");
+		}
 
 		String withdraw_limit = sysparaService.find("withdraw_limit_" + symbol).getValue();
 		if (withdraw.getVolume() < Double.valueOf(withdraw_limit)) {
@@ -731,11 +707,9 @@
 
 		withdraw.setQdcode(withdraw_qr);
 
+		double amount_before = walletExtend.getAmount();
 
-//		walletService.updateExtend(walletExtend.getPartyId().toString(), symbol, Arith.sub(0, withdraw.getVolume()));
-		//修改资金账户
-		walletGatherService.update(walletGather.getPartyId().toString(),symbol,withdraw.getVolume(),"sub");
-
+		walletService.updateExtend(walletExtend.getPartyId().toString(), symbol, Arith.sub(0, withdraw.getVolume()));
 		withdraw.setId(ApplicationUtil.getCurrentTimeUUID());
 		insertWithdraw(withdraw);
 

--
Gitblit v1.9.3