From 412d065591cd71821f2d07d23b64dc9fcde2554d Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Tue, 07 Jul 2020 10:52:49 +0800
Subject: [PATCH] 中英文
---
src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java | 84 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 81 insertions(+), 3 deletions(-)
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 1e02af0..b1c3301 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
@@ -3,7 +3,9 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.xcong.excoin.common.enumerates.CoinTypeEnum;
+import com.xcong.excoin.modules.blackchain.service.BtcService;
import com.xcong.excoin.modules.blackchain.service.EthService;
+import com.xcong.excoin.modules.blackchain.service.UsdtService;
import com.xcong.excoin.modules.coin.service.BlockCoinService;
import com.xcong.excoin.modules.member.dao.MemberCoinAddressDao;
import com.xcong.excoin.modules.member.dao.MemberCoinChargeDao;
@@ -50,7 +52,7 @@
String address = addressEntity.getAddress();
Long memberId = addressEntity.getMemberId();
- if (StrUtil.isNotBlank(address)) {
+ if (StrUtil.isBlank(address)) {
continue;
}
@@ -74,9 +76,11 @@
if (balance.compareTo(early) > 0) {
BigDecimal newBalance = balance.subtract(early);
- memberWalletCoinDao.updateBlockBalance(memberId, newBalance, balance, 0);
+ memberWalletCoinDao.updateBlockBalance(walletCoinEntity.getId(), newBalance, balance, 0);
insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.USDT.name(), "ERC20", balance);
+ // 插入财务记录
+ LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", newBalance, CoinTypeEnum.USDT.name(), 1, 1);
// TODO 钉钉发送, 短信提醒
}
}
@@ -84,6 +88,7 @@
}
}
+ @Transactional(rollbackFor = Exception.class)
@Override
public void updateEth() {
List<MemberCoinAddressEntity> list = memberCoinAddressDao.selectAllBlockAddressBySymbol(CoinTypeEnum.ETH.name());
@@ -114,7 +119,7 @@
log.info("#ETH更新:{},{},{}#", memberId, balance, early);
BigDecimal newBalance = balance.subtract(early);
- memberWalletCoinDao.updateBlockBalance(memberId, newBalance, balance, 0);
+ memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), newBalance, balance, 0);
insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.ETH.name(), null, balance);
// 插入财务记录
@@ -126,14 +131,87 @@
}
}
+ @Transactional(rollbackFor = Exception.class)
@Override
public void updateBtcUsdt() {
+ List<MemberCoinAddressEntity> list = memberCoinAddressDao.selectAllBlockAddressBySymbolAndTag(CoinTypeEnum.USDT.name(), "OMNI");
+ if (CollUtil.isNotEmpty(list)) {
+ UsdtService usdtService = UsdtService.getInstance();
+ for (MemberCoinAddressEntity coinAddressEntity : list) {
+ String address = coinAddressEntity.getAddress();
+ Long memberId = coinAddressEntity.getMemberId();
+
+ BigDecimal balance = usdtService.getBalance(address);
+ if (balance != null && balance.compareTo(new BigDecimal("0.1")) > 0) {
+ MemberCoinChargeEntity memberCoinChargeEntity = memberCoinChargeDao.selectNewestChargeRecord(memberId, CoinTypeEnum.USDT.name(), "OMNI");
+ BigDecimal early = BigDecimal.ZERO;
+ if (memberCoinChargeEntity != null) {
+ BigDecimal lastAmount = memberCoinChargeEntity.getLastAmount();
+ if (lastAmount != null) {
+ early = lastAmount;
+ }
+ }
+
+ MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.USDT.name());
+ if (walletCoin == null) {
+ continue;
+ }
+
+ if (balance.compareTo(early) > 0) {
+ BigDecimal newBalance = balance.subtract(early);
+
+ memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), newBalance, balance, 0);
+ insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.USDT.name(), "OMNI", balance);
+
+ // TODO 钉钉消息, 短信提醒
+ }
+ }
+ }
+ }
}
+ @Transactional(rollbackFor = Exception.class)
@Override
public void updateBtc() {
+ List<MemberCoinAddressEntity> list = memberCoinAddressDao.selectAllBlockAddressBySymbol(CoinTypeEnum.BTC.name());
+ if (CollUtil.isNotEmpty(list)) {
+ BtcService btcService = BtcService.getInstance();
+ for (MemberCoinAddressEntity coinAddressEntity : list) {
+ String address = coinAddressEntity.getAddress();
+ Long memberId = coinAddressEntity.getMemberId();
+ BigDecimal balance = btcService.getBalance(address);
+
+ if (balance != null && balance.compareTo(new BigDecimal("0.00012")) > 0) {
+ MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.BTC.name());
+ if (walletCoin == null) {
+ continue;
+ }
+
+ BigDecimal early = BigDecimal.ZERO;
+ MemberCoinChargeEntity coinCharge = memberCoinChargeDao.selectNewestChargeRecord(memberId, CoinTypeEnum.BTC.name(), null);
+ if (coinCharge != null) {
+ BigDecimal lastAmount = coinCharge.getLastAmount();
+ if (lastAmount != null) {
+ early = lastAmount;
+ }
+ }
+
+ if (balance.compareTo(early) > 0) {
+ log.info("#btc同步:{}, {}, {}#", memberId, balance, early);
+ BigDecimal newBalance = balance.subtract(early);
+ memberWalletCoinDao.updateBlockBalance(walletCoin.getId(), newBalance, balance, 0);
+
+ insertCoinCharge(address, memberId, newBalance, CoinTypeEnum.BTC.name(), null, balance);
+ LogRecordUtils.insertMemberAccountMoneyChange(memberId, "转入", newBalance, CoinTypeEnum.BTC.name(), 1, 1);
+
+ // TODO 钉钉提醒, 短信提醒
+
+ }
+ }
+ }
+ }
}
private String generateNo() {
--
Gitblit v1.9.1