From be8c9767089b5e52ed462ea1d083d846e7420a45 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Mon, 15 Jun 2026 11:01:37 +0800
Subject: [PATCH] 1

---
 trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiChannelBlockchainController.java |   75 +++++++++++++++----------------------
 1 files changed, 31 insertions(+), 44 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 aa1cde9..5331259 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
@@ -85,33 +85,12 @@
      */
     @RequestMapping(action + "list.action")
     public Object list() throws IOException {
-        List<ChannelBlockchain> data = new ArrayList<ChannelBlockchain>();
         String partyId = SecurityUtils.getUser().getUserId();
         User party = userService.getById(partyId);
-        List<PartyBlockchain> list = partyBlockchainService.findByUserName(party.getUserName());
-        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.setBlockchainName(chainName);
-                cbc.setBlockchain_name(chainName);
-                cbc.setAddress(chainAddress);
-                cbc.setCoin(coinSymbol);
-                cbc.setAuto(auto);
-                cbc.setImg(qrImage);
-                return cbc;
-            }).collect(Collectors.toList());
-        }
-        if (data.isEmpty()) data = channelBlockchainService.list();
+        List<ChannelBlockchain> data = buildAddressList(party, null);
         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).setImg(path);
@@ -127,31 +106,12 @@
     @GetMapping(action + "getBlockchainName.action")
     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);
         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());
-        }
-        if (data.isEmpty()) data = this.channelBlockchainService.findByCoin(coin.toLowerCase());
+        List<ChannelBlockchain> data = buildAddressList(party, coin);
         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()) {
@@ -160,8 +120,6 @@
                     config.setMargin(3);
                     String qr = QrCodeUtil.generateAsBase64(data.get(i).getAddress(), config, "png");
                     data.get(i).setImgStr(qr);
-//                    data.get(i).setImgStr("/public/showimg!showImg.action?imagePath=" + data.get(i).getImg());
-//                    data.get(i).setImg(path);
                 }
             } else {
                 data.get(i).setImg(null);
@@ -172,6 +130,35 @@
         return Result.succeed(data);
     }
 
+    private List<ChannelBlockchain> buildAddressList(User party, String coin) {
+        List<ChannelBlockchain> templates = StringUtils.isNullOrEmpty(coin)
+                ? channelBlockchainService.list()
+                : channelBlockchainService.findByCoin(coin.toLowerCase());
+        List<PartyBlockchain> partyList = StringUtils.isNullOrEmpty(coin)
+                ? partyBlockchainService.findByUserName(party.getUserName())
+                : partyBlockchainService.findByUserNameAndCoinSymbol(party.getUserName(), coin);
+        Map<String, String> customAddresses = new HashMap<>();
+        for (PartyBlockchain pb : partyList) {
+            customAddresses.put(addressKey(pb.getCoinSymbol(), pb.getChainName()), pb.getAddress());
+        }
+        return templates.stream().map(template -> {
+            ChannelBlockchain cbc = new ChannelBlockchain();
+            cbc.setUuid(template.getUuid());
+            cbc.setCoin(template.getCoin());
+            cbc.setBlockchainName(template.getBlockchainName());
+            cbc.setBlockchain_name(template.getBlockchainName());
+            cbc.setAuto(template.isAuto());
+            cbc.setImg(template.getImg());
+            String key = addressKey(template.getCoin(), template.getBlockchainName());
+            cbc.setAddress(customAddresses.getOrDefault(key, template.getAddress()));
+            return cbc;
+        }).collect(Collectors.toList());
+    }
+
+    private String addressKey(String coin, String chain) {
+        return (coin == null ? "" : coin.toLowerCase()) + "|" + (chain == null ? "" : chain.toLowerCase());
+    }
+
     /**
      * 根据币种获取链地址
      */

--
Gitblit v1.9.3