Helius
2020-11-19 ac5051ef7aa0ea4410d32760a200e2dc31ef870e
src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java
@@ -78,6 +78,8 @@
   private final RedisUtils redisUtils;
   
   private final TrcAddressDao trcAddressDao;
   @Override
   public IPage<AgentFriendRelationEntity> findAgentInfoListInPage(AgentFriendRelationEntity agentFriendRelationEntity,
         QueryRequest request) {
@@ -488,6 +490,9 @@
      if ("Y".equals(selectById.getIsInside())) {
         // 查询算力系统中是否存在该地址
         TdCoinWallet tdCoinWallet = memberWalletCoinMapper.selectTdCoinWalletByAddress(address, "USDT");
         TrcAddressEntity trcAddressEntity = trcAddressDao.selectTrcAddressByAddress(address);
         // 判断是否为TRC20地址
         if (trcAddressEntity == null) {
         if (tdCoinWallet != null) {
            // 更新算力系统中用户钱包余额
            memberWalletCoinMapper.updateTdCoinWalletAvaliable(amount, address);
@@ -533,6 +538,44 @@
            memberAccountMoneyChangeEntity.setUpdateTime(new Date());
            memberAccountMoneyChangeMapper.insert(memberAccountMoneyChangeEntity);
         }
         } else {
            if (trcAddressEntity.getSystemFlag().equals(TrcAddressEntity.SYSTEM_FLAG_SL)) {
               memberWalletCoinMapper.updateTdCoinWalletTrc20(amount, trcAddressEntity.getMemberId());
               TdFinancialReord tdFinancialReord = new TdFinancialReord();
               tdFinancialReord.setAmount(amount);
               tdFinancialReord.setCreateTime(new Date());
               tdFinancialReord.setMemId(trcAddressEntity.getMemberId());
               tdFinancialReord.setSymbol("USDT");
               tdFinancialReord.setTitle("USDT交易所转账");
               tdFinancialReord.setContent("USDT交易所转账");
               // 插入算力系统中财务记录
               tdFinancialReordDao.insert(tdFinancialReord);
            } else {
               Long aimMemberId = trcAddressEntity.getMemberId();
               MemberWalletCoinEntity aimWalletCoin = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(aimMemberId, symbol);
               BigDecimal addTotal = aimWalletCoin.getTotalBalance().add(amount);
               BigDecimal addAvailable = aimWalletCoin.getAvailableBalance().add(amount);
               aimWalletCoin.setTotalBalance(addTotal);
               aimWalletCoin.setAvailableBalance(addAvailable);
               memberWalletCoinMapper.updateById(aimWalletCoin);
               MemberAccountMoneyChangeEntity memberAccountMoneyChangeEntity = new MemberAccountMoneyChangeEntity();
               memberAccountMoneyChangeEntity.setContent("收款");
               memberAccountMoneyChangeEntity.setMemberId(aimMemberId);
               memberAccountMoneyChangeEntity.setAmount(amount);
               memberAccountMoneyChangeEntity.setStatus(MemberAccountMoneyChangeEntity.STATUS_SUCCESS_INTEGER);
               memberAccountMoneyChangeEntity.setSymbol(selectById.getSymbol());
               memberAccountMoneyChangeEntity.setType(MemberAccountMoneyChangeEntity.TYPE_WALLET_COIN);
               memberAccountMoneyChangeEntity.setCreateBy(selectById.getCreateBy());
               memberAccountMoneyChangeEntity.setCreateTime(new Date());
               memberAccountMoneyChangeEntity.setUpdateBy(selectById.getCreateBy());
               memberAccountMoneyChangeEntity.setUpdateTime(new Date());
               memberAccountMoneyChangeMapper.insert(memberAccountMoneyChangeEntity);
            }
         }
      }
      
      Map<String, Object> columnMaps = new HashMap<>();
@@ -547,18 +590,20 @@
      selectById.setStatus(MemberCoinWithdrawEntity.IS_STATUS_Y);
      memberCoinWithdrawMapper.updateById(selectById);
      if (!"Y".equals(selectById.getIsInside())) {
      if ("TRC20".equals(selectById.getLabel())) {
         Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
               log.info("远程调用TRC执行:{}", selectById.getId());
               String orderNo = generateOrderNo(memberId);
               TRC20ApiUtils.coinApply(orderNo, memberId.toString(), selectById.getSymbol(), selectById.getAmount().toPlainString(), selectById.getAddress());
                  TRC20ApiUtils.coinApply(orderNo, memberId.toString(), selectById.getSymbol(), selectById.getAmount().subtract(selectById.getFeeAmount()).toPlainString(), selectById.getAddress());
               selectById.setTag(orderNo);
               memberCoinWithdrawMapper.updateById(selectById);
            }
         });
         thread.start();
         }
      }
      MemberEntity memberEntity = memberMapper.selectById(memberId);
@@ -567,7 +612,6 @@
      SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        String time = format.format(new Date()); // 将当前时间袼式化为指定的格式
      log.info("---->{}", phone);
      if(StrUtil.isNotBlank(phone)) {
         Sms106Send.sendWithdrawalCoinMsg(phone, time);
      }