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 | 53 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 44 insertions(+), 9 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 94ee137..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 @@ -5,18 +5,17 @@ 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; import com.alibaba.fastjson.JSONObject; import com.xcong.excoin.common.LoginUserUtils; import com.xcong.excoin.common.response.Result; -import com.xcong.excoin.modules.blackchain.service.BlockSerive; -import com.xcong.excoin.modules.blackchain.service.BtcService; -import com.xcong.excoin.modules.blackchain.service.EthService; -import com.xcong.excoin.modules.blackchain.service.LtcService; -import com.xcong.excoin.modules.blackchain.service.UsdtService; -import com.xcong.excoin.modules.blackchain.service.XrpService; import com.xcong.excoin.modules.member.dao.MemberCoinAddressDao; import com.xcong.excoin.modules.member.dao.MemberDao; import com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity; @@ -34,6 +33,11 @@ MemberDao memberDao; @Resource MemberCoinAddressDao memberMapper; + @Resource + private TrcAddressDao trcAddressDao; + + @Resource + private UsdtUpdateProducer usdtUpdateProducer; @Override public Result findBlockAddress(String symbol) { @@ -51,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); } @@ -105,9 +136,7 @@ map.put("lable", uuid); break; case "XRP": - JSONObject jSONObject = XrpService.createWallet(); - address = (String) jSONObject.get("xAddress"); - key = (String) jSONObject.get("secret"); + address = "biyicteos123"; map.put("address", address); map.put("lable", uuid); break; @@ -185,8 +214,14 @@ coinAddress.setLabel(uuid); memberMapper.insert(coinAddress); } + // 发送新增的地址到监听集合 + usdtUpdateProducer.sendAddressMsg(address); } break; + case "RFNC": + address = RocService.createWallet(); + map.put("address", address); + break; default: break; } -- Gitblit v1.9.1