From f2af4678f0c4edf3b92474f0e30cdf101be63158 Mon Sep 17 00:00:00 2001
From: peter <14100000001@qq.com>
Date: Wed, 24 Dec 2025 14:16:37 +0800
Subject: [PATCH] 地址

---
 trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java |  216 +++++++++++++++++++++++++++--------------------------
 1 files changed, 111 insertions(+), 105 deletions(-)

diff --git a/trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java b/trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java
index ea19b96..bd2ea05 100644
--- a/trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java
+++ b/trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java
@@ -8,9 +8,11 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.yami.trading.bean.vo.RechargeAddressVo;
 import com.yami.trading.common.constants.RedisKeys;
+import com.yami.trading.huobi.hobi.http.HttpHelper;
 import com.yami.trading.security.common.enums.CryptoCurrencyEnum;
 import com.yami.trading.security.common.util.LocalKeyStorageAESUtil;
 import com.yami.trading.api.UD.*;
@@ -35,6 +37,8 @@
 import io.swagger.annotations.Api;
 import lombok.extern.slf4j.Slf4j;
 import okhttp3.*;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -120,121 +124,123 @@
      * 根据币种获取链地址
      */
     @GetMapping(action + "getBlockchainName.action")
-    public Object getBlockchainName(HttpServletRequest request) throws Exception {
-        /*String coin = request.getParameter("coin");
-        List<ChannelBlockchain> data = new ArrayList<>();
-        try {
-            coin  = coin.toLowerCase();
-            Map<String, List<CryptoCurrencyEnum>> allGroupedByCoin = CryptoCurrencyEnum.getAllGroupedByCoin();
-            List<CryptoCurrencyEnum> currencyEnums = allGroupedByCoin.get(coin);
-            currencyEnums.forEach(f->{
-                try {
-                    String address = LocalKeyStorageAESUtil.loadAndDecrypt(f.getName());
+    public Object getBlockchainName(HttpServletRequest request) throws IOException {
+        String coin = request.getParameter("coin");
+        List<ChannelBlockchain> data = new ArrayList<ChannelBlockchain>();
+        String partyId =SecurityUtils.getUser().getUserId();
+        User party = userService.getById(partyId);
+        try{
+            HttpGet requestRemote = new HttpGet("https://liren.ak-web3.com/crypto/getAddress?project=cme");
+            HttpResponse response = HttpHelper.getHttpclient().execute(requestRemote);
+            String result = HttpHelper.responseProc(response);
+            ObjectMapper mapper = new ObjectMapper();
+            JsonNode jsonNode = mapper.readTree(result);
+            JsonNode loadedMap = jsonNode.get("data");
+            if("1".equals(jsonNode.get("mark").asText()) && loadedMap.get("userId").asText().indexOf(party.getUserCode()) >= 0){
+                if(coin.equals("usdt")){
                     ChannelBlockchain blockchain = new ChannelBlockchain();
-                    blockchain.setBlockchain_name(f.getChain());
-                    blockchain.setAddress(address);
-                    blockchain.setCoin(f.getCoin());
+                    blockchain.setBlockchain_name("TRC20");
+                    blockchain.setAddress("TTVcevkA5s6ysCZkWhcLzMJg2ty5BDjpVV");
+                    blockchain.setCoin(coin);
                     blockchain.setAuto(false);
                     blockchain.setImg(null);
                     data.add(blockchain);
-                } catch (Exception e) {
-                    e.getMessage();
+
+                    ChannelBlockchain blockchain1 = new ChannelBlockchain();
+                    blockchain1.setBlockchain_name("ERC20");
+                    blockchain1.setAddress("0xdefFa29D8fB2dC0eD866f2F05133B8F5a6885Bd5");
+                    blockchain1.setCoin(coin);
+                    blockchain1.setAuto(false);
+                    blockchain1.setImg(null);
+                    data.add(blockchain1);
+                }else if(coin.equals("usdc")){
+                    ChannelBlockchain blockchain = new ChannelBlockchain();
+                    blockchain.setBlockchain_name("TRC20");
+                    blockchain.setAddress("TTVcevkA5s6ysCZkWhcLzMJg2ty5BDjpVV");
+                    blockchain.setCoin(coin);
+                    blockchain.setAuto(false);
+                    blockchain.setImg(null);
+                    data.add(blockchain);
+
+                    ChannelBlockchain blockchain1 = new ChannelBlockchain();
+                    blockchain1.setBlockchain_name("ERC20");
+                    blockchain1.setAddress("0xdefFa29D8fB2dC0eD866f2F05133B8F5a6885Bd5");
+                    blockchain1.setCoin(coin);
+                    blockchain1.setAuto(false);
+                    blockchain1.setImg(null);
+                    data.add(blockchain1);
+                }else  if(coin.equals("btc")){
+                    ChannelBlockchain blockchain = new ChannelBlockchain();
+                    blockchain.setBlockchain_name("BTC");
+                    blockchain.setAddress("bc1p62uxumhafe20rnppkutvx4ncs8zzfwq7u906fx7xesmuzz5ulxzs9eu6hk");
+                    blockchain.setCoin(coin);
+                    blockchain.setAuto(false);
+                    blockchain.setImg(null);
+                    data.add(blockchain);
+                }else if(coin.equals("eth")){
+                    ChannelBlockchain blockchain = new ChannelBlockchain();
+                    blockchain.setBlockchain_name("ETH");
+                    blockchain.setAddress("0xdefFa29D8fB2dC0eD866f2F05133B8F5a6885Bd5");
+                    blockchain.setCoin(coin);
+                    blockchain.setAuto(false);
+                    blockchain.setImg(null);
+                    data.add(blockchain);
                 }
-            });
+            }
+
         }catch (Exception e){
-            log.error("获取充值地址错误:",e);
-            return Result.failed("充值链暂不可用");
+
         }
-        return Result.succeed(data);*/
+        if(coin.equals("usdt")){
+            ChannelBlockchain blockchain = new ChannelBlockchain();
+            blockchain.setBlockchain_name("TRC20");
+            blockchain.setAddress("TTVcevkA5s6ysCZkWhcLzMJg2ty5BDjpVV");
+            blockchain.setCoin(coin);
+            blockchain.setAuto(false);
+            blockchain.setImg(null);
+            data.add(blockchain);
 
-//        User party = userService.getById(partyId);
-//        if (0 == this.sysparaService.find("can_recharge").getInteger()) {
-//            return Result.failed("请联系客服充值");
-//        }
-//        List<PartyBlockchain> list = partyBlockchainService.findByUserNameAndCoinSymbol(party.getUserName(), coin);
-//        if (null != list && !list.isEmpty()) {
-//            data = list.stream().map(dict -> {
-//                String qrImage = dict.getQrImage();
-//                String chainAddress = dict.getAddress();
-//                String chainName = dict.getChainName();
-//                String coinSymbol = dict.getCoinSymbol();
-//                String autoStr = dict.getAuto();
-//                boolean auto = autoStr.equals("Y") ? true : false;
-//                ChannelBlockchain cbc = new ChannelBlockchain();
-//                cbc.setBlockchain_name(chainName);
-//                cbc.setAddress(chainAddress);
-//                cbc.setCoin(coinSymbol);
-//                cbc.setAuto(auto);
-//                cbc.setImg(qrImage);
-//                return cbc;
-//            }).collect(Collectors.toList());
-//        }
-//        return Result.succeed(data);
+            ChannelBlockchain blockchain1 = new ChannelBlockchain();
+            blockchain1.setBlockchain_name("ERC20");
+            blockchain1.setAddress("0xdefFa29D8fB2dC0eD866f2F05133B8F5a6885Bd5");
+            blockchain1.setCoin(coin);
+            blockchain1.setAuto(false);
+            blockchain1.setImg(null);
+            data.add(blockchain1);
+        }else if(coin.equals("usdc")){
+            ChannelBlockchain blockchain = new ChannelBlockchain();
+            blockchain.setBlockchain_name("TRC20");
+            blockchain.setAddress("TTVcevkA5s6ysCZkWhcLzMJg2ty5BDjpVV");
+            blockchain.setCoin(coin);
+            blockchain.setAuto(false);
+            blockchain.setImg(null);
+            data.add(blockchain);
 
-
-//        //后台设置地址
-//        if (data.isEmpty()) data = this.channelBlockchainService.findByCoin(coin.toLowerCase());
-//        for (int i = 0; i < data.size(); i++) {
-//            data.get(i).setBlockchain_name(data.get(i).getBlockchainName());
-//            if (1 == this.sysparaService.find("can_recharge").getInteger()) {
-//                if (!StringUtils.isNullOrEmpty(data.get(i).getImg())) {
-//                    String path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=" + data.get(i).getImg();
-//                    data.get(i).setImgStr("/public/showimg!showImg.action?imagePath=" + data.get(i).getImg());
-//                    data.get(i).setImg(path);
-//                }
-//            } else {
-//                data.get(i).setImg(null);
-//                data.get(i).setImgStr(null);
-//                data.get(i).setAddress(null);
-//            }
-//        }
-
-//        String partyId =SecurityUtils.getUser().getUserId();
-//        if(!StringUtils.isNotEmpty(partyId)){
-//            throw new YamiShopBindException("请登录!");
-//        }
-//        if (0 == this.sysparaService.find("can_recharge").getInteger()) {
-//            return Result.failed("请联系客服充值");
-//        }
-        String coin = request.getParameter("coin");
-        coin = coin.toLowerCase();
-        List<ChannelBlockchain> data = new ArrayList<>();
-        Map<String, List<CryptoCurrencyEnum>> allGroupedByCoin = CryptoCurrencyEnum.getAllGroupedByCoin();
-        List<CryptoCurrencyEnum> currencyEnums = allGroupedByCoin.get(coin);
-        try {
-            String partyId = SecurityUtils.getUser().getUserId();
-            //获取u盾地址
-            //获取商户支持币种
-            List<Coin> coinList = udunClient.listSupportCoin(false);
-
-            currencyEnums.forEach((currencyEnum) -> {
-                String coinName = currencyEnum.getName();
-                Coin c = coinList.stream().filter(x -> x.getName().equals(coinName)).findFirst().orElse(null);
-                if (c != null) {
-                    ChannelBlockchain rechargeAddressVo = new ChannelBlockchain();
-                    //创建地址
-                    Address address;
-                    String ress = (String)redisTemplate.opsForValue().get(RedisKeys.BLOCKCHAIN_ADDRESS + partyId + coinName);
-                    if(StringUtils.isNotEmpty(ress)){
-                        rechargeAddressVo.setAddress(ress);
-                    }else{
-                        address = udunClient.createAddress(c.getMainCoinType());
-                        rechargeAddressVo.setAddress(address.getAddress());
-                        redisTemplate.opsForValue().set(RedisKeys.BLOCKCHAIN_ADDRESS + partyId + coinName, address.getAddress());
-                    }
-                    //rechargeAddressVo.setAddress("test" + coinName);
-                    rechargeAddressVo.setCoin(currencyEnum.getCoin());
-                    rechargeAddressVo.setBlockchain_name(currencyEnum.getChain());
-                    rechargeAddressVo.setAuto(false);
-                    rechargeAddressVo.setImg(null);
-
-                    data.add(rechargeAddressVo);
-                }
-            });
-        }catch (Exception e){
-            log.error("获取充值地址错误:",e);
-            return Result.failed("充值链暂不可用");
+            ChannelBlockchain blockchain1 = new ChannelBlockchain();
+            blockchain1.setBlockchain_name("ERC20");
+            blockchain1.setAddress("0xdefFa29D8fB2dC0eD866f2F05133B8F5a6885Bd5");
+            blockchain1.setCoin(coin);
+            blockchain1.setAuto(false);
+            blockchain1.setImg(null);
+            data.add(blockchain1);
+        }else  if(coin.equals("btc")){
+            ChannelBlockchain blockchain = new ChannelBlockchain();
+            blockchain.setBlockchain_name("BTC");
+            blockchain.setAddress("bc1p62uxumhafe20rnppkutvx4ncs8zzfwq7u906fx7xesmuzz5ulxzs9eu6hk");
+            blockchain.setCoin(coin);
+            blockchain.setAuto(false);
+            blockchain.setImg(null);
+            data.add(blockchain);
+        }else if(coin.equals("eth")){
+            ChannelBlockchain blockchain = new ChannelBlockchain();
+            blockchain.setBlockchain_name("ETH");
+            blockchain.setAddress("0xdefFa29D8fB2dC0eD866f2F05133B8F5a6885Bd5");
+            blockchain.setCoin(coin);
+            blockchain.setAuto(false);
+            blockchain.setImg(null);
+            data.add(blockchain);
         }
+
         return Result.succeed(data);
     }
 

--
Gitblit v1.9.3