From 8c62c4f079fccdcce584a458a7b9741edbe34721 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Sun, 10 Aug 2025 23:47:58 +0800
Subject: [PATCH] 1
---
trading-order-service/src/main/java/com/yami/trading/service/impl/WithdrawServiceImpl.java | 97 ++++++++++++++++++++++++------------------------
1 files changed, 48 insertions(+), 49 deletions(-)
diff --git a/trading-order-service/src/main/java/com/yami/trading/service/impl/WithdrawServiceImpl.java b/trading-order-service/src/main/java/com/yami/trading/service/impl/WithdrawServiceImpl.java
index c2b650a..b659dc8 100644
--- a/trading-order-service/src/main/java/com/yami/trading/service/impl/WithdrawServiceImpl.java
+++ b/trading-order-service/src/main/java/com/yami/trading/service/impl/WithdrawServiceImpl.java
@@ -1,9 +1,12 @@
package com.yami.trading.service.impl;
import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.extra.qrcode.QrConfig;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -65,6 +68,8 @@
WalletLogService walletLogService;
@Autowired
LogService logService;
+ @Autowired
+ CapitaltWalletService capitaltWalletService;
@Override
public Page listRecord(Page page, String status, String roleName,
@@ -141,8 +146,18 @@
double amount_before = wallet.getMoney().doubleValue();
- walletService.update(wallet.getUserId().toString(),
- Arith.add(withdraw.getAmount(), withdraw.getAmountFee()));
+// walletService.update(wallet.getUserId().toString(),
+// Arith.add(withdraw.getAmount(), withdraw.getAmountFee()));
+
+ CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class)
+ .eq(CapitaltWallet::getUserId, wallet.getUserId().toString()).last(" limit 1 "));
+ if(ObjectUtil.isEmpty(capitaltWallet)){
+ throw new YamiShopBindException("用户资金账户不存在!");
+ }
+ capitaltWalletService.update(new LambdaUpdateWrapper<CapitaltWallet>()
+ .set(CapitaltWallet::getMoney,new BigDecimal(Arith.add(capitaltWallet.getMoney().doubleValue(), amount_before)))
+ .eq(CapitaltWallet::getUserId,wallet.getUserId()));
+
/*
* 保存资金日志
@@ -462,8 +477,12 @@
if (party.getStatus() != 1) {
throw new YamiShopBindException("Your account has been frozen");
}
- Wallet wallet = walletService.saveWalletByPartyId(withdraw.getUserId());
- if (wallet.getMoney().doubleValue() < withdraw.getVolume().doubleValue()) {
+
+// Wallet wallet = walletService.saveWalletByPartyId(withdraw.getUserId());
+
+ CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class)
+ .eq(CapitaltWallet::getUserId, withdraw.getUserId()).last(" limit 1 "));
+ if (capitaltWallet.getMoney().doubleValue() < withdraw.getVolume().doubleValue()) {
throw new YamiShopBindException("余额不足");
}
// 手续费(USDT)
@@ -558,7 +577,7 @@
/**
* 用户Party表里可提现金额参数 -----可为负数
*/
- double party_withdraw = party.getWithdrawLimitAmount().doubleValue();
+// double party_withdraw = party.getWithdrawLimitAmount().doubleValue();
/**
* usdt剩余余额
*/
@@ -593,15 +612,15 @@
}
}
}
- double withdraw_limit_turnover_percent = Double
- .valueOf(sysparaService.find("withdraw_limit_turnover_percent").getSvalue());
- party_withdraw = Arith.mul(party_withdraw, withdraw_limit_turnover_percent);
- // 流水小于限额
- if (userdata_turnover < party_withdraw) {
- fact_withdraw_amount = Arith.sub(party_withdraw, userdata_turnover);
- throw new YamiShopBindException(fact_withdraw_amount + "");
-// throw new BusinessException(1, "当前还需交易" + fact_withdraw_amount + ",才可提币");
- }
+// double withdraw_limit_turnover_percent = Double
+// .valueOf(sysparaService.find("withdraw_limit_turnover_percent").getSvalue());
+// party_withdraw = Arith.mul(party_withdraw, withdraw_limit_turnover_percent);
+// // 流水小于限额
+// if (userdata_turnover < party_withdraw) {
+// fact_withdraw_amount = Arith.sub(party_withdraw, userdata_turnover);
+// throw new YamiShopBindException(fact_withdraw_amount + "");
+//// throw new BusinessException(1, "当前还需交易" + fact_withdraw_amount + ",才可提币");
+// }
}
if ("2".equals(withdraw_limit_open_use_type)) {
/**
@@ -626,45 +645,13 @@
}
}
}
-// String withdraw_fee_type = sysparaService.find("withdraw_fee_type").getValue();
-// double withdraw_fee = Double.valueOf(((Syspara) sysparaService.find("withdraw_fee")).getValue());
-// DecimalFormat df = new DecimalFormat("#.##");
-// if ("fixed".equals(withdraw_fee_type)) {
-// fee = withdraw_fee;
-// } else {
-// fee = Double.valueOf(df.format(Arith.mul(withdraw.getVolume(), withdraw_fee)));
-//
-// }
withdraw.setAmountFee(new BigDecimal(fee));
-// ExchangeRate exchangeRate = exchangeRateService.findBy(ExchangeRate.OUT, withdraw.getCurrency());
-//
-// if (exchangeRate == null) {
-// throw new BusinessException("Parameter Error");
-// }
-//
-// withdraw.setAmount(Double.valueOf(df.format(Arith.mul(withdraw.getVolume(), exchangeRate.getRata()))));
withdraw.setAmount(new BigDecimal(Arith.sub(withdraw.getVolume().doubleValue(), fee)));
if (channel.indexOf("USDT") != -1) {
withdraw.setMethod(channel);
}
-// if ("USDT".equals(channel)) {
-// withdraw.setMethod("USDT");
-// }
else if ("OTC".equals(channel)) {
throw new YamiShopBindException("渠道未开通");
-// if (StringUtils.isNullOrEmpty(method_id)) {
-// throw new BusinessException("请选择付款账号");
-// }
-// PaymentMethod paymentMethod = paymentMethodService.get(method_id);
-// if (paymentMethod == null) {
-// throw new BusinessException("请选择付款账号");
-// }
-// withdraw.setMethod(paymentMethod.getMethod());
-// withdraw.setAccount(paymentMethod.getAccount());
-// withdraw.setBank(paymentMethod.getBank());
-// withdraw.setDeposit_bank(paymentMethod.getDeposit_bank());
-// withdraw.setQdcode(paymentMethod.getQdcode());
-// withdraw.setUsername(withdraw.getUsername());
} else {
throw new YamiShopBindException("渠道未开通");
}
@@ -680,8 +667,20 @@
*/
String withdraw_qr = qRGenerateService.generateWithdraw(withdraw.getOrderNo(), withdraw.getAddress());
withdraw.setQdcode(withdraw_qr);
- double amount_before = wallet.getMoney().doubleValue();
- walletService.update(wallet.getUserId().toString(), Arith.sub(0, withdraw.getVolume().doubleValue()));
+ double amount_before = capitaltWallet.getMoney().doubleValue();
+
+
+
+// walletService.update(wallet.getUserId().toString(), Arith.sub(0, withdraw.getVolume().doubleValue()));
+
+
+ if(ObjectUtil.isEmpty(capitaltWallet)){
+ throw new YamiShopBindException("用户资金账户不存在!");
+ }
+ capitaltWalletService.update(new LambdaUpdateWrapper<CapitaltWallet>()
+ .set(CapitaltWallet::getMoney,new BigDecimal(Arith.sub(capitaltWallet.getMoney().doubleValue(), amount_before)))
+ .eq(CapitaltWallet::getUserId,capitaltWallet.getUserId()));
+
save(withdraw);
/*
@@ -691,7 +690,7 @@
moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN);
moneyLog.setAmountBefore(new BigDecimal(amount_before));
moneyLog.setAmount(new BigDecimal(Arith.sub(0, withdraw.getVolume().doubleValue())));
- moneyLog.setAmountAfter(wallet.getMoney());
+ moneyLog.setAmountAfter(capitaltWallet.getMoney());
moneyLog.setLog("提现订单[" + withdraw.getOrderNo() + "]");
// moneyLog.setExtra(withdraw.getOrder_no());
moneyLog.setUserId(withdraw.getUserId());
--
Gitblit v1.9.3