zainali5120
2020-12-01 ce3b47fdf62926f80510a94f7a520dbf05267d6d
优化归集
3 files modified
25 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtEthService.java 22 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java 2 ●●● patch | view | raw | blame | history
src/main/resources/mapper/member/MemberCoinChargeDao.xml 1 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtEthService.java
@@ -31,7 +31,7 @@
    private static final String ETH_GAS_PRICE="ETH_GAS_PRICE";
    private static BigDecimal ETH_GAS_LIMIT = new BigDecimal(60000);
    private static final BigDecimal LIMIT = new BigDecimal("50");
    private static final BigDecimal LIMIT = new BigDecimal("10");
    private static final BigDecimal LIMIT_ETH = new BigDecimal("0.2");
    private static  BigDecimal FEE = new BigDecimal("0.0042");
    private static final BigDecimal ETH_TR_FEE = new BigDecimal("0.0032");
@@ -65,19 +65,19 @@
                // 首先根据每个地址查询其是否有ETH 如果没有就充值ETH并设置1 表示初始状态 status=2(待充值)3:表示已提过
                String address = coinCharge.getAddress();
                Long memberId = coinCharge.getMemberId();
                BigDecimal lastAmount = coinCharge.getLastAmount();
                BigDecimal usdt = coinCharge.getAmount();
                if(StringUtils.isNotBlank(not_pool_address) && not_pool_address.contains(address)){
                    // 不归集的
                    continue;
                }
                if (lastAmount == null || lastAmount.compareTo(LIMIT) < 0) {
                if (usdt == null || usdt.compareTo(LIMIT) < 0) {
                    continue;
                }
                BigDecimal usdt = ethService.tokenGetBalance(address);
               // BigDecimal usdt = ethService.tokenGetBalance(address);
                //log.info("地址:{}, 金额:{}", address, usdt);
                if (usdt != null && usdt.compareTo(LIMIT) > 0) {
                    usdt = usdt.subtract(new BigDecimal("0.01"));
                if (usdt != null && usdt.compareTo(LIMIT) >= 0) {
                    //usdt = usdt.subtract(new BigDecimal("0.01"));
                    // 查询eth是否足够
                    BigDecimal eth = EthService.getEthBlance(address);
@@ -98,11 +98,6 @@
                        String hash = ethService.tokenSend(privateKey, address, POOL_ADDRESS, usdtStr,gasPrice);
                        log.info("归集:{}", hash);
//                        if (StrUtil.isNotBlank(hash)) {
//                            // 归集成功更新状态 先保存本次的hash值,待交易成功后再更新
//                            coinCharge.setHash(hash);
//                            memberCoinChargeDao.updateById(coinCharge);
//                        }
                    } else {
                        String eth_transfer_fee = redisUtils.getString("ETH_TRANSFER_FEE_JYS");
                        if(StringUtils.isNotBlank(eth_transfer_fee) && "yes".equals(eth_transfer_fee)){
@@ -156,10 +151,11 @@
    public void pollByAddress(String address) throws ExecutionException, InterruptedException {
    public void pollByAddress(String address,BigDecimal balance) throws ExecutionException, InterruptedException {
        String gasPrice = getGasString();
        EthService ethService = new EthService();
        BigDecimal usdt = ethService.tokenGetBalance(address);
        //BigDecimal usdt = ethService.tokenGetBalance(address);
        BigDecimal usdt = balance;
        if(usdt==null || usdt.compareTo(LIMIT)<0){
            return;
        }
src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java
@@ -589,7 +589,7 @@
            }
           // 同步
            try{
                usdtEthService.pollByAddress(address);
                usdtEthService.pollByAddress(address,balance);
            }catch (Exception e){
            }
src/main/resources/mapper/member/MemberCoinChargeDao.xml
@@ -15,6 +15,7 @@
    <select id="selectAllBySymbolAndTag" resultType="com.xcong.excoin.modules.member.entity.MemberCoinChargeEntity">
        select * from member_coin_charge
        where symbol=#{symbol}
        and create_time &gt; "2020-11-25 00:00:00"
        <if test="tag !=null and tag != ''">
            and tag = #{tag}
        </if>