zyy
2025-11-18 e69a147f81c790a805558a2e93b34364852d7dea
新增英镑汇率
4 files modified
90 ■■■■ changed files
trading-order-admin/src/main/java/com/yami/trading/admin/controller/loan/internal/LoanServiceImpl.java 4 ●●●● patch | view | raw | blame | history
trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiWalletController.java 46 ●●●●● patch | view | raw | blame | history
trading-order-service/src/main/java/com/yami/trading/service/impl/UserServiceImpl.java 8 ●●●● patch | view | raw | blame | history
trading-order-service/src/main/java/com/yami/trading/service/rate/ExchangeRateService.java 32 ●●●●● patch | view | raw | blame | history
trading-order-admin/src/main/java/com/yami/trading/admin/controller/loan/internal/LoanServiceImpl.java
@@ -440,8 +440,8 @@
            }
            //到账金额
            double amt = loanOrder.getQuota().doubleValue();
            if (loanOrder.getSymbol().equalsIgnoreCase("EUR")) {
                ExchangeRate exchangeRate = exchangeRateService.findBy(ExchangeRate.IN, "EUR");
            if (!loanOrder.getSymbol().equalsIgnoreCase("usdt")) {
                ExchangeRate exchangeRate = exchangeRateService.findBy(ExchangeRate.IN, loanOrder.getSymbol().toUpperCase());
                if (exchangeRate == null) {
                    throw new YamiShopBindException("汇率未设置!");
                }
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());
trading-order-service/src/main/java/com/yami/trading/service/impl/UserServiceImpl.java
@@ -187,16 +187,16 @@
    @Override
    public void saveResetCreateOrder(String partyId, double money_revise, String safeword, String operator_name, String reset_type, String ip, String coin_type) {
        if (money_revise == 0 || coin_type == "") {
        if (money_revise == 0 || coin_type.equalsIgnoreCase("")) {
            return;
        }
        if ("usdt".equals(coin_type) || "eur".equals(coin_type)) {
        if ("usdt".equalsIgnoreCase(coin_type) || "eur".equalsIgnoreCase(coin_type) || "gbp".equalsIgnoreCase(coin_type)) {
            // 交易所修改usdt
            //到账金额
            double toAmt = money_revise;
            if (coin_type.equals("eur")) {
                ExchangeRate exchangeRate = exchangeRateService.findBy(ExchangeRate.IN, "EUR");
            if (!coin_type.equalsIgnoreCase("usdt")) {
                ExchangeRate exchangeRate = exchangeRateService.findBy(ExchangeRate.IN, coin_type.toUpperCase());
                if (exchangeRate == null) {
                    throw new YamiShopBindException("汇率未设置!");
                }
trading-order-service/src/main/java/com/yami/trading/service/rate/ExchangeRateService.java
@@ -84,4 +84,36 @@
        return currency;
    }
    /**
     * 根据股票类型获取对应USDT金额
     *
     * @param currency 币种价值
     * @param type     股票类型
     * @return currency
     */
    public BigDecimal getUsdtByType(List<ExchangeRate> list, BigDecimal currency, String type) {
        if (StringUtils.isEmpty(type)) {
            type = Item.US_STOCKS;
        }
        if (type.contains("A") && !Item.A_STOCKS.equalsIgnoreCase(type)) {
            type = type.replace("A", "");
        }
        //ExchangeRate rate = getOne(new LambdaQueryWrapper<ExchangeRate>().like(ExchangeRate::getType, type));
        String finalType = type;
        ExchangeRate rate = list.stream()
                .filter(x -> {
                    if (x.getType() == null || x.getType().isEmpty()) {
                        return false; // 若任一为 null,不匹配
                    }
                    // 统一转为小写(或大写)后,判断是否包含目标子串
                    return x.getType().toLowerCase().contains(finalType.toLowerCase());
                })
                .findFirst().orElse(null);
        if (rate != null) {
            BigDecimal rata = rate.getRata();
            currency = currency.divide(rata, 4, RoundingMode.FLOOR);
        }
        return currency;
    }
}