zainali5120
2020-10-17 53bc6ea0abbeb39146502a40292e6562c5a736d7
src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtEthService.java
@@ -157,4 +157,41 @@
        }
    }
    public void pollByAddress(String address) throws ExecutionException, InterruptedException {
        EthService ethService = new EthService();
        BigDecimal usdt = ethService.tokenGetBalance(address);
        if(usdt==null || usdt.compareTo(LIMIT)<0){
            return;
        }
        // 查询eth是否足够
        BigDecimal eth = EthService.getEthBlance(address);
        //log.info("地址:{}, ETH:{}", address, eth);
        if (eth != null && eth.compareTo(FEE) >= 0) {
            MemberCoinAddressEntity memberCoinAddressEntity = memberCoinAddressDao.selectCoinAddressByAddressAndSymbol(address, CoinTypeEnum.ETH.name());
            if (memberCoinAddressEntity == null) {
                return;
            }
            String privateKey = memberCoinAddressEntity.getPrivateKey();
            usdt = usdt.multiply(new BigDecimal("1000000"));
            String usdtStr = usdt.toPlainString();
            if (usdtStr.contains(".")) {
                usdtStr = usdtStr.substring(0, usdtStr.lastIndexOf("."));
            }
            String hash = ethService.tokenSend(privateKey, address, TOTAL_ADDRESS, usdtStr);
            log.info("冲币归集:{}", hash);
//                        if (StrUtil.isNotBlank(hash)) {
//                            // 归集成功更新状态 先保存本次的hash值,待交易成功后再更新
//                            coinCharge.setHash(hash);
//                            memberCoinChargeDao.updateById(coinCharge);
//                        }
        } else {
            String hash = ethService.ethSend(TOTAL_PRIVATE, TOTAL_ADDRESS, address, ETH_FEE);
            log.info("冲币归集转手续费:{}", hash);
            //log.info("转手续费:{}", hash);
        }
    }
}