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 |  779 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 708 insertions(+), 71 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 5516712..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
@@ -2,10 +2,20 @@
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
-import javax.annotation.Resource;
+import java.util.Map;
 
+import javax.annotation.Resource;
+import javax.validation.Valid;
+
+import com.xcong.excoin.modules.contract.dao.ContractHoldOrderDao;
+import com.xcong.excoin.modules.contract.entity.ContractEntrustOrderEntity;
+import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity;
+import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
 import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
+import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity;
+import com.xcong.excoin.utils.*;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -20,28 +30,35 @@
 import com.xcong.excoin.modules.coin.entity.MemberAccountMoneyChange;
 import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity;
 import com.xcong.excoin.modules.coin.mapper.MemberAccountMoneyChangeMapper;
+import com.xcong.excoin.modules.coin.parameter.dto.CoinInListDto;
 import com.xcong.excoin.modules.coin.parameter.dto.RecordsPageDto;
+import com.xcong.excoin.modules.coin.parameter.vo.AllWalletCoinVo;
+import com.xcong.excoin.modules.coin.parameter.vo.CoinInListVo;
+import com.xcong.excoin.modules.coin.parameter.vo.ContractSymbolListVo;
 import com.xcong.excoin.modules.coin.parameter.vo.MemberAccountMoneyChangeInfoVo;
-import com.xcong.excoin.modules.coin.parameter.vo.MemberAgentIntoInfoVo;
 import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletAgentInfoVo;
 import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinInfoVo;
 import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletCoinVo;
 import com.xcong.excoin.modules.coin.parameter.vo.MemberWalletContractInfoVo;
 import com.xcong.excoin.modules.coin.service.CoinService;
+import com.xcong.excoin.modules.member.dao.MemberCoinChargeDao;
+import com.xcong.excoin.modules.member.dao.MemberCoinWithdrawDao;
+import com.xcong.excoin.modules.member.dao.MemberDao;
 import com.xcong.excoin.modules.member.dao.MemberWalletAgentDao;
 import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
 import com.xcong.excoin.modules.member.dao.MemberWalletContractDao;
+import com.xcong.excoin.modules.member.entity.MemberCoinChargeEntity;
+import com.xcong.excoin.modules.member.entity.MemberCoinWithdrawEntity;
+import com.xcong.excoin.modules.member.entity.MemberEntity;
 import com.xcong.excoin.modules.member.entity.MemberWalletAgentEntity;
 import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
 import com.xcong.excoin.modules.member.entity.MemberWalletContractEntity;
 import com.xcong.excoin.modules.platform.dao.PlatformCnyUsdtExchangeDao;
-import com.xcong.excoin.utils.CoinTypeConvert;
-import com.xcong.excoin.utils.MessageSourceUtils;
-import com.xcong.excoin.utils.RedisUtils;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import jnr.ffi.Struct.int16_t;
 
 @Service
 public class CoinServiceImpl extends ServiceImpl<MemberWalletCoinDao, MemberWalletCoinEntity> implements CoinService {
@@ -59,13 +76,24 @@
     @Resource
     MemberWalletAgentDao memberWalletAgentDao;
     @Resource
+    MemberDao memberDao;
+    @Resource
+    MemberCoinChargeDao memberCoinChargeDao;
+    @Resource
+    MemberCoinWithdrawDao memberCoinWithdrawDao;
+    @Resource
     RedisUtils redisUtils;
+    @Resource
+    CacheSettingUtils cacheSettingUtils;
+    @Resource
+    ContractHoldOrderDao contractHoldOrderDao;
 
 
     @Override
     public Result getWalletCoin() {
         //获取用户ID
         Long memberId = LoginUserUtils.getAppLoginUser().getId();
+//        Long memberId = 444L;
         PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
         BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
 
@@ -77,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);
+                    }
                 }
             }
 
@@ -95,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();
@@ -139,7 +186,6 @@
             memberWalletCoinVo.setTotalUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN));
             memberWalletCoinVo.setTotalCny(totalUsdts.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
             memberWalletCoinVo.setMemberWalletCoinInfoVo(memberWalletCoinlist);
-            ;
             return Result.ok(memberWalletCoinVo);
         }
     }
@@ -176,36 +222,24 @@
 
         //获取用户ID
         Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
         PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
         BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
-
-        String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
-        MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
-        if (ObjectUtil.isEmpty(walletContract)) {
-            return Result.fail(MessageSourceUtils.getString("member_service_0001"));
-        }
-        /**
-         * todo
-         */
-        //获取当前的合约持仓
-        //获取实时盈亏
-        BigDecimal profitAndLoss = new BigDecimal("0");
-        //获取总付款
-        BigDecimal totalPayment = new BigDecimal("0");
-        BigDecimal lastTotalBalance = new BigDecimal("0");
-        BigDecimal totalBalance = walletContract.getTotalBalance();
-        lastTotalBalance = totalBalance.add(profitAndLoss);
-        if (lastTotalBalance.compareTo(BigDecimal.ZERO) < 0) {
-            lastTotalBalance = new BigDecimal("0");
-        }
-
-        MemberWalletContractInfoVo memberWalletContractInfoVo = new MemberWalletContractInfoVo();
-        memberWalletContractInfoVo.setFrozenBalance(totalPayment.setScale(4, BigDecimal.ROUND_DOWN));
-        memberWalletContractInfoVo.setAvailableBalance(walletContract.getAvailableBalance());
-        memberWalletContractInfoVo.setTotalBalance(lastTotalBalance.setScale(4, BigDecimal.ROUND_DOWN));
-        memberWalletContractInfoVo.setTotalRMBBalance(lastTotalBalance.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
-
+        
+        Map<String, Object> columnMap = new HashMap<String, Object>();
+        columnMap.put("member_id", memberId);
+        columnMap.put("wallet_code", "USDT");
+		List<MemberWalletContractEntity> selectByMap = memberWalletContractDao.selectByMap(columnMap);
+		MemberWalletContractInfoVo memberWalletContractInfoVo = new MemberWalletContractInfoVo();
+		if(CollUtil.isNotEmpty(selectByMap)) {
+			for(MemberWalletContractEntity memberWalletContractEntity : selectByMap) {
+				memberWalletContractInfoVo.setFrozenBalance(memberWalletContractEntity.getFrozenBalance().setScale(4, BigDecimal.ROUND_DOWN));
+				memberWalletContractInfoVo.setAvailableBalance(memberWalletContractEntity.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
+				memberWalletContractInfoVo.setTotalCoin(memberWalletContractEntity.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
+				memberWalletContractInfoVo.setAvailableCoin(memberWalletContractEntity.getTotalBalance().multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
+				memberWalletContractInfoVo.setWalletCode(memberWalletContractEntity.getWalletCode()+"/USDT");
+			}
+		}
+		
         return Result.ok(memberWalletContractInfoVo);
     }
 
@@ -228,9 +262,6 @@
                 return Result.fail(MessageSourceUtils.getString("member_service_0005"));
             }
             BigDecimal subtract = walletCoin.getTotalBalance().subtract(balance);
-            if (subtract.compareTo(BigDecimal.ZERO) < 0) {
-                return Result.fail(MessageSourceUtils.getString("member_service_0005"));
-            }
             walletCoin.setAvailableBalance(total);
             walletCoin.setTotalBalance(subtract);
             int updateWalletCoinById = memberWalletCoinDao.updateById(walletCoin);
@@ -262,6 +293,73 @@
 
             //添加合约资金划转历史记录
             memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMWALLETCOIN.getValue());
+            memberAccountRecord.setSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue());
+            memberAccountRecord.setAmount(balance);
+            memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
+            memberAccountMoneyChangeDao.insert(memberAccountRecord);
+        }
+        return Result.ok(MessageSourceUtils.getString("member_service_0006"));
+    }
+    
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Result coinWalletTransferToContracts(BigDecimal balance, String symbol) {
+        if (balance.compareTo(BigDecimal.ZERO) <= 0) {
+            return Result.fail(MessageSourceUtils.getString("member_service_0004"));
+        }
+        //获取用户ID
+        Long memberId = LoginUserUtils.getAppLoginUser().getId();
+
+        if (!StrUtil.isEmpty(memberId.toString())) {
+        	//获取对应的币种
+            String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
+            MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
+            BigDecimal available = walletCoin.getAvailableBalance();
+            // 扣币
+            BigDecimal total = available.subtract(balance);
+            if (total.compareTo(BigDecimal.ZERO) < 0) {
+                return Result.fail(MessageSourceUtils.getString("member_service_0005"));
+            }
+            BigDecimal subtract = walletCoin.getTotalBalance().subtract(balance);
+            walletCoin.setAvailableBalance(total);
+            walletCoin.setTotalBalance(subtract);
+            int updateWalletCoinById = memberWalletCoinDao.updateById(walletCoin);
+            if (updateWalletCoinById < 1) {
+                return Result.fail(MessageSourceUtils.getString("member_service_0096"));
+            }
+            // 加币
+            // 查询合约账户
+            MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, symbol);
+            BigDecimal availableBalance = walletContract.getAvailableBalance();
+            BigDecimal add = availableBalance.add(balance);
+            walletContract.setAvailableBalance(add);
+            BigDecimal totalBalance = walletContract.getTotalBalance();
+            BigDecimal totalBigDecimal = totalBalance.add(balance);
+            walletContract.setTotalBalance(totalBigDecimal);
+            int updateWalletContractById = memberWalletContractDao.updateById(walletContract);
+            if (updateWalletContractById < 1) {
+                return Result.fail(MessageSourceUtils.getString("member_service_0096"));
+            }
+            
+            //更新合约全仓模式下的订单权益
+            MemberEntity memberEntity = memberDao.selectById(memberId);
+            String symbols = symbol+"/USDT";
+            //ThreadPoolUtils.sendWholeForceClosingPrice(symbols, memberEntity);
+            // 全仓爆仓
+            ThreadPoolUtils.sendWholePrice(memberEntity.getId());
+            
+            //添加币币资金划转历史记录
+            MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
+            memberAccountRecord.setContent("转出至合约"+symbol+"账户");
+            memberAccountRecord.setMemberId(memberId);
+            memberAccountRecord.setAmount(balance.negate());
+            memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
+            memberAccountRecord.setSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue());
+            memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
+            memberAccountMoneyChangeDao.insert(memberAccountRecord);
+
+            //添加合约资金划转历史记录
+            memberAccountRecord.setContent("由币币账户转入至合约"+symbol+"账户");
             memberAccountRecord.setSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue());
             memberAccountRecord.setAmount(balance);
             memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
@@ -328,14 +426,159 @@
         memberAccountMoneyChangeDao.insert(memberAccountRecord);
         return Result.ok(MessageSourceUtils.getString("member_service_0006"));
     }
-
+    
     @Override
-    public Result findWalletContractBySymbol() {
+    @Transactional(rollbackFor = Exception.class)
+    public Result contractTransferToWalletCoins(BigDecimal balance, String symbol) {
         //获取用户ID
         Long memberId = LoginUserUtils.getAppLoginUser().getId();
-        String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
-        MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
-        BigDecimal availableBalance = walletContract.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN);
+        MemberEntity memberEntity = memberDao.selectById(memberId);
+        if (balance.compareTo(BigDecimal.ZERO) <= 0) {
+    		return Result.fail(MessageSourceUtils.getString("member_service_0004"));
+    	}
+        //获取合约当前持仓类型
+        Integer contractPositionType = memberEntity.getContractPositionType();
+        // 总盈利
+        BigDecimal totalProfitOrLess = BigDecimal.ZERO;
+        if(contractPositionType == 2){
+            //获取全仓模式下的所有持仓信息
+            PlatformTradeSettingEntity tradeSetting = cacheSettingUtils.getTradeSetting();
+            List<ContractHoldOrderEntity> holdOrderEntities = contractHoldOrderDao.selectHoldOrderListForWholeByMemberIdAndSymbol(memberEntity.getId(),"");
+            if (CollUtil.isNotEmpty(holdOrderEntities)) {
+                for (ContractHoldOrderEntity holdOrderEntity : holdOrderEntities) {
+                    // 获取最新价
+                    BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(holdOrderEntity.getSymbol())));
+                    BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(holdOrderEntity.getSymbol());
+                    // 单个订单盈利
+                    BigDecimal profitOrLess = BigDecimal.ZERO;
+                    // 开多
+                    if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) {
+                        profitOrLess = newPrice.subtract(holdOrderEntity.getOpeningPrice()).multiply(new BigDecimal(holdOrderEntity.getSymbolCntSale())).multiply(lotNumber);
+                        // 开空
+                    } else {
+                        profitOrLess = holdOrderEntity.getOpeningPrice().subtract(newPrice).multiply(new BigDecimal(holdOrderEntity.getSymbolCntSale())).multiply(lotNumber);
+                    }
+                    if (MemberEntity.IS_PROFIT_Y == memberEntity.getIsProfit()) {
+                        if (profitOrLess.compareTo(BigDecimal.ZERO) > 0) {
+                            profitOrLess = profitOrLess.multiply(BigDecimal.ONE.subtract(tradeSetting.getForceParam()));
+                        } else {
+                            profitOrLess = profitOrLess.multiply(BigDecimal.ONE.add(tradeSetting.getForceParam()));
+                        }
+                    }
+                    totalProfitOrLess = totalProfitOrLess.add(profitOrLess);
+                }
+            }
+        }
+
+    	String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
+    	MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, symbol);
+    	BigDecimal availableBalance = walletContract.getAvailableBalance();
+
+    	BigDecimal canReduce = availableBalance;
+    	//可用减去盈亏
+    	if(totalProfitOrLess.compareTo(BigDecimal.ZERO) < 0){
+            canReduce = availableBalance.add(totalProfitOrLess);
+        }
+    	// 扣币
+    	BigDecimal availableSubtract = canReduce.subtract(balance);
+    	if (availableSubtract.compareTo(BigDecimal.ZERO) < 0) {
+    		return Result.fail(MessageSourceUtils.getString("member_service_0007"));
+    	}
+    	BigDecimal totalBalance = walletContract.getTotalBalance();
+    	BigDecimal totalSubtract = totalBalance.subtract(balance);
+    	
+    	walletContract.setAvailableBalance(availableBalance.subtract(balance));
+    	walletContract.setTotalBalance(totalSubtract);
+    	int updateWalletCoinById = memberWalletContractDao.updateById(walletContract);
+    	if (updateWalletCoinById < 1) {
+    		return Result.fail(MessageSourceUtils.getString("member_service_0096"));
+    	}
+    	// 加币
+    	MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
+    	BigDecimal walletCoinAvailableBalance = walletCoin.getAvailableBalance();
+    	BigDecimal CoinAvailableBalance = walletCoinAvailableBalance.add(balance);
+    	BigDecimal walletCoinTotalBalance = walletCoin.getTotalBalance();
+    	BigDecimal CoinTotalBalance = walletCoinTotalBalance.add(balance);
+    	
+    	walletCoin.setAvailableBalance(CoinAvailableBalance);
+    	walletCoin.setTotalBalance(CoinTotalBalance);
+    	int updateById = memberWalletCoinDao.updateById(walletCoin);
+    	if (updateById < 1) {
+    		return Result.fail(MessageSourceUtils.getString("member_service_0096"));
+    	}
+
+        // 全仓爆仓
+        ThreadPoolUtils.sendWholePrice(memberEntity.getId());
+    	
+    	//添加资金划转历史记录
+    	MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
+    	memberAccountRecord.setContent("合约"+symbol+"账户转出至币币账户");
+    	memberAccountRecord.setMemberId(memberId);
+    	memberAccountRecord.setAmount(balance.negate());
+    	memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
+    	memberAccountRecord.setSymbol(walletCode);
+    	memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
+    	memberAccountMoneyChangeDao.insert(memberAccountRecord);
+    	
+    	//添加资金划转历史记录
+    	memberAccountRecord.setContent("由合约"+symbol+"账户转入");
+    	memberAccountRecord.setSymbol(walletCode);
+    	memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
+    	memberAccountRecord.setAmount(balance);
+    	memberAccountMoneyChangeDao.insert(memberAccountRecord);
+    	return Result.ok(MessageSourceUtils.getString("member_service_0006"));
+    }
+
+    @Override
+    public Result findWalletContractBySymbol(String symbol) {
+        //获取用户ID
+        Long memberId = LoginUserUtils.getAppLoginUser().getId();
+        MemberEntity memberEntity = memberDao.selectById(memberId);
+        //获取合约当前持仓类型
+        Integer contractPositionType = memberEntity.getContractPositionType();
+        // 总盈利
+        BigDecimal totalProfitOrLess = BigDecimal.ZERO;
+        if(contractPositionType == 2){
+            //获取全仓模式下的所有持仓信息
+            PlatformTradeSettingEntity tradeSetting = cacheSettingUtils.getTradeSetting();
+            List<ContractHoldOrderEntity> holdOrderEntities = contractHoldOrderDao.selectHoldOrderListForWholeByMemberIdAndSymbol(memberEntity.getId(),"");
+            if (CollUtil.isNotEmpty(holdOrderEntities)) {
+                for (ContractHoldOrderEntity holdOrderEntity : holdOrderEntities) {
+                    // 获取最新价
+                    BigDecimal newPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(holdOrderEntity.getSymbol())));
+                    BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(holdOrderEntity.getSymbol());
+                    // 单个订单盈利
+                    BigDecimal profitOrLess = BigDecimal.ZERO;
+                    // 开多
+                    if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) {
+                        profitOrLess = newPrice.subtract(holdOrderEntity.getOpeningPrice()).multiply(new BigDecimal(holdOrderEntity.getSymbolCntSale())).multiply(lotNumber);
+                        // 开空
+                    } else {
+                        profitOrLess = holdOrderEntity.getOpeningPrice().subtract(newPrice).multiply(new BigDecimal(holdOrderEntity.getSymbolCntSale())).multiply(lotNumber);
+                    }
+                    if (MemberEntity.IS_PROFIT_Y == memberEntity.getIsProfit()) {
+                        if (profitOrLess.compareTo(BigDecimal.ZERO) > 0) {
+                            profitOrLess = profitOrLess.multiply(BigDecimal.ONE.subtract(tradeSetting.getForceParam()));
+                        } else {
+                            profitOrLess = profitOrLess.multiply(BigDecimal.ONE.add(tradeSetting.getForceParam()));
+                        }
+                    }
+                    totalProfitOrLess = totalProfitOrLess.add(profitOrLess);
+                }
+            }
+        }
+
+        MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, symbol);
+        BigDecimal availableBalance = walletContract.getAvailableBalance();
+        //可用减去盈亏
+        if(totalProfitOrLess.compareTo(BigDecimal.ZERO) < 0){
+            availableBalance = availableBalance.add(totalProfitOrLess);
+        }
+        if(availableBalance.compareTo(BigDecimal.ZERO) > 0){
+            availableBalance = availableBalance.setScale(4, BigDecimal.ROUND_DOWN);
+        }else{
+            availableBalance = BigDecimal.ZERO;
+        }
         return Result.ok(availableBalance);
     }
 
@@ -476,6 +719,99 @@
 
         return Result.ok(MessageSourceUtils.getString("member_service_0006"));
     }
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Result agentTransferToWalletCoins(BigDecimal balance, Integer transfertype, String symbol) {
+    	if (balance.compareTo(BigDecimal.ZERO) <= 0) {
+    		return Result.fail(MessageSourceUtils.getString("member_service_0004"));
+    	}
+    	//获取用户ID
+    	Long memberId = LoginUserUtils.getAppLoginUser().getId();
+    	
+    	// 扣币
+    	String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
+    	MemberWalletAgentEntity walletAgent = memberWalletAgentDao.selectWalletAgentBymIdAndCode(memberId, walletCode);
+    	BigDecimal availableBalance = walletAgent.getAvailableBalance();
+    	BigDecimal totalBalance = walletAgent.getTotalBalance();
+    	
+    	BigDecimal available = availableBalance.subtract(balance);
+    	if (available.compareTo(BigDecimal.ZERO) < 0) {
+    		return Result.fail(MessageSourceUtils.getString("member_service_0008"));
+    	}
+    	BigDecimal total = totalBalance.subtract(balance);
+    	if (total.compareTo(BigDecimal.ZERO) < 0) {
+    		return Result.fail(MessageSourceUtils.getString("member_service_0008"));
+    	}
+    	
+    	walletAgent.setAvailableBalance(available);
+    	walletAgent.setTotalBalance(total);
+    	
+    	int i = memberWalletAgentDao.updateById(walletAgent);
+    	if (i < 1) {
+    		return Result.fail(MessageSourceUtils.getString("member_service_0095"));
+    	}
+    	//添加资金划转历史记录
+    	MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
+    	//代理账户转币币
+    	if (MemberAccountMoneyChange.TYPE_WALLET_COIN.equals(transfertype)) {
+    		MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
+    		BigDecimal walletCoinAvailableBalance = walletCoin.getAvailableBalance();
+    		BigDecimal walletCoinTotalBalance = walletCoin.getTotalBalance();
+    		
+    		walletCoin.setAvailableBalance(walletCoinAvailableBalance.add(balance));
+    		walletCoin.setTotalBalance(walletCoinTotalBalance.add(balance));
+    		
+    		int updateById = memberWalletCoinDao.updateById(walletCoin);
+    		if (updateById < 1) {
+    			return Result.fail(MessageSourceUtils.getString("member_service_0095"));
+    		}
+    		//添加资金划转历史记录
+    		memberAccountRecord.setMemberId(memberId);
+    		memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
+    		memberAccountRecord.setSymbol(walletCode);
+    		memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMAGENT.getValue());
+    		memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
+    		memberAccountRecord.setAmount(balance);
+    		memberAccountMoneyChangeDao.insert(memberAccountRecord);
+    		memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOWALLETCOIN.getValue());
+    		
+    	} else if (MemberAccountMoneyChange.TYPE_WALLET_CONTRACT.equals(transfertype)) {
+    		//代理账户转合约
+    		MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, symbol);
+    		BigDecimal walletContractAvailableBalance = walletContract.getAvailableBalance();
+    		BigDecimal walletContractTotalBalance = walletContract.getTotalBalance();
+    		
+    		walletContract.setAvailableBalance(walletContractAvailableBalance.add(balance));
+    		walletContract.setTotalBalance(walletContractTotalBalance.add(balance));
+    		
+    		int updateById = memberWalletContractDao.updateById(walletContract);
+    		if (updateById < 1) {
+    			return Result.fail(MessageSourceUtils.getString("member_service_0095"));
+    		}
+    		
+    		//更新合约全仓模式下的订单权益
+            MemberEntity memberEntity = memberDao.selectById(memberId);
+            String symbols = symbol+"/USDT";
+            //ThreadPoolUtils.sendWholeForceClosingPrice(symbols, memberEntity);
+            // 全仓爆仓
+            ThreadPoolUtils.sendWholePrice(memberEntity.getId());
+    		
+    		//添加资金划转历史记录
+    		memberAccountRecord.setMemberId(memberId);
+    		memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
+    		memberAccountRecord.setSymbol(walletCode);
+    		memberAccountRecord.setContent("由代理账户转入合约"+symbol+"账户");
+    		memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
+    		memberAccountRecord.setAmount(balance);
+    		memberAccountMoneyChangeDao.insert(memberAccountRecord);
+    		memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOCONTRACT.getValue());
+    	}
+    	memberAccountRecord.setAmount(balance.negate());
+    	memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_AGENT);
+    	memberAccountMoneyChangeDao.insert(memberAccountRecord);
+    	
+    	return Result.ok(MessageSourceUtils.getString("member_service_0006"));
+    }
 
     @Override
     public Result findWalletAgentBySymbol() {
@@ -497,29 +833,330 @@
     }
 
 	@Override
-	public Result getWalletAgentIntoRecords() {
+	public Result getWalletAgentIntoRecords(RecordsPageDto recordsPageDto) {
 	        //获取用户ID
 	        Long memberId = LoginUserUtils.getAppLoginUser().getId();
-
-	        List<MemberAccountMoneyChange> contractRecordList =
-	                memberAccountMoneyChangeDao.selectWalletAgentIntoRecordsByMemIdTypeSymbol(memberId);
-
-	        MemberAgentIntoInfoVo memberAgentIntoInfoVo = new MemberAgentIntoInfoVo();
+	        
+	        Page<OrderCoinsDealEntity> page = new Page<>(recordsPageDto.getPageNum(), recordsPageDto.getPageSize());
+	        MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
+	        memberAccountMoneyChange.setMemberId(memberId);
+	        IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.selectWalletAgentIntoRecordsByMemIdTypeSymbol(page, memberAccountMoneyChange);
+	        List<MemberAccountMoneyChange> contractRecordList = list.getRecords();
 	        List<MemberAccountMoneyChangeInfoVo> arrayList = new ArrayList<>();
-	        if (ObjectUtil.isNotNull(contractRecordList)) {
-	            for (MemberAccountMoneyChange memberAccountMoneyChange : contractRecordList) {
-	                MemberAccountMoneyChangeInfoVo memberAccountMoneyChangeInfoVo = new MemberAccountMoneyChangeInfoVo();
-	                memberAccountMoneyChangeInfoVo.setAmount(memberAccountMoneyChange.getAmount());
-	                memberAccountMoneyChangeInfoVo.setContent(memberAccountMoneyChange.getContent());
-	                memberAccountMoneyChangeInfoVo.setStatus(memberAccountMoneyChange.getStatus());
-	                memberAccountMoneyChangeInfoVo.setSymbol(memberAccountMoneyChange.getSymbol());
-	                memberAccountMoneyChangeInfoVo.setType(memberAccountMoneyChange.getType());
-	                memberAccountMoneyChangeInfoVo.setUpdateTime(memberAccountMoneyChange.getUpdateTime());
-	                arrayList.add(memberAccountMoneyChangeInfoVo);
-	            }
+	        if(CollUtil.isNotEmpty(contractRecordList)) {
+	        	if (ObjectUtil.isNotNull(contractRecordList)) {
+	        		for (MemberAccountMoneyChange memberAccountMoneyChanges : contractRecordList) {
+	        			MemberAccountMoneyChangeInfoVo memberAccountMoneyChangeInfoVo = new MemberAccountMoneyChangeInfoVo();
+	        			memberAccountMoneyChangeInfoVo.setAmount(memberAccountMoneyChanges.getAmount());
+	        			memberAccountMoneyChangeInfoVo.setContent(memberAccountMoneyChanges.getContent());
+	        			memberAccountMoneyChangeInfoVo.setStatus(memberAccountMoneyChanges.getStatus());
+	        			memberAccountMoneyChangeInfoVo.setSymbol(memberAccountMoneyChanges.getSymbol());
+	        			memberAccountMoneyChangeInfoVo.setType(memberAccountMoneyChanges.getType());
+	        			memberAccountMoneyChangeInfoVo.setUpdateTime(memberAccountMoneyChanges.getUpdateTime());
+	        			arrayList.add(memberAccountMoneyChangeInfoVo);
+	        		}
+	        	}
 	        }
-	        memberAgentIntoInfoVo.setMemberAccountMoneyChangeInfoVo(arrayList);
-	        return Result.ok(memberAgentIntoInfoVo);
+	        Page<MemberAccountMoneyChangeInfoVo> pageEntityToPageVo = new Page<>();
+	        pageEntityToPageVo.setRecords(arrayList);
+	        
+	        return Result.ok(pageEntityToPageVo);
 	}
 
+	@Override
+	public Result getAllWalletCoin() {
+		//获取【币币】
+        Long memberId = LoginUserUtils.getAppLoginUser().getId();
+//        Long memberId =446L;
+        PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
+        BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
+        AllWalletCoinVo allWalletCoinVo = new AllWalletCoinVo();
+
+        BigDecimal totalUsdts = BigDecimal.ZERO;
+        if (!StrUtil.isEmpty(memberId.toString())) {
+
+            List<MemberWalletCoinEntity> memberWalletCoinlist = memberWalletCoinDao.selectMemberWalletCoinsByMemberId(memberId);
+            List<MemberWalletCoinInfoVo> memberWalletCoinInfoVolist = new ArrayList<MemberWalletCoinInfoVo>();
+
+            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 (CollUtil.isNotEmpty(memberWalletCoinInfoVolist)) {
+                for (MemberWalletCoinInfoVo walletCoin : memberWalletCoinInfoVolist) {
+                    if (MemberWalletCoinEnum.WALLETCOINCODE.getValue().equals(walletCoin.getWalletCode())) {
+                        BigDecimal totalUsdt = BigDecimal.ZERO;
+                        totalUsdt = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
+                        totalUsdts = totalUsdts.add(totalUsdt);
+                    } else {
+                        BigDecimal amount = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
+                        // 获取最新价
+                        BigDecimal closePrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(walletCoin.getWalletCode()+"/USDT")));
+                        BigDecimal totalUsdt = BigDecimal.ZERO;
+                        totalUsdt = totalUsdt.add(amount.multiply(closePrice));
+                        totalUsdts = totalUsdts.add(totalUsdt);
+                    }
+                }
+            }
+        } 
+        allWalletCoinVo.setWalletUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN));
+		//获取【合约】
+        String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
+        MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
+        if (ObjectUtil.isEmpty(walletContract)) {
+            return Result.fail(MessageSourceUtils.getString("member_service_0001"));
+        }
+        allWalletCoinVo.setContractUsdt(walletContract.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
+        totalUsdts = totalUsdts.add(walletContract.getTotalBalance());
+		//获取【代理】
+        MemberWalletAgentEntity walletAgent = memberWalletAgentDao.selectWalletAgentBymIdAndCode(memberId, walletCode);
+        BigDecimal availableBalance = walletAgent.getAvailableBalance();
+        allWalletCoinVo.setAgentUsdt(availableBalance.setScale(4, BigDecimal.ROUND_DOWN));
+        totalUsdts = totalUsdts.add(availableBalance);
+        
+        allWalletCoinVo.setTotalUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN));
+        allWalletCoinVo.setTotalCny(totalUsdts.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
+        return Result.ok(allWalletCoinVo);
+	}
+
+	@Override
+	public Result getContractSymbolList() {
+		//获取用户ID
+        Long memberId = LoginUserUtils.getAppLoginUser().getId();
+        List<ContractSymbolListVo> list = memberWalletContractDao.findContractSymbolListBymemberId(memberId);
+        if(CollUtil.isNotEmpty(list)) {
+        	for(ContractSymbolListVo contractSymbolListVo : list) {
+        		String walletCode = contractSymbolListVo.getWalletCode();
+        		walletCode = walletCode+"/USDT";
+        		contractSymbolListVo.setWalletCode(walletCode);
+        	}
+        }
+		return Result.ok(list);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public Result contractInTransfer(BigDecimal balance, String symbolIn, String symbolOut) {
+		//获取用户ID
+        Long memberId = LoginUserUtils.getAppLoginUser().getId();
+        //转入转出不能是同一账户
+        if(symbolIn.equals(symbolOut)) {
+        	return Result.fail(MessageSourceUtils.getString("member_service_0098"));
+        }
+        if (balance.compareTo(BigDecimal.ZERO) <= 0) {
+    		return Result.fail(MessageSourceUtils.getString("member_service_0004"));
+    	}
+        
+        MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, symbolOut);
+    	BigDecimal availableBalance = walletContract.getAvailableBalance();
+    	// 扣币
+    	BigDecimal availableSubtract = availableBalance.subtract(balance);
+    	if (availableSubtract.compareTo(BigDecimal.ZERO) < 0) {
+    		return Result.fail(MessageSourceUtils.getString("member_service_0007"));
+    	}
+    	BigDecimal totalBalance = walletContract.getTotalBalance();
+    	BigDecimal totalSubtract = totalBalance.subtract(balance);
+    	
+    	walletContract.setAvailableBalance(availableSubtract);
+    	walletContract.setTotalBalance(totalSubtract);
+    	int updateWalletCoinById = memberWalletContractDao.updateById(walletContract);
+    	if (updateWalletCoinById < 1) {
+    		return Result.fail(MessageSourceUtils.getString("member_service_0096"));
+    	}
+    	
+    	//更新合约全仓模式下的订单权益
+        MemberEntity memberEntity = memberDao.selectById(memberId);
+        String symbols = symbolOut+"/USDT";
+        //ThreadPoolUtils.sendWholeForceClosingPrice(symbols, memberEntity);
+        // 全仓爆仓
+        ThreadPoolUtils.sendWholePrice(memberEntity.getId());
+        
+        // 加币
+        // 查询合约账户
+        MemberWalletContractEntity walletContractIn = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, symbolIn);
+        BigDecimal availableBalanceIn = walletContractIn.getAvailableBalance();
+        BigDecimal addIn = availableBalanceIn.add(balance);
+        walletContractIn.setAvailableBalance(addIn);
+        BigDecimal totalBalanceIn = walletContractIn.getTotalBalance();
+        BigDecimal totalBigDecimalIn = totalBalanceIn.add(balance);
+        walletContractIn.setTotalBalance(totalBigDecimalIn);
+        int updateWalletContractById = memberWalletContractDao.updateById(walletContractIn);
+        if (updateWalletContractById < 1) {
+            return Result.fail(MessageSourceUtils.getString("member_service_0096"));
+        }
+        
+        //更新合约全仓模式下的订单权益
+        String symbolIns = symbolIn+"/USDT";
+        //ThreadPoolUtils.sendWholeForceClosingPrice(symbolIns, memberEntity);
+        // 全仓爆仓
+        ThreadPoolUtils.sendWholePrice(memberEntity.getId());
+        
+        //添加币币资金划转历史记录
+        MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
+        memberAccountRecord.setContent("转出至合约"+symbolIn+"账户");
+        memberAccountRecord.setMemberId(memberId);
+        memberAccountRecord.setAmount(balance.negate());
+        memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
+        memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
+        memberAccountMoneyChangeDao.insert(memberAccountRecord);
+
+        //添加合约资金划转历史记录
+        memberAccountRecord.setContent("由合约"+symbolOut+"账户转入至合约"+symbolIn+"账户");
+        memberAccountRecord.setAmount(balance);
+        memberAccountMoneyChangeDao.insert(memberAccountRecord);
+        
+        return Result.ok(MessageSourceUtils.getString("member_service_0006"));
+	}
+
+	@Override
+	public Result coinInList(@Valid CoinInListDto coinInListDto) {
+		//获取用户ID
+        Long memberId = LoginUserUtils.getAppLoginUser().getId();
+        int type = coinInListDto.getType();
+        //充币记录
+        if(type == 1) {
+        	Page<MemberCoinChargeEntity> page = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
+        	MemberCoinChargeEntity memberCoinChargeEntity = new MemberCoinChargeEntity();
+        	memberCoinChargeEntity.setMemberId(memberId);
+    		IPage<MemberCoinChargeEntity> memberCoinCharge = memberCoinChargeDao.findMemberCoinChargeInPage(page, memberCoinChargeEntity);
+    		List<MemberCoinChargeEntity> records = memberCoinCharge.getRecords();
+
+    		Page<CoinInListVo> responsePage = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
+    		if(CollUtil.isNotEmpty(records)) {
+    			ArrayList<CoinInListVo> arrayList = new ArrayList<>();
+    			for(MemberCoinChargeEntity memberCoinChargeEntitys : records) {
+    				CoinInListVo coinInListVo = new CoinInListVo();
+    				coinInListVo.setSymbol(memberCoinChargeEntitys.getSymbol());
+    				coinInListVo.setAmount(memberCoinChargeEntitys.getAmount().toPlainString());
+    				coinInListVo.setContent("充币");
+    				coinInListVo.setStatus(memberCoinChargeEntitys.getStatus());
+    				coinInListVo.setUpdateTime(memberCoinChargeEntitys.getUpdateTime());
+    				arrayList.add(coinInListVo);
+    			}
+    			responsePage.setRecords(arrayList);
+    		}
+    		return Result.ok(responsePage);
+        }
+        //提币记录
+        if(type == 2) {
+        	Page<MemberCoinWithdrawEntity> page = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
+        	MemberCoinWithdrawEntity memberCoinWithdrawEntity = new MemberCoinWithdrawEntity();
+        	memberCoinWithdrawEntity.setMemberId(memberId);
+    		IPage<MemberCoinWithdrawEntity> memberCoinWithdraw = memberCoinWithdrawDao.findMemberCoinWithdrawInPage(page, memberCoinWithdrawEntity);
+    		List<MemberCoinWithdrawEntity> records = memberCoinWithdraw.getRecords();
+    		
+    		Page<CoinInListVo> responsePage = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
+    		if(CollUtil.isNotEmpty(records)) {
+    			ArrayList<CoinInListVo> arrayList = new ArrayList<>();
+    			for(MemberCoinWithdrawEntity memberCoinWithdrawEntitys : records) {
+    				CoinInListVo coinInListVo = new CoinInListVo();
+    				coinInListVo.setSymbol(memberCoinWithdrawEntitys.getSymbol());
+    				coinInListVo.setAmount(memberCoinWithdrawEntitys.getAmount().toPlainString());
+    				coinInListVo.setContent("提币");
+    				int status = memberCoinWithdrawEntitys.getStatus();
+    				int statusOut = 0;
+    				if(status == 1) {
+    					statusOut = 0;
+    				}
+    				if(status == 2) {
+    					statusOut = 1;
+    				}
+    				if(status == 3) {
+    					statusOut = 2;
+    				}
+    				coinInListVo.setStatus(statusOut);
+    				coinInListVo.setUpdateTime(memberCoinWithdrawEntitys.getUpdateTime());
+    				coinInListVo.setIsInside(memberCoinWithdrawEntitys.getIsInside());
+    				arrayList.add(coinInListVo);
+    			}
+    			responsePage.setRecords(arrayList);
+    		}
+    		return Result.ok(responsePage);
+        }
+        //划转记录
+        if(type == 3) {
+        	Page<MemberAccountMoneyChange> page = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
+        	MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
+        	memberAccountMoneyChange.setMemberId(memberId);
+        	IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.coinInList(page, memberAccountMoneyChange);
+        	List<MemberAccountMoneyChange> records = list.getRecords();
+        	
+        	Page<CoinInListVo> responsePage = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
+    		if(CollUtil.isNotEmpty(records)) {
+    			ArrayList<CoinInListVo> arrayList = new ArrayList<>();
+    			for(MemberAccountMoneyChange memberAccountMoneyChanges : records) {
+    				CoinInListVo coinInListVo = new CoinInListVo();
+    				coinInListVo.setSymbol(memberAccountMoneyChanges.getSymbol());
+    				coinInListVo.setAmount(memberAccountMoneyChanges.getAmount().toPlainString());
+    				coinInListVo.setContent(memberAccountMoneyChanges.getContent());
+    				coinInListVo.setStatus(memberAccountMoneyChanges.getStatus());
+    				coinInListVo.setUpdateTime(memberAccountMoneyChanges.getUpdateTime());
+    				arrayList.add(coinInListVo);
+    			}
+    			responsePage.setRecords(arrayList);
+    		}
+    		return Result.ok(responsePage);
+        }
+        //其他记录
+        if(type == 4) {
+        	Page<OrderCoinsDealEntity> page = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
+        	MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
+        	memberAccountMoneyChange.setMemberId(memberId);
+        	IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.selectWalletAgentIntoRecordsByMemIdTypeSymbol(page, memberAccountMoneyChange);
+        	List<MemberAccountMoneyChange> records = list.getRecords();
+        	
+        	Page<CoinInListVo> responsePage = new Page<>(coinInListDto.getPageNum(), coinInListDto.getPageSize());
+    		if(CollUtil.isNotEmpty(records)) {
+    			ArrayList<CoinInListVo> arrayList = new ArrayList<>();
+    			for(MemberAccountMoneyChange memberAccountMoneyChanges : records) {
+    				CoinInListVo coinInListVo = new CoinInListVo();
+    				coinInListVo.setSymbol(memberAccountMoneyChanges.getSymbol());
+    				coinInListVo.setAmount(memberAccountMoneyChanges.getAmount().toPlainString());
+    				coinInListVo.setContent(memberAccountMoneyChanges.getContent());
+    				coinInListVo.setStatus(memberAccountMoneyChanges.getStatus());
+    				coinInListVo.setUpdateTime(memberAccountMoneyChanges.getUpdateTime());
+    				arrayList.add(coinInListVo);
+    			}
+    			responsePage.setRecords(arrayList);
+    		}
+    		return Result.ok(responsePage);
+        }
+        
+        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