From e69a147f81c790a805558a2e93b34364852d7dea Mon Sep 17 00:00:00 2001
From: zyy <zyy@email.com>
Date: Tue, 18 Nov 2025 16:13:15 +0800
Subject: [PATCH] 新增英镑汇率

---
 trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiWalletController.java |   46 ++++++++++++++++++++++++++++++----------------
 1 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiWalletController.java b/trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiWalletController.java
index 3124efe..49dae51 100644
--- a/trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiWalletController.java
+++ b/trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiWalletController.java
@@ -1,6 +1,7 @@
 package com.yami.trading.api.controller;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.yami.trading.api.dto.ChannelBlockchainDto;
 import com.yami.trading.api.model.GetChannelBlockchainModel;
@@ -11,6 +12,7 @@
 import com.yami.trading.bean.model.ChannelBlockchain;
 import com.yami.trading.bean.model.Wallet;
 import com.yami.trading.bean.model.WalletExtend;
+import com.yami.trading.bean.rate.domain.ExchangeRate;
 import com.yami.trading.bean.vo.WithdrawFeeVo;
 import com.yami.trading.common.constants.Constants;
 import com.yami.trading.common.domain.Result;
@@ -253,6 +255,7 @@
             mapRet.put("lock_money", usdt.getLockMoney());
             mapRet.put("freeze_money", usdt.getFreezeMoney());
         }
+
         // 其他币账户
         List<Item> list_it = this.itemService.cacheGetByMarket("");
         if (StringUtils.isNotEmpty(symbolType)) {
@@ -266,6 +269,7 @@
                 list_it = list_it.stream().filter(i -> symbolType.equalsIgnoreCase(i.getType())).collect(Collectors.toList());
             }
         }
+
         List<String> list_symbol = new ArrayList<>();
         if (!StringUtils.isNotEmpty(symbol)) {
             // symbol为空,获取所有的
@@ -283,6 +287,7 @@
                 }
             }
         }
+
         List<Item> items = this.itemService.cacheGetAll();
         // 按id排序
         Collections.sort(items, new Comparator<Item>() {
@@ -291,6 +296,7 @@
                 return arg0.getUuid().compareTo(arg1.getUuid());
             }
         });
+
         Map<String, Item> itemMap = new HashMap<String, Item>();
         for (int i = 0; i < items.size(); i++) {
             itemMap.put(items.get(i).getSymbol(), items.get(i));
@@ -301,24 +307,26 @@
                 walletExtends = this.walletService.findExtend(partyId, list_symbol);
             }
         }
+
         if (null == walletExtends) {
             walletExtends = new ArrayList<>();
         }
         List<WalletExtend> walletExtendsRet = new ArrayList<WalletExtend>();
-        int temp = 0;
         for (int i = 0; i < list_symbol.size(); i++) {
-            for (int j = 0; j < walletExtends.size(); j++) {
-                WalletExtend walletExtend = walletExtends.get(j);
-                if (walletExtend.getWallettype().toUpperCase().equals(list_symbol.get(i).toUpperCase())) {
-                    walletExtend.setAmount(Double.valueOf(df2.format(walletExtend.getAmount())));
-                    walletExtend.setLockAmount(Double.valueOf(df2.format(walletExtend.getLockAmount())));
-                    walletExtend.setFreezeAmount(Double.valueOf(df2.format(walletExtend.getFreezeAmount())));
-                    walletExtendsRet.add(walletExtend);
-                    temp = 1;
+            String symbols = list_symbol.get(i);
+            WalletExtend walletExtend = walletExtends.stream()
+                    .filter(x -> x.getWallettype().equalsIgnoreCase(symbols))
+                    .findFirst().orElse(null);
+            if (null != walletExtend) {
+                walletExtend.setAmount(Double.parseDouble(df2.format(walletExtend.getAmount())));
+                walletExtend.setLockAmount(Double.parseDouble(df2.format(walletExtend.getLockAmount())));
+                walletExtend.setFreezeAmount(Double.parseDouble(df2.format(walletExtend.getFreezeAmount())));
+                walletExtendsRet.add(walletExtend);
+            } else {
+                if (symbolType.equalsIgnoreCase(Item.US_STOCKS)) {
+                    continue;
                 }
-            }
-            if (0 == temp) {
-                WalletExtend walletExtend = new WalletExtend();
+                walletExtend = new WalletExtend();
                 if (StringUtils.isNotEmpty(partyId)) {
                     walletExtend.setPartyId(partyId);
                 }
@@ -335,9 +343,15 @@
                 }
                 walletExtendsRet.add(walletExtend);
             }
-            temp = 0;
         }
+
         String symbolsStr = "";
+
+        List<String> wallTypeList = walletExtendsRet.stream()
+                .map(WalletExtend::getWallettype)
+                .map(type -> type != null ? type.toLowerCase() : null)
+                .collect(Collectors.toList());
+        list_symbol = list_symbol.stream().filter( x -> wallTypeList.contains(x.toLowerCase())).collect(Collectors.toList());
         for (int i = 0; i < list_symbol.size(); i++) {
             if (i != 0) {
                 symbolsStr = symbolsStr + "," + list_symbol.get(i);
@@ -354,6 +368,7 @@
             realtimeMap.put(realtime_all.get(i).getSymbol(), realtime_all.get(i));
         }
         List<Map<String, Object>> extendsList = new ArrayList<Map<String, Object>>();
+        List<ExchangeRate> rateList = exchangeRateService.list();
         for (int i = 0; i < walletExtendsRet.size(); i++) {
             if (false == all) {
                 // 只要btc、eth
@@ -380,8 +395,8 @@
             map.put("frozenAmount", walletExtendsRet.get(i).getFreezeAmount());
             Realtime rt = realtimeMap.get(walletExtendsRet.get(i).getWallettype());
             if (null != rt) {
-                map.put("usdt", df2.format(exchangeRateService.getUsdtByType(BigDecimal.valueOf(Arith.mul(rt.getClose(), volume)), symbolType)));
-                map.put("usableUsdt", df2.format(exchangeRateService.getUsdtByType(BigDecimal.valueOf(Arith.mul(rt.getClose(), walletExtendsRet.get(i).getAmount())), symbolType)));
+                map.put("usdt", df2.format(exchangeRateService.getUsdtByType(rateList, BigDecimal.valueOf(Arith.mul(rt.getClose(), volume)), symbolType)));
+                map.put("usableUsdt", df2.format(exchangeRateService.getUsdtByType(rateList, BigDecimal.valueOf(Arith.mul(rt.getClose(), walletExtendsRet.get(i).getAmount())), symbolType)));
             } else {
                 map.put("usdt", 0);
                 map.put("usableUsdt", 0);
@@ -440,7 +455,6 @@
         }
         Map<String, String> itemMap = new HashMap<String, String>();
         Map<String, String> itemSymbolDataMap = new HashMap<String, String>();
-
         for (int i = 0; i < list_it.size(); i++) {
             itemMap.put(list_it.get(i).getSymbol(), list_it.get(i).getSymbolFullName());
             itemSymbolDataMap.put(list_it.get(i).getSymbol(), list_it.get(i).getSymbolData());

--
Gitblit v1.9.3