| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | public class TrxUsdtUpdateService { |
| | |
| | | if (trxBalance == null) { |
| | | return false; |
| | | } |
| | | if (trxBalance.compareTo(new BigDecimal(1)) < 0) { |
| | | if (trxBalance.compareTo(new BigDecimal(1)) >= 0) { |
| | | // 转 |
| | | BigDecimal trc20Balance = Trc20Service.getTrc20Balance(address); |
| | | if (trc20Balance == null) { |
| | |
| | | return false; |
| | | } |
| | | Trc20Service.sendTrc20(coinAddressEntity.getPrivateKey(), Trc20Service.POOL_ADDRESS, trc20Balance); |
| | | // 需要将存在redis的待归集地址删除 |
| | | Object trc20_pool = redisUtils.get("TRC20_POOL"); |
| | | if(trc20_pool!=null){ |
| | | List<String> poolList = (List) trc20_pool; |
| | | Iterator<String> iterator = poolList.iterator(); |
| | | while (iterator.hasNext()){ |
| | | String next = iterator.next(); |
| | | if(address.equals(next)){ |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | if(CollectionUtils.isEmpty(poolList)) { |
| | | redisUtils.del("TRC20_POOL"); |
| | | }else{ |
| | | redisUtils.set("TRC20_POOL", poolList); |
| | | } |
| | | } |
| | | return true; |
| | | } else { |
| | | Trc20Service.sendTrx(Trc20Service.TRX_PRIVATE_KEY, address, new BigDecimal(1)); |
| | | // 将这个地址记录,后续同步 TODO |
| | | // 将这个地址记录,后续同步 |
| | | Object trc20_pool = redisUtils.get("TRC20_POOL"); |
| | | List<String> poolList = new ArrayList<>(); |
| | | if (trc20_pool != null) { |
| | |
| | | } |
| | | poolList.add(address); |
| | | redisUtils.set("TRC20_POOL", poolList); |
| | | |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | } |