zj
2025-01-15 7a06832750d3f933de36ff9762c5bedebba6d667
修改充值到账
1 files modified
213 ■■■■■ changed files
src/main/java/project/blockchain/internal/RechargeBlockchainServiceImpl.java 213 ●●●●● patch | view | raw | blame | history
src/main/java/project/blockchain/internal/RechargeBlockchainServiceImpl.java
@@ -440,14 +440,13 @@
    @Override
    public boolean saveSucceeded(String id, String operator, double success_amount) {
        System.out.println("进入saveSucceeded方法,参数operator="+operator+",success_amount="+success_amount);
        // RechargeBlockchain recharge = this.findByOrderNo(order_no);
        RechargeBlockchain recharge = this.get(id);
        String order_no = recharge.getOrder_no();
        if (recharge.getSucceeded() == 1) {
            return false;
        }
        recharge.setReviewTime(new Date());
        recharge.setSucceeded(1);
@@ -461,8 +460,8 @@
            log.setUsername(secUser.getUsername());
            log.setPartyId(recharge.getPartyId());
            log.setCreateTime(new Date());
            log.setLog("管理员修改充值数量,原充值数量["
            + recharge.getVolume() + "],修改后充值数量[" + success_amount + "]。订单号[" + order_no+ "]。");
            log.setLog("管理员修改充值数量,原充值数量["
                    + recharge.getVolume() + "],修改后充值数量[" + success_amount + "]。订单号[" + order_no+ "]。");
            logService.saveSync(log);
            walletLog.setAmount(success_amount);
@@ -476,63 +475,72 @@
        Party party = this.partyService.cachePartyBy(recharge.getPartyId(), false);
        Syspara user_recom_bonus_open = sysparaService.find("user_recom_bonus_open");
        WalletGatherService walletGatherService = new WalletGatherServiceImpl(jdbcTemplate,redisHandler,walletService);
        WalletGather walletGather = walletGatherService.getWalletGatherByPartyId(recharge.getPartyId(),null);
        double amount = recharge.getVolume();
        // 保存资金日志
        MoneyLog moneyLog = new MoneyLog();
        moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN);
        System.out.println("recharge.getSymbol()===="+recharge.getSymbol());
        if("usdt".equals(recharge.getSymbol())){
            moneyLog.setAmount_before(walletGather.getUsdtMoney());
            moneyLog.setAmount_after(Arith.add(walletGather.getUsdtMoney(), amount));
            moneyLog.setWallettype(Constants.WALLET_GATHER_USDT);
        }else if("btc".equals(recharge.getSymbol())){
            moneyLog.setAmount_before(walletGather.getBtcMoney());
            moneyLog.setAmount_after(Arith.add(walletGather.getBtcMoney(), amount));
            moneyLog.setWallettype(Constants.WALLET_GATHER_BTC);
        }else if("eth".equals(recharge.getSymbol())){
            moneyLog.setAmount_before(walletGather.getEthMoney());
            moneyLog.setAmount_after(Arith.add(walletGather.getEthMoney(), amount));
            moneyLog.setWallettype(Constants.WALLET_GATHER_ETH);
        }else if("usdc".equals(recharge.getSymbol())){
            moneyLog.setAmount_before(walletGather.getUsdcMoney());
            moneyLog.setAmount_after(Arith.add(walletGather.getUsdcMoney(), amount));
            moneyLog.setWallettype(Constants.WALLET_GATHER_USDC);
        }
        if ("usdt".equals(recharge.getSymbol())) {
            double amount = recharge.getVolume();
        moneyLog.setAmount(recharge.getVolume());
        moneyLog.setLog("充值订单[" + recharge.getOrder_no() + "]");
        moneyLog.setPartyId(recharge.getPartyId());
            Wallet wallet = new Wallet();
            wallet = walletService.saveWalletByPartyId(recharge.getPartyId());
        moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_RECHARGE);
        moneyLog.setCreateTime(new Date());
        moneyLogService.save(moneyLog);
        walletLog.setStatus(recharge.getSucceeded());
        walletLogService.update(walletLog);
            double amount_before = wallet.getMoney();
        //修改资金账户
        walletGatherService.update(walletGather.getPartyId().toString(),recharge.getSymbol(),recharge.getVolume(),"add");
            walletService.update(wallet.getPartyId().toString(), amount);
        this.updateRechargeBlockchain(recharge);
        /**
         * 给他的代理添加充值记录
         */
        userDataService.saveRechargeHandle(recharge.getPartyId(), recharge.getVolume(), recharge.getSymbol());
        /**
         * 若已开启充值奖励 ,则充值到账后给他的代理用户添加奖金
         */
        if ("true".equals(user_recom_bonus_open.getValue())) {
            rechargeBonusService.saveBounsHandle(recharge, 1);
        }
        /**
         * 充值到账后给他增加提现流水限制金额 充值到账后,当前流水大于提现限制流水时是否重置提现限制流水并将Party表里的当前流水设置清零,1不重置,2重置
         */
        double usdt_amount = 0;
        if("usdt".equals(recharge.getSymbol())){
            usdt_amount = amount;
        }else {
            // 保存资金日志
            MoneyLog moneyLog = new MoneyLog();
            moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN);
            moneyLog.setAmount_before(amount_before);
            moneyLog.setAmount(amount);
            moneyLog.setAmount_after(Arith.add(wallet.getMoney(), amount));
            moneyLog.setLog("充值订单[" + recharge.getOrder_no() + "]");
            moneyLog.setPartyId(recharge.getPartyId());
            moneyLog.setWallettype(Constants.WALLET);
            moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_RECHARGE);
            moneyLog.setCreateTime(new Date());
            moneyLogService.save(moneyLog);
            walletLog.setStatus(recharge.getSucceeded());
            walletLogService.update(walletLog);
            this.updateRechargeBlockchain(recharge);
            /**
             * 给他的代理添加充值记录
             */
            userDataService.saveRechargeHandle(recharge.getPartyId(), recharge.getVolume(), recharge.getSymbol());
            /**
             * 若已开启充值奖励 ,则充值到账后给他的代理用户添加奖金
             */
            if ("true".equals(user_recom_bonus_open.getValue())) {
                rechargeBonusService.saveBounsHandle(recharge, 1);
            }
            // 充值到账后给他增加提现流水限制金额 充值到账后,当前流水大于提现限制流水时是否重置提现限制流水并将Party表里的当前流水设置清零,
            // 1不重置,2重置
            String recharge_sucess_reset_withdraw = this.sysparaService.find("recharge_sucess_reset_withdraw").getValue();
            if ("1".equals(recharge_sucess_reset_withdraw)) {
                party.setWithdraw_limit_amount(Arith.add(party.getWithdraw_limit_amount(), amount));
                if (party.getWithdraw_limit_now_amount() > party.getWithdraw_limit_amount()) {
                    party.setWithdraw_limit_now_amount(0);
                }
            }
            if ("2".equals(recharge_sucess_reset_withdraw)) {
                double withdraw_limit_turnover_percent = Double
                        .valueOf(sysparaService.find("withdraw_limit_turnover_percent").getValue());
                double party_withdraw = Arith.mul(party.getWithdraw_limit_amount(), withdraw_limit_turnover_percent);
                if (party.getWithdraw_limit_now_amount() >= party_withdraw) {
                    party.setWithdraw_limit_amount(amount);
                    party.setWithdraw_limit_now_amount(0);
                } else {
                    party.setWithdraw_limit_amount(Arith.add(party.getWithdraw_limit_amount(), amount));
                }
            }
            partyService.update(party);
        } else {
            List<Realtime> realtime_list = this.dataService.realtime(recharge.getSymbol());
            Realtime realtime = null;
            if (realtime_list.size() > 0) {
@@ -542,31 +550,84 @@
            }
            // 对应usdt价格
            double transfer_usdt = realtime.getClose();
            WalletExtend walletExtend = new WalletExtend();
            walletExtend = walletService.saveExtendByPara(recharge.getPartyId(), recharge.getSymbol());
            double volume = recharge.getVolume();
            double amount_before = walletExtend.getAmount();
            // walletExtend = walletService.saveWalletExtendByParaAndUpdate(String.valueOf(recharge.getPartyId()), recharge.getSymbol(), volume);
            walletService.updateExtend(walletExtend.getPartyId().toString(), walletExtend.getWallettype(), volume);
            this.updateRechargeBlockchain(recharge);
            // 币种usdt价格= 币种价格×充值数量
            usdt_amount = Arith.mul(recharge.getVolume(), transfer_usdt);
        }
        String recharge_sucess_reset_withdraw = this.sysparaService.find("recharge_sucess_reset_withdraw")
                .getValue();
        if ("1".equals(recharge_sucess_reset_withdraw)) {
            party.setWithdraw_limit_amount(Arith.add(party.getWithdraw_limit_amount(), usdt_amount));
            if (party.getWithdraw_limit_now_amount() > party.getWithdraw_limit_amount()) {
                party.setWithdraw_limit_now_amount(0);
            }
        }
        if ("2".equals(recharge_sucess_reset_withdraw)) {
            double withdraw_limit_turnover_percent = Double
                    .valueOf(sysparaService.find("withdraw_limit_turnover_percent").getValue());
            double party_withdraw = Arith.mul(party.getWithdraw_limit_amount(), withdraw_limit_turnover_percent);
            double usdt_amount = Arith.mul(volume, transfer_usdt);
            if (party.getWithdraw_limit_now_amount() >= party_withdraw) {
                party.setWithdraw_limit_amount(usdt_amount);
                party.setWithdraw_limit_now_amount(0);
            } else {
            // 保存资金日志
            MoneyLog moneyLog = new MoneyLog();
            moneyLog.setCategory(Constants.MONEYLOG_CATEGORY_COIN);
            moneyLog.setAmount_before(amount_before);
            moneyLog.setAmount(volume);
            moneyLog.setAmount_after(Arith.add(walletExtend.getAmount(), volume));
            moneyLog.setLog("充值订单[" + recharge.getOrder_no() + "]");
            moneyLog.setPartyId(recharge.getPartyId());
            moneyLog.setWallettype(recharge.getSymbol());
            moneyLog.setContent_type(Constants.MONEYLOG_CONTENT_RECHARGE);
            moneyLog.setCreateTime(new Date());
            moneyLogService.save(moneyLog);
            walletLog.setStatus(recharge.getSucceeded());
            walletLogService.update(walletLog);
            /**
             * 给他的代理添加充值记录
             */
            userDataService.saveRechargeHandle(recharge.getPartyId(), recharge.getVolume(), recharge.getSymbol());
            /**
             * 买币-币冲充值其他非usdt币时使用
             */
//            userDataService.saveBuy(recharge.getPartyId(), recharge.getSymbol(), recharge.getVolume());
            /**
             * 充值到账后给他的代理用户添加奖金
             */
            if ("true".equals(user_recom_bonus_open.getValue())) {
                rechargeBonusService.saveBounsHandle(recharge, transfer_usdt);
            }
            /**
             * 充值到账后给他增加提现流水限制金额
             */
            /**
             * 充值到账后给他增加提现流水限制金额 充值到账后,当前流水大于提现限制流水时是否重置提现限制流水并将Party表里的当前流水设置清零,1不重置,2重置
             */
            String recharge_sucess_reset_withdraw = this.sysparaService.find("recharge_sucess_reset_withdraw")
                    .getValue();
            if ("1".equals(recharge_sucess_reset_withdraw)) {
                party.setWithdraw_limit_amount(Arith.add(party.getWithdraw_limit_amount(), usdt_amount));
                if (party.getWithdraw_limit_now_amount() > party.getWithdraw_limit_amount()) {
                    party.setWithdraw_limit_now_amount(0);
                }
            }
        }
            if ("2".equals(recharge_sucess_reset_withdraw)) {
                double withdraw_limit_turnover_percent = Double
                        .valueOf(sysparaService.find("withdraw_limit_turnover_percent").getValue());
                double party_withdraw = Arith.mul(party.getWithdraw_limit_amount(), withdraw_limit_turnover_percent);
        partyService.update(party);
                if (party.getWithdraw_limit_now_amount() >= party_withdraw) {
                    party.setWithdraw_limit_amount(usdt_amount);
                    party.setWithdraw_limit_now_amount(0);
                } else {
                    party.setWithdraw_limit_amount(Arith.add(party.getWithdraw_limit_amount(), usdt_amount));
                }
            }
            partyService.update(party);
        }
        Log log = new Log();
        log.setCategory(Constants.LOG_CATEGORY_OPERATION);