| | |
| | | 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; |
| | |
| | | // 统计拓展钱包 |
| | | 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); |
| | |
| | | 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 |
| | | */ |