zyy
2025-11-17 03ec6194650d6a79e2256337892a00f52a7be8bf
优化
1 files modified
27 ■■■■■ changed files
trading-order-service/src/main/java/com/yami/trading/service/impl/WalletServiceImpl.java 27 ●●●●● patch | view | raw | blame | history
trading-order-service/src/main/java/com/yami/trading/service/impl/WalletServiceImpl.java
@@ -1,6 +1,7 @@
package com.yami.trading.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
@@ -664,8 +665,8 @@
        // 统计拓展钱包
        List<Item> items = itemService.findByType(symbolType);
        List<String> symbolList = items.stream().map(Item::getSymbol).collect(Collectors.toList());
        List<Realtime> realtimeList = dataService.realtimeByType(symbolType);
        double convertUsdt = getWalletExtendConvertUsdt(partyId, realtimeList, symbolList);
        //List<Realtime> realtimeList = dataService.realtimeByType(symbolType);
        double convertUsdt = getWalletExtendConvertUSDT(partyId, symbolList);
        // logger.info("getTotalAssets ==> "+partyId + " ===> "+symbolType+"====>"+convertUsdt);
@@ -1036,6 +1037,28 @@
        return walletExtendAll;
    }
    public double getWalletExtendConvertUSDT(String partyId, List<String> symbolList) {
        double walletExtendAll = 0;
        List<WalletExtend> walletExtends = findExtend(partyId, symbolList);
        for (WalletExtend walletExtend : walletExtends) {
            String symbol = symbolList.stream()
                    .filter( x -> x.equalsIgnoreCase(walletExtend.getWallettype()))
                    .findFirst().orElse(null);
            if (symbol != null) {
                List<Realtime> realtimeList = dataService.realtime(symbol);
                if (!CollectionUtil.isEmpty(realtimeList)) {
                    Realtime realtime = realtimeList.get(0);
                    Item item = itemService.findBySymbol(symbol);
                    String type = item.getType();
                    double currency = Arith.mul(realtime.getClose(), walletExtend.getAmount());
                    BigDecimal usdtByType = exchangeRateService.getUsdtByType(BigDecimal.valueOf(currency), type);
                    walletExtendAll = Arith.add(walletExtendAll, usdtByType.doubleValue());
                }
            }
        }
        return walletExtendAll;
    }
    /*
     * 获取 所有订单 交割合约总资产、总未实现盈利 redis
     */