From 829f629756e5402bcd3e9f6ef1f9c6dbffbabb11 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Wed, 17 Apr 2024 14:46:29 +0800
Subject: [PATCH] 55测试环境

---
 src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java |  104 ++++++++++++++++++++++++++++++---------------------
 1 files changed, 61 insertions(+), 43 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java b/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java
index 9ae4435..6dd5b92 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java
@@ -93,6 +93,7 @@
     public Result getWalletCoin() {
         //获取用户ID
         Long memberId = LoginUserUtils.getAppLoginUser().getId();
+//        Long memberId = 444L;
         PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
         BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
 
@@ -104,13 +105,15 @@
 
             if (CollUtil.isNotEmpty(memberWalletCoinlist)) {
                 for (MemberWalletCoinEntity memberWalletCoinEntity : memberWalletCoinlist) {
-                    MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo();
-                    memberWalletCoinInfoVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
-                    memberWalletCoinInfoVo.setFrozenBalance(memberWalletCoinEntity.getFrozenBalance().setScale(4, BigDecimal.ROUND_DOWN));
-                    memberWalletCoinInfoVo.setMemberId(memberWalletCoinEntity.getMemberId());
-                    memberWalletCoinInfoVo.setTotalBalance(memberWalletCoinEntity.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
-                    memberWalletCoinInfoVo.setWalletCode(memberWalletCoinEntity.getWalletCode());
-                    memberWalletCoinInfoVolist.add(memberWalletCoinInfoVo);
+                    if ("USDT".equals(memberWalletCoinEntity.getWalletCode()) || "XCH".equals(memberWalletCoinEntity.getWalletCode())) {
+                        MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo();
+                        memberWalletCoinInfoVo.setAvailableBalance(memberWalletCoinEntity.getAvailableBalance().setScale(8, BigDecimal.ROUND_DOWN));
+                        memberWalletCoinInfoVo.setFrozenBalance(memberWalletCoinEntity.getFrozenBalance().setScale(8, BigDecimal.ROUND_DOWN));
+                        memberWalletCoinInfoVo.setMemberId(memberWalletCoinEntity.getMemberId());
+                        memberWalletCoinInfoVo.setTotalBalance(memberWalletCoinEntity.getTotalBalance().setScale(8, BigDecimal.ROUND_DOWN));
+                        memberWalletCoinInfoVo.setWalletCode(memberWalletCoinEntity.getWalletCode());
+                        memberWalletCoinInfoVolist.add(memberWalletCoinInfoVo);
+                    }
                 }
             }
 
@@ -122,16 +125,33 @@
                         totalUsdts = totalUsdts.add(totalUsdt);
                         BigDecimal totalCny = totalUsdt.multiply(cnyUsdt);
                         walletCoin.setTotalBalance(totalCny);
-                    } else {
+                    }
+
+                    if ("XCH".equals(walletCoin.getWalletCode())) {
+//                        BigDecimal xch = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
+//                        String xchNewPrice = redisUtils.getString("XCH_NEW_PRICE");
+//                        BigDecimal totalUsdt = xch.add(new BigDecimal(xchNewPrice));
+//                        BigDecimal totalCny = totalUsdt.multiply(cnyUsdt);
+//                        walletCoin.setTotalBalance(totalCny);
+
                         BigDecimal amount = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
                         // 获取最新价
-                        BigDecimal closePrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(walletCoin.getWalletCode()+"/USDT")));
+                        BigDecimal closePrice = new BigDecimal(redisUtils.getString("XCH_NEW_PRICE"));
                         BigDecimal totalUsdt = BigDecimal.ZERO;
-                        //Double closePrice = symbolsService.getCloseSymbolsBySymbolsName(walletCoin.getWalletCode()+"/USDT");
                         totalUsdt = totalUsdt.add(amount.multiply(closePrice));
                         totalUsdts = totalUsdts.add(totalUsdt);
                         walletCoin.setTotalBalance(totalUsdt.multiply(cnyUsdt));
                     }
+//                    else {
+//                        BigDecimal amount = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
+//                        // 获取最新价
+//                        BigDecimal closePrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(walletCoin.getWalletCode()+"/USDT")));
+//                        BigDecimal totalUsdt = BigDecimal.ZERO;
+//                        //Double closePrice = symbolsService.getCloseSymbolsBySymbolsName(walletCoin.getWalletCode()+"/USDT");
+//                        totalUsdt = totalUsdt.add(amount.multiply(closePrice));
+//                        totalUsdts = totalUsdts.add(totalUsdt);
+//                        walletCoin.setTotalBalance(totalUsdt.multiply(cnyUsdt));
+//                    }
                 }
             }
             MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo();
@@ -454,7 +474,7 @@
     	MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, symbol);
     	BigDecimal availableBalance = walletContract.getAvailableBalance();
 
-    	BigDecimal canReduce = BigDecimal.ZERO;
+    	BigDecimal canReduce = availableBalance;
     	//可用减去盈亏
     	if(totalProfitOrLess.compareTo(BigDecimal.ZERO) < 0){
             canReduce = availableBalance.add(totalProfitOrLess);
@@ -847,6 +867,7 @@
 	public Result getAllWalletCoin() {
 		//获取【币币】
         Long memberId = LoginUserUtils.getAppLoginUser().getId();
+//        Long memberId =446L;
         PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
         BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
         AllWalletCoinVo allWalletCoinVo = new AllWalletCoinVo();
@@ -1014,7 +1035,7 @@
     			for(MemberCoinChargeEntity memberCoinChargeEntitys : records) {
     				CoinInListVo coinInListVo = new CoinInListVo();
     				coinInListVo.setSymbol(memberCoinChargeEntitys.getSymbol());
-    				coinInListVo.setAmount(memberCoinChargeEntitys.getAmount());
+    				coinInListVo.setAmount(memberCoinChargeEntitys.getAmount().toPlainString());
     				coinInListVo.setContent("充币");
     				coinInListVo.setStatus(memberCoinChargeEntitys.getStatus());
     				coinInListVo.setUpdateTime(memberCoinChargeEntitys.getUpdateTime());
@@ -1038,7 +1059,7 @@
     			for(MemberCoinWithdrawEntity memberCoinWithdrawEntitys : records) {
     				CoinInListVo coinInListVo = new CoinInListVo();
     				coinInListVo.setSymbol(memberCoinWithdrawEntitys.getSymbol());
-    				coinInListVo.setAmount(memberCoinWithdrawEntitys.getAmount());
+    				coinInListVo.setAmount(memberCoinWithdrawEntitys.getAmount().toPlainString());
     				coinInListVo.setContent("提币");
     				int status = memberCoinWithdrawEntitys.getStatus();
     				int statusOut = 0;
@@ -1074,7 +1095,7 @@
     			for(MemberAccountMoneyChange memberAccountMoneyChanges : records) {
     				CoinInListVo coinInListVo = new CoinInListVo();
     				coinInListVo.setSymbol(memberAccountMoneyChanges.getSymbol());
-    				coinInListVo.setAmount(memberAccountMoneyChanges.getAmount());
+    				coinInListVo.setAmount(memberAccountMoneyChanges.getAmount().toPlainString());
     				coinInListVo.setContent(memberAccountMoneyChanges.getContent());
     				coinInListVo.setStatus(memberAccountMoneyChanges.getStatus());
     				coinInListVo.setUpdateTime(memberAccountMoneyChanges.getUpdateTime());
@@ -1098,7 +1119,7 @@
     			for(MemberAccountMoneyChange memberAccountMoneyChanges : records) {
     				CoinInListVo coinInListVo = new CoinInListVo();
     				coinInListVo.setSymbol(memberAccountMoneyChanges.getSymbol());
-    				coinInListVo.setAmount(memberAccountMoneyChanges.getAmount());
+    				coinInListVo.setAmount(memberAccountMoneyChanges.getAmount().toPlainString());
     				coinInListVo.setContent(memberAccountMoneyChanges.getContent());
     				coinInListVo.setStatus(memberAccountMoneyChanges.getStatus());
     				coinInListVo.setUpdateTime(memberAccountMoneyChanges.getUpdateTime());
@@ -1112,33 +1133,30 @@
         return Result.fail(MessageSourceUtils.getString("member_controller_0005"));
         
     }
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
-	
 
+
+    @Override
+    public BigDecimal getAllWalletAmount(Long memberId) {
+        List<MemberWalletCoinEntity> memberWalletCoinList = memberWalletCoinDao.selectMemberWalletCoinsByMemberId(memberId);
+        BigDecimal total = BigDecimal.ZERO;
+        if (CollUtil.isNotEmpty(memberWalletCoinList)) {
+            for (MemberWalletCoinEntity memberWalletCoinEntity : memberWalletCoinList) {
+                if (memberWalletCoinEntity.getWalletCode().equals(CoinTypeEnum.USDT.name())) {
+                    total = total.add(memberWalletCoinEntity.getTotalBalance());
+                } else {
+                    BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(memberWalletCoinEntity.getWalletCode() + "/USDT")));
+                    total = total.add(memberWalletCoinEntity.getTotalBalance().multiply(newPrice));
+                }
+            }
+        }
+
+        MemberWalletContractEntity contractWallet = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, CoinTypeEnum.USDT.name());
+        total = total.add(contractWallet.getTotalBalance());
+
+        MemberWalletAgentEntity walletAgent = memberWalletAgentDao.selectWalletAgentBymIdAndCode(memberId, CoinTypeEnum.USDT.name());
+        if (walletAgent != null) {
+            total = total.add(walletAgent.getTotalBalance());
+        }
+        return total;
+    }
 }

--
Gitblit v1.9.1