1
zj
2025-01-17 42ba802e77dea3e36fb24468919bdca111468a5c
1
6 files modified
119 ■■■■ changed files
src/main/java/project/web/admin/AdminWithdrawController.java 3 ●●●● patch | view | raw | blame | history
src/main/java/project/web/api/WithdrawController.java 3 ●●●● patch | view | raw | blame | history
src/main/java/project/withdraw/AdminWithdrawService.java 2 ●●● patch | view | raw | blame | history
src/main/java/project/withdraw/WithdrawService.java 3 ●●●● patch | view | raw | blame | history
src/main/java/project/withdraw/internal/AdminWithdrawServiceImpl.java 46 ●●●●● patch | view | raw | blame | history
src/main/java/project/withdraw/internal/WithdrawServiceImpl.java 62 ●●●● patch | view | raw | blame | history
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());
src/main/java/project/web/api/WithdrawController.java
@@ -185,8 +185,7 @@
            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);
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);
    /**
     * 通过
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 订单号
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,24 +67,17 @@
            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();
        }
        //修改资金账户
        walletGatherService.update(walletGather.getPartyId().toString(),symbol,withdraw.getAmount(),"add");
            Wallet wallet = walletService.saveWalletByPartyId(withdraw.getPartyId());
            double amount_before = wallet.getMoney();
            walletService.update(wallet.getPartyId().toString(),
                    Arith.add(withdraw.getAmount(), withdraw.getAmount_fee()));
        /*
         * 保存资金日志
         */
@@ -102,6 +95,28 @@
        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);
        }
        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);
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);