新版仿ok交易所-后端
1
zj
2025-10-14 7ff2bf07924915fc12612c9fd8cae5915dca2560
trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiWithdrawController.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yami.trading.bean.model.CapitaltWallet;
import com.yami.trading.bean.model.Wallet;
import com.yami.trading.bean.model.Withdraw;
import com.yami.trading.common.constants.Constants;
import com.yami.trading.common.domain.Result;
@@ -12,6 +13,7 @@
import com.yami.trading.security.common.util.SecurityUtils;
import com.yami.trading.service.CapitaltWalletService;
import com.yami.trading.service.SessionTokenService;
import com.yami.trading.service.WalletService;
import com.yami.trading.service.WithdrawService;
import com.yami.trading.service.syspara.SysparaService;
import com.yami.trading.service.user.UserService;
@@ -49,7 +51,8 @@
    protected WalletLogService walletLogService;
    @Autowired
    CapitaltWalletService capitaltWalletService;
    @Autowired
    WalletService walletService;
    /**
     * 首次进入页面,传递session_token
     */
@@ -90,25 +93,29 @@
            throw new YamiShopBindException("系统参数错误");
        }
        if ("true".equals(exchange_withdraw_need_safeword)) {
            if (StringUtils.isEmptyString(safeword)) {
                throw new YamiShopBindException("资金密码不能为空");
            }
            if (safeword.length() < 6 || safeword.length() > 12) {
                throw new YamiShopBindException("资金密码必须6-12位");
            }
            if (!userService.checkLoginSafeword(SecurityUtils.getUser().getUserId(),safeword)){
                throw new YamiShopBindException("资金密码错误");
            }
        }
//        if ("true".equals(exchange_withdraw_need_safeword)) {
//
//            if (StringUtils.isEmptyString(safeword)) {
//                throw new YamiShopBindException("资金密码不能为空");
//            }
//
//            if (safeword.length() < 6 || safeword.length() > 12) {
//                throw new YamiShopBindException("资金密码必须6-12位");
//            }
//            if (!userService.checkLoginSafeword(SecurityUtils.getUser().getUserId(),safeword)){
//                throw new YamiShopBindException("资金密码错误");
//            }
//        }
        // 获取资金账户(capital)
        CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class)
                .eq(CapitaltWallet::getUserId, partyId).last(" limit 1 "));
        if(capitaltWallet.getMoney().compareTo(new BigDecimal(amount)) < 0){
            throw new YamiShopBindException("可提现余额不足!");
        if(channel.contains("USDT")){
            Wallet capitaltWallet = walletService.getOne(new LambdaQueryWrapper<>(Wallet.class)
                    .eq(Wallet::getUserId, partyId).last(" limit 1 "));
//            CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class)
//                    .eq(CapitaltWallet::getUserId, partyId).last(" limit 1 "));
            if(capitaltWallet.getMoney().compareTo(new BigDecimal(amount)) < 0){
                throw new YamiShopBindException("Insufficient available balance for withdrawal!");
            }
        }
        this.sessionTokenService.del(session_token);