| | |
| | | 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; |
| | |
| | | String data_symbol = ""; |
| | | List<String> list_symbol = new ArrayList<String>(); |
| | | |
| | | List<Item> list_items = this.itemService.cacheGetByMarket(""); |
| | | List<WalletExtend> walletExtendList = findExtend(partyId.toString()); |
| | | list_symbol = walletExtendList.stream().map(WalletExtend::getWallettype).collect(Collectors.toList()); |
| | | for (int i = 0; i < list_symbol.size(); i++) { |
| | | String symbol = list_symbol.get(i); |
| | | if (i != 0) { |
| | | data_symbol = data_symbol + "," + symbol; |
| | | } else { |
| | | data_symbol = symbol; |
| | | } |
| | | } |
| | | |
| | | /*List<Item> list_items = this.itemService.cacheGetByMarket(""); |
| | | for (int i = 0; i < list_items.size(); i++) { |
| | | Item items = list_items.get(i); |
| | | list_symbol.add(items.getSymbol()); |
| | |
| | | } else { |
| | | data_symbol = items.getSymbol(); |
| | | } |
| | | } |
| | | }*/ |
| | | |
| | | List<Realtime> realtime_all = this.dataService.realtime(data_symbol); |
| | | if (realtime_all.size() <= 0) { |
| | |
| | | // 钱包USDT |
| | | money_wallet = wallet.getMoney().doubleValue(); |
| | | // 币余额 |
| | | money_coin = this.getWalletExtendConvertUsdt(partyId.toString(), realtime_all, list_symbol); |
| | | money_coin = this.getWalletExtendConvertUsdt2(realtime_all, walletExtendList); |
| | | money = money + money_coin; |
| | | // 钱包USDT+币余额 |
| | | money_all_coin = money; |
| | |
| | | // 统计拓展钱包 |
| | | 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); |
| | |
| | | // walletLog.setWallettype("USDT"); |
| | | } |
| | | |
| | | public double getWalletExtendConvertUsdt2(List<Realtime> realtimeList, List<WalletExtend> walletExtends) { |
| | | double walletExtendAll = 0; |
| | | for (WalletExtend walletExtend : walletExtends) { |
| | | for (Realtime realtime : realtimeList) { |
| | | String symbol = realtime.getSymbol(); |
| | | if (symbol.equalsIgnoreCase(walletExtend.getWallettype())) { |
| | | 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; |
| | | } |
| | | |
| | | public double getWalletExtendConvertUsdt(String partyId, List<Realtime> realtimeList, List<String> symbolList) { |
| | | double walletExtendAll = 0; |
| | | List<WalletExtend> walletExtends = findExtend(partyId, symbolList); |
| | |
| | | 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 |
| | | */ |