From 292a4634d9c52ce193eca9de356d65960bdc35f4 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 15 Jan 2021 18:20:37 +0800
Subject: [PATCH] 20210115

---
 src/main/java/com/xcong/excoin/modules/blackchain/service/Impl/BlockSeriveImpl.java |   43 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/blackchain/service/Impl/BlockSeriveImpl.java b/src/main/java/com/xcong/excoin/modules/blackchain/service/Impl/BlockSeriveImpl.java
index 33c2c20..47010f0 100644
--- a/src/main/java/com/xcong/excoin/modules/blackchain/service/Impl/BlockSeriveImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/blackchain/service/Impl/BlockSeriveImpl.java
@@ -6,6 +6,10 @@
 import javax.annotation.Resource;
 
 import com.xcong.excoin.modules.blackchain.service.*;
+import com.xcong.excoin.modules.coin.dao.TrcAddressDao;
+import com.xcong.excoin.modules.coin.entity.TrcAddressEntity;
+import com.xcong.excoin.rabbit.producer.UsdtUpdateProducer;
+import com.xcong.excoin.utils.TRC20ApiUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
@@ -29,6 +33,11 @@
     MemberDao memberDao;
     @Resource
     MemberCoinAddressDao memberMapper;
+    @Resource
+    private TrcAddressDao trcAddressDao;
+
+    @Resource
+    private UsdtUpdateProducer usdtUpdateProducer;
 
     @Override
     public Result findBlockAddress(String symbol) {
@@ -46,6 +55,33 @@
 
             if ("USDT".equals(symbol)) {
                 memberCoinAddress = memberMapper.selectBlockAddressWithTag(Long.parseLong(mId), symbol, lable);
+
+                TrcAddressEntity srcAddressEntity = trcAddressDao.selectSrcAddressByMemberId(member.getId());
+                if (srcAddressEntity != null) {
+                    map.put("trc20_address", srcAddressEntity.getAddress());
+                    map.put("trc20_label", "TRC20");
+                } else {
+                    // 分布式redis锁
+                    for (;;) {
+                        boolean flag = redisUtil.setNotExist("LOCK_TRC20", 1, 5);
+                        log.info("是否存在:{}", flag);
+                        if (!flag) {
+                            continue;
+                        }
+
+                        TrcAddressEntity address = trcAddressDao.selectOneSrcAddressUnUse();
+                        address.setMemberId(member.getId());
+                        address.setIsUse(1);
+                        address.setSystemFlag(1);
+
+                        TRC20ApiUtils.createWallet(member.getId(), member.getInviteId(), "USDT", address.getAddress());
+                        trcAddressDao.updateById(address);
+
+                        map.put("trc20_address", address.getAddress());
+                        map.put("trc20_label", "TRC20");
+                        break;
+                    }
+                }
             } else {
                 memberCoinAddress = memberMapper.selectBlockAddress(Long.parseLong(mId), symbol);
             }
@@ -178,12 +214,11 @@
                                 coinAddress.setLabel(uuid);
                                 memberMapper.insert(coinAddress);
                             }
-                            if(!UsdtErc20UpdateService.ALL_ADDRESS_LIST.contains(address)){
-                                UsdtErc20UpdateService.ALL_ADDRESS_LIST.add(address);
-                            }
+                           // 发送新增的地址到监听集合
+                            usdtUpdateProducer.sendAddressMsg(address);
                         }
                         break;
-                    case "ROC":
+                    case "RFNC":
                         address = RocService.createWallet();
                         map.put("address", address);
                         break;

--
Gitblit v1.9.1