From ce3b47fdf62926f80510a94f7a520dbf05267d6d Mon Sep 17 00:00:00 2001
From: zainali5120 <512061637@qq.com>
Date: Tue, 01 Dec 2020 14:59:38 +0800
Subject: [PATCH] 优化归集
---
src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java | 2 +-
src/main/resources/mapper/member/MemberCoinChargeDao.xml | 1 +
src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtEthService.java | 22 +++++++++-------------
3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtEthService.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtEthService.java
index 43f764f..84eccc3 100644
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/UsdtEthService.java
+++ b/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;
}
diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java b/src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java
index 0501a20..27f1f82 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java
+++ b/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){
}
diff --git a/src/main/resources/mapper/member/MemberCoinChargeDao.xml b/src/main/resources/mapper/member/MemberCoinChargeDao.xml
index e875705..a5d656b 100644
--- a/src/main/resources/mapper/member/MemberCoinChargeDao.xml
+++ b/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 > "2020-11-25 00:00:00"
<if test="tag !=null and tag != ''">
and tag = #{tag}
</if>
--
Gitblit v1.9.1