peternameyakj
2024-07-30 f23b33bbb9eaff76cac5b69e3b793fc7910fb0fa
src/main/java/project/withdraw/internal/AdminWithdrawServiceImpl.java
@@ -24,10 +24,7 @@
import project.party.recom.UserRecomService;
import project.tip.TipService;
import project.user.UserDataService;
import project.wallet.Wallet;
import project.wallet.WalletExtend;
import project.wallet.WalletLogService;
import project.wallet.WalletService;
import project.wallet.*;
import project.withdraw.AdminWithdrawService;
import project.withdraw.Withdraw;
import security.SecUser;
@@ -51,7 +48,7 @@
   private TipService tipService;
   
   @Override
   public void saveReject(String id, String failure_msg, String userName, String partyId) {
   public void saveReject(String id, String failure_msg, String userName, String partyId, WalletGatherService walletGatherService) {
      Withdraw withdraw = this.get(id);
      if (withdraw.getSucceeded() == 2 ) {// 通过后不可驳回
@@ -70,56 +67,41 @@
         symbol = "btc";
      } else if (withdraw.getMethod().indexOf("ETH") != -1) {
         symbol = "eth";
      }  else if (withdraw.getMethod().indexOf("USDC") != -1) {
         symbol = "eth";
      } else {
         symbol = "usdt";
      }
      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);
      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");
      /*
       * 保存资金日志
       */
      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());