From c119feb821bdb1e6ef407f55056173f752c01c32 Mon Sep 17 00:00:00 2001
From: zainali5120 <512061637@qq.com>
Date: Thu, 16 Jul 2020 17:11:20 +0800
Subject: [PATCH] 订单止盈止损类提交

---
 src/main/java/com/xcong/excoin/modules/coin/service/impl/CoinServiceImpl.java |  935 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 467 insertions(+), 468 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 5d0fd81..164bde5 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
@@ -5,18 +5,24 @@
 import java.util.List;
 import javax.annotation.Resource;
 
+import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xcong.excoin.common.LoginUserUtils;
 import com.xcong.excoin.common.enumerates.CoinTypeEnum;
 import com.xcong.excoin.common.enumerates.MemberWalletCoinEnum;
 import com.xcong.excoin.common.response.Result;
 import com.xcong.excoin.modules.coin.dao.MemberAccountMoneyChangeDao;
-import com.xcong.excoin.modules.coin.dao.platform.CnyUsdtExchangeDao;
-import com.xcong.excoin.modules.coin.entity.CnyUsdtExchange;
 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.RecordsPageDto;
 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;
@@ -28,483 +34,476 @@
 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;
 
 @Service
-public class CoinServiceImpl extends ServiceImpl<MemberWalletCoinDao, MemberWalletCoinEntity> implements CoinService{
+public class CoinServiceImpl extends ServiceImpl<MemberWalletCoinDao, MemberWalletCoinEntity> implements CoinService {
 
-	//@Resource
-	//SymbolsService symbolsService;
-	@Resource
-	CnyUsdtExchangeDao cnyUsdtExchangeDao;
-	@Resource
-	MemberWalletCoinDao memberWalletCoinDao;
-	@Resource
-	MemberWalletContractDao memberWalletContractDao;
-	@Resource
-	MemberAccountMoneyChangeDao memberAccountMoneyChangeDao;
-	@Resource
-	MemberWalletAgentDao memberWalletAgentDao;
-	
-	
-	@Override
-	public Result getWalletCoin() {
-			//获取用户ID
-			Long memberId = LoginUserUtils.getAppLoginUser().getId();
-			CnyUsdtExchange cnyUsdtExchange =cnyUsdtExchangeDao.getCNYAndUSDTOne();
-			BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
-			
-			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());
-						memberWalletCoinInfoVo.setFrozenBalance(memberWalletCoinEntity.getFrozenBalance());
-						memberWalletCoinInfoVo.setMemberId(memberWalletCoinEntity.getMemberId());
-						memberWalletCoinInfoVo.setTotalBalance(memberWalletCoinEntity.getTotalBalance());
-						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);
-							BigDecimal totalCny = totalUsdt.multiply(cnyUsdt);
-							walletCoin.setTotalBalance(totalCny.setScale(4, BigDecimal.ROUND_DOWN));
-						}else {
-							BigDecimal amount = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
-							BigDecimal closePrice = new BigDecimal("10.0000");
-							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).setScale(4, BigDecimal.ROUND_DOWN));
-						}
-					}
-				}
-				MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo();
-				memberWalletCoinVo.setTotalUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN));
-				memberWalletCoinVo.setTotalCny(totalUsdts.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
-				memberWalletCoinVo.setMemberWalletCoinInfoVo(memberWalletCoinInfoVolist);
-				return Result.ok(memberWalletCoinVo);
-			}else {
-				List<MemberWalletCoinInfoVo> memberWalletCoinlist = new ArrayList<MemberWalletCoinInfoVo>();
-				MemberWalletCoinInfoVo coin = new MemberWalletCoinInfoVo();
-				coin.setAvailableBalance(BigDecimal.ZERO);
-				coin.setTotalBalance(BigDecimal.ZERO);
-				coin.setFrozenBalance(BigDecimal.ZERO);
-				coin.setWalletCode(CoinTypeEnum.BTC.toString());
-				memberWalletCoinlist.add(coin);
-				coin.setWalletCode(CoinTypeEnum.ETH.toString());
-				memberWalletCoinlist.add(coin);
-				coin.setWalletCode(CoinTypeEnum.LTC.toString());
-				memberWalletCoinlist.add(coin);
-				coin.setWalletCode(CoinTypeEnum.BCH.toString());
-				memberWalletCoinlist.add(coin);
-				coin.setWalletCode(CoinTypeEnum.USDT.toString());
-				memberWalletCoinlist.add(coin);
-				coin.setWalletCode(CoinTypeEnum.EOS.toString());
-				memberWalletCoinlist.add(coin);
-				coin.setWalletCode(CoinTypeEnum.XRP.toString());
-				memberWalletCoinlist.add(coin);
-				coin.setWalletCode(CoinTypeEnum.ETC.toString());
-				memberWalletCoinlist.add(coin);
-				
-				MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo();
-				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);
-			}
-	}
+    //@Resource
+    //SymbolsService symbolsService;
+    @Resource
+    PlatformCnyUsdtExchangeDao cnyUsdtExchangeDao;
+    @Resource
+    MemberWalletCoinDao memberWalletCoinDao;
+    @Resource
+    MemberWalletContractDao memberWalletContractDao;
+    @Resource
+    MemberAccountMoneyChangeDao memberAccountMoneyChangeDao;
+    @Resource
+    MemberWalletAgentDao memberWalletAgentDao;
+    @Resource
+    RedisUtils redisUtils;
+
+
+    @Override
+    public Result getWalletCoin() {
+        //获取用户ID
+        Long memberId = LoginUserUtils.getAppLoginUser().getId();
+        PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
+        BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
+
+        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);
+                        BigDecimal totalCny = totalUsdt.multiply(cnyUsdt);
+                        walletCoin.setTotalBalance(totalCny);
+                    } 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();
+            memberWalletCoinVo.setTotalUsdt(totalUsdts.setScale(4, BigDecimal.ROUND_DOWN));
+            memberWalletCoinVo.setTotalCny(totalUsdts.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
+            memberWalletCoinVo.setMemberWalletCoinInfoVo(memberWalletCoinInfoVolist);
+            return Result.ok(memberWalletCoinVo);
+        } else {
+            List<MemberWalletCoinInfoVo> memberWalletCoinlist = new ArrayList<MemberWalletCoinInfoVo>();
+            MemberWalletCoinInfoVo coin = new MemberWalletCoinInfoVo();
+            coin.setAvailableBalance(BigDecimal.ZERO);
+            coin.setTotalBalance(BigDecimal.ZERO);
+            coin.setFrozenBalance(BigDecimal.ZERO);
+            coin.setWalletCode(CoinTypeEnum.BTC.toString());
+            memberWalletCoinlist.add(coin);
+            coin.setWalletCode(CoinTypeEnum.ETH.toString());
+            memberWalletCoinlist.add(coin);
+            coin.setWalletCode(CoinTypeEnum.LTC.toString());
+            memberWalletCoinlist.add(coin);
+            coin.setWalletCode(CoinTypeEnum.BCH.toString());
+            memberWalletCoinlist.add(coin);
+            coin.setWalletCode(CoinTypeEnum.USDT.toString());
+            memberWalletCoinlist.add(coin);
+            coin.setWalletCode(CoinTypeEnum.EOS.toString());
+            memberWalletCoinlist.add(coin);
+            coin.setWalletCode(CoinTypeEnum.XRP.toString());
+            memberWalletCoinlist.add(coin);
+            coin.setWalletCode(CoinTypeEnum.ETC.toString());
+            memberWalletCoinlist.add(coin);
+
+            MemberWalletCoinVo memberWalletCoinVo = new MemberWalletCoinVo();
+            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);
+        }
+    }
+
+    @Override
+    public Result getWalletCoinBySymbol(String symbol) {
+        //获取用户ID
+        Long memberId = LoginUserUtils.getAppLoginUser().getId();
+        MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
+        MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo();
+        memberWalletCoinInfoVo.setFrozenBalance(walletCoin.getFrozenBalance());
+        memberWalletCoinInfoVo.setAvailableBalance(walletCoin.getAvailableBalance());
+        memberWalletCoinInfoVo.setMemberId(memberId);
+        memberWalletCoinInfoVo.setWalletCode(symbol);
+        if (!StrUtil.isEmpty(memberId.toString())) {
+            PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
+            BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
+            BigDecimal total = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
+
+            if (MemberWalletCoinEnum.WALLETCOINCODE.getValue().equals(walletCoin.getWalletCode())) {
+                memberWalletCoinInfoVo.setTotalBalance(total.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
+
+            } else {
+            	BigDecimal closePrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol+"/USDT")));
+                //Double closePrice = symbolsService.getCloseSymbolsBySymbolsName(wallet.getCode()+"/USDT");
+                memberWalletCoinInfoVo.setTotalBalance(total.multiply(closePrice).multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
+            }
+        }
+        return Result.ok(memberWalletCoinInfoVo);
+    }
+
+    @Override
+    public Result getWalletContractById() {
+
+        //获取用户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"));
+        }
+
+        MemberWalletContractInfoVo memberWalletContractInfoVo = new MemberWalletContractInfoVo();
+        memberWalletContractInfoVo.setFrozenBalance(walletContract.getFrozenBalance().setScale(4, BigDecimal.ROUND_DOWN));
+        memberWalletContractInfoVo.setAvailableBalance(walletContract.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
+        memberWalletContractInfoVo.setTotalBalance(walletContract.getTotalBalance().setScale(4, BigDecimal.ROUND_DOWN));
+        memberWalletContractInfoVo.setTotalRMBBalance(walletContract.getTotalBalance().multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
+
+        return Result.ok(memberWalletContractInfoVo);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Result coinWalletTransferToContract(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, walletCode);
+            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"));
+            }
+            //添加币币资金划转历史记录
+            MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
+            memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOCONTRACT.getValue());
+            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(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 contractTransferToWalletCoin(BigDecimal balance, 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();
+        MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
+        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"));
+        }
+        // 加币
+        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"));
+        }
+
+        //添加资金划转历史记录
+        MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
+        memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOWALLETCOIN.getValue());
+        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(MemberWalletCoinEnum.CONTENTFROMCONTRACT.getValue());
+        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() {
+        //获取用户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);
+        return Result.ok(availableBalance);
+    }
+
+    @Override
+    public Result findWalletCoinBySymbol(String symbol) {
+        //获取用户ID
+        Long memberId = LoginUserUtils.getAppLoginUser().getId();
+
+        MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
+        BigDecimal availableBalance = walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN);
+        return Result.ok(availableBalance);
+    }
+
+    @Override
+    public Result getWalletCoinRecords(RecordsPageDto recordsPageDto) {
+        //获取用户ID
+        Long memberId = LoginUserUtils.getAppLoginUser().getId();
+        
+        Page<OrderCoinsDealEntity> page = new Page<>(recordsPageDto.getPageNum(), recordsPageDto.getPageSize());
+        MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
+        memberAccountMoneyChange.setMemberId(memberId);
+        IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.selectWalletCoinRecordsInPage(page, memberAccountMoneyChange);
+        Page<MemberAccountMoneyChangeInfoVo> pageEntityToPageVo = MemberAccountMoneyChangeMapper.INSTANCE.pageEntityToPageVo(list);
+        
+        return Result.ok(pageEntityToPageVo);
+    }
+
+    @Override
+    public Result getWalletContractRecords(RecordsPageDto recordsPageDto) {
+        //获取用户ID
+        Long memberId = LoginUserUtils.getAppLoginUser().getId();
+        
+        Page<OrderCoinsDealEntity> page = new Page<>(recordsPageDto.getPageNum(), recordsPageDto.getPageSize());
+        MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
+        memberAccountMoneyChange.setMemberId(memberId);
+        IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.selectWalletContractRecordsInPage(page, memberAccountMoneyChange);
+        Page<MemberAccountMoneyChangeInfoVo> pageEntityToPageVo = MemberAccountMoneyChangeMapper.INSTANCE.pageEntityToPageVo(list);
+        return Result.ok(pageEntityToPageVo);
+    }
+
+    @Override
+    public Result getWalletAgentRecords(RecordsPageDto recordsPageDto) {
+        //获取用户ID
+        Long memberId = LoginUserUtils.getAppLoginUser().getId();
+        
+        Page<OrderCoinsDealEntity> page = new Page<>(recordsPageDto.getPageNum(), recordsPageDto.getPageSize());
+        MemberAccountMoneyChange memberAccountMoneyChange = new MemberAccountMoneyChange();
+        memberAccountMoneyChange.setMemberId(memberId);
+        IPage<MemberAccountMoneyChange> list = memberAccountMoneyChangeDao.selectWalletAgentRecordsInPage(page, memberAccountMoneyChange);
+        Page<MemberAccountMoneyChangeInfoVo> pageEntityToPageVo = MemberAccountMoneyChangeMapper.INSTANCE.pageEntityToPageVo(list);
+        
+        return Result.ok(pageEntityToPageVo);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Result agentTransferToWalletCoin(BigDecimal balance, Integer transfertype) {
+        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, walletCode);
+            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"));
+            }
+
+            //添加资金划转历史记录
+            memberAccountRecord.setMemberId(memberId);
+            memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
+            memberAccountRecord.setSymbol(walletCode);
+            memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMAGENT.getValue());
+            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() {
+        //获取用户ID
+        Long memberId = LoginUserUtils.getAppLoginUser().getId();
+        String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
+
+        MemberWalletAgentEntity walletAgent = memberWalletAgentDao.selectWalletAgentBymIdAndCode(memberId, walletCode);
+        BigDecimal availableBalance = walletAgent.getAvailableBalance();
+
+        PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
+        BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
+        BigDecimal multiply = availableBalance.multiply(cnyUsdt);
+
+        MemberWalletAgentInfoVo memberWalletAgentInfoVo = new MemberWalletAgentInfoVo();
+        memberWalletAgentInfoVo.setTotalBalance(availableBalance.setScale(4, BigDecimal.ROUND_DOWN));
+        memberWalletAgentInfoVo.setTotalRMBBalance(multiply.setScale(4, BigDecimal.ROUND_DOWN));
+        return Result.ok(memberWalletAgentInfoVo);
+    }
 
 	@Override
-	public Result getWalletCoinBySymbol(String symbol) {
-			//获取用户ID
-			Long memberId = LoginUserUtils.getAppLoginUser().getId();
-			MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId,symbol);
-			MemberWalletCoinInfoVo memberWalletCoinInfoVo = new MemberWalletCoinInfoVo();
-			memberWalletCoinInfoVo.setFrozenBalance(walletCoin.getFrozenBalance());
-			memberWalletCoinInfoVo.setAvailableBalance(walletCoin.getAvailableBalance());
-			memberWalletCoinInfoVo.setMemberId(memberId);
-			memberWalletCoinInfoVo.setWalletCode(symbol);
-			if(!StrUtil.isEmpty(memberId.toString())) {
-				CnyUsdtExchange cnyUsdtExchange =cnyUsdtExchangeDao.getCNYAndUSDTOne();
-				BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
-				BigDecimal total = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
-				
-				if(MemberWalletCoinEnum.WALLETCOINCODE.getValue().equals(walletCoin.getWalletCode())) {
-					memberWalletCoinInfoVo.setTotalBalance(total.multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
-					
-				}else {
-					BigDecimal closePrice = new BigDecimal("10.0000");
-					//Double closePrice = symbolsService.getCloseSymbolsBySymbolsName(wallet.getCode()+"/USDT");
-					memberWalletCoinInfoVo.setTotalBalance(total.multiply(closePrice).multiply(cnyUsdt).setScale(4, BigDecimal.ROUND_DOWN));
-				}
-			}
-			return Result.ok(memberWalletCoinInfoVo);
-	}
+	public Result getWalletAgentIntoRecords() {
+	        //获取用户ID
+	        Long memberId = LoginUserUtils.getAppLoginUser().getId();
 
-	@Override
-	public Result getWalletContractById() {
-		
-			//获取用户ID
-			Long memberId = LoginUserUtils.getAppLoginUser().getId();
-			
-			CnyUsdtExchange 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("50.000");
-			//获取总付款
-			BigDecimal totalPayment = new BigDecimal("50.000");
-			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));
-			
-			return Result.ok(memberWalletContractInfoVo);
-	}
+	        List<MemberAccountMoneyChange> contractRecordList =
+	                memberAccountMoneyChangeDao.selectWalletAgentIntoRecordsByMemIdTypeSymbol(memberId);
 
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public Result coinWalletTransferToContract(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);
-				if(subtract.compareTo(BigDecimal.ZERO)<0) {
-					return Result.fail(MessageSourceUtils.getString("member_service_0005"));
-				}
-				walletCoin.setAvailableBalance(total.setScale(4, BigDecimal.ROUND_DOWN));
-				walletCoin.setTotalBalance(subtract.setScale(4, BigDecimal.ROUND_DOWN));
-				int updateWalletCoinById = memberWalletCoinDao.updateById(walletCoin);
-				if(updateWalletCoinById < 1) {
-					return Result.fail(MessageSourceUtils.getString("member_service_0096"));
-				}
-				// 加币
-				// 查询合约账户
-				MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
-				BigDecimal availableBalance = walletContract.getAvailableBalance();
-				BigDecimal add = availableBalance.add(balance);
-				walletContract.setAvailableBalance(add.setScale(4, BigDecimal.ROUND_DOWN));
-				BigDecimal totalBalance = walletContract.getTotalBalance();
-				BigDecimal totalBigDecimal = totalBalance.add(balance);
-				walletContract.setTotalBalance(totalBigDecimal.setScale(4, BigDecimal.ROUND_DOWN));
-				int updateWalletContractById = memberWalletContractDao.updateById(walletContract);
-				if(updateWalletContractById < 1) {
-					return Result.fail(MessageSourceUtils.getString("member_service_0096"));
-				}
-				//添加币币资金划转历史记录
-				MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
-				memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOCONTRACT.getValue());
-				memberAccountRecord.setMemberId(memberId);
-				memberAccountRecord.setAmount(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
-				memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
-				memberAccountRecord.setSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue());
-				memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
-				memberAccountMoneyChangeDao.insert(memberAccountRecord);
-				
-				//添加合约资金划转历史记录
-				memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMWALLETCOIN.getValue());
-				memberAccountRecord.setSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue());
-				memberAccountRecord.setAmount(balance.setScale(4, BigDecimal.ROUND_DOWN));
-				memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
-				memberAccountMoneyChangeDao.insert(memberAccountRecord);
-			}
-		return Result.ok(MessageSourceUtils.getString("member_service_0006"));
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public Result contractTransferToWalletCoin(BigDecimal balance, 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();
-			MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
-			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.setScale(4, BigDecimal.ROUND_DOWN));
-			walletContract.setTotalBalance(totalSubtract.setScale(4, BigDecimal.ROUND_DOWN));
-			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.setScale(4, BigDecimal.ROUND_DOWN));
-			walletCoin.setTotalBalance(CoinTotalBalance.setScale(4, BigDecimal.ROUND_DOWN));
-			int updateById = memberWalletCoinDao.updateById(walletCoin);
-			if(updateById < 1) {
-				return Result.fail(MessageSourceUtils.getString("member_service_0096"));
-			}
-			
-			//添加资金划转历史记录
-			MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
-			memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOWALLETCOIN.getValue());
-			memberAccountRecord.setMemberId(memberId);
-			memberAccountRecord.setAmount(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
-			memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
-			memberAccountRecord.setSymbol(walletCode);
-			memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT);
-			memberAccountMoneyChangeDao.insert(memberAccountRecord);
-			
-			//添加资金划转历史记录
-			memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTFROMCONTRACT.getValue());
-			memberAccountRecord.setSymbol(walletCode);
-			memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
-			memberAccountRecord.setAmount(balance.setScale(4, BigDecimal.ROUND_DOWN));
-			memberAccountMoneyChangeDao.insert(memberAccountRecord);
-		return Result.ok(MessageSourceUtils.getString("member_service_0006"));
-	}
-
-	@Override
-	public Result findWalletContractBySymbol() {
-		//获取用户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);
-		return Result.ok(availableBalance);
-	}
-
-	@Override
-	public Result findWalletCoinBySymbol(String symbol) {
-		//获取用户ID
-		Long memberId = LoginUserUtils.getAppLoginUser().getId();
-		
-		MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
-		BigDecimal availableBalance = walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN);
-		return Result.ok(availableBalance);
-	}
-
-	@Override
-	public Result getWalletCoinRecords() {
-		//获取用户ID
-		Long memberId = LoginUserUtils.getAppLoginUser().getId();
-		List<MemberAccountMoneyChange> coinRecordList = memberAccountMoneyChangeDao.selectWalletCoinRecordsByMemIdTypeSymbol(memberId);
-		List<MemberAccountMoneyChangeInfoVo> arrayList = new ArrayList<>();
-		if(CollUtil.isNotEmpty(coinRecordList)) {
-			for(MemberAccountMoneyChange memberAccountMoneyChange : coinRecordList) {
-				MemberAccountMoneyChangeInfoVo memberAccountMoneyChangeInfoVo = new MemberAccountMoneyChangeInfoVo();
-				memberAccountMoneyChangeInfoVo.setAmount(memberAccountMoneyChange.getAmount());
-				memberAccountMoneyChangeInfoVo.setContent(memberAccountMoneyChange.getContent());
-				memberAccountMoneyChangeInfoVo.setStatus(memberAccountMoneyChange.getStatus());
-				memberAccountMoneyChangeInfoVo.setSymbol(memberAccountMoneyChange.getSymbol());
-				memberAccountMoneyChangeInfoVo.setType(memberAccountMoneyChange.getType());
-				arrayList.add(memberAccountMoneyChangeInfoVo);
-			}
-		}
-		return Result.ok(arrayList);
-	}
-
-	@Override
-	public Result getWalletContractRecords() {
-		//获取用户ID
-		Long memberId = LoginUserUtils.getAppLoginUser().getId();
-		String symbol = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
-		List<MemberAccountMoneyChange> contractRecordList = memberAccountMoneyChangeDao.selectWalletContractRecordsByMemIdTypeSymbol(symbol,memberId);
-		
-		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());
-				arrayList.add(memberAccountMoneyChangeInfoVo);
-			}
-		}
-		
-		return Result.ok(arrayList);
-	}
-
-	@Override
-	public Result getWalletAgentRecords() {
-		//获取用户ID
-		Long memberId = LoginUserUtils.getAppLoginUser().getId();
-		
-		List<MemberAccountMoneyChange> contractRecordList = 
-				memberAccountMoneyChangeDao.selectWalletAgentRecordByMemIdTypeSymbol(MemberWalletCoinEnum.WALLETCOINCODE.getValue(),memberId);
-		
-		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());
-				arrayList.add(memberAccountMoneyChangeInfoVo);
-			}
-		}
-		return Result.ok(arrayList);
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public Result agentTransferToWalletCoin(BigDecimal balance, Integer transfertype) {
-			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.setScale(4, BigDecimal.ROUND_DOWN));
-			walletAgent.setTotalBalance(total.setScale(4, BigDecimal.ROUND_DOWN));
-			
-			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).setScale(4, BigDecimal.ROUND_DOWN));
-				walletCoin.setTotalBalance(walletCoinTotalBalance.add(balance).setScale(4, BigDecimal.ROUND_DOWN));
-				
-				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.setScale(4, BigDecimal.ROUND_DOWN));
-				memberAccountMoneyChangeDao.insert(memberAccountRecord);
-				memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOWALLETCOIN.getValue());
-				
-			}else if(MemberAccountMoneyChange.TYPE_WALLET_CONTRACT.equals(transfertype)) {
-				//代理账户转合约
-				MemberWalletContractEntity walletContract =  memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberId, walletCode);
-				BigDecimal walletContractAvailableBalance = walletContract.getAvailableBalance();
-				BigDecimal walletContractTotalBalance = walletContract.getTotalBalance();
-				
-				walletContract.setAvailableBalance(walletContractAvailableBalance.add(balance).setScale(4, BigDecimal.ROUND_DOWN));
-				walletContract.setTotalBalance(walletContractTotalBalance.add(balance).setScale(4, BigDecimal.ROUND_DOWN));
-				
-				int updateById = memberWalletContractDao.updateById(walletContract);
-				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_CONTRACT);
-				memberAccountRecord.setAmount(balance.setScale(4, BigDecimal.ROUND_DOWN));
-				memberAccountMoneyChangeDao.insert(memberAccountRecord);
-				memberAccountRecord.setContent(MemberWalletCoinEnum.CONTENTTOCONTRACT.getValue());
-			}
-			memberAccountRecord.setAmount(balance.negate().setScale(4, BigDecimal.ROUND_DOWN));
-			memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_AGENT);
-			memberAccountMoneyChangeDao.insert(memberAccountRecord);
-			
-		return Result.ok(MessageSourceUtils.getString("member_service_0006"));
-	}
-
-	@Override
-	public Result findWalletAgentBySymbol() {
-		//获取用户ID
-		Long memberId = LoginUserUtils.getAppLoginUser().getId();
-		String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
-		
-		MemberWalletAgentEntity walletAgent = memberWalletAgentDao.selectWalletAgentBymIdAndCode(memberId, walletCode);
-		BigDecimal availableBalance = walletAgent.getAvailableBalance();
-		
-		CnyUsdtExchange cnyUsdtExchange =cnyUsdtExchangeDao.getCNYAndUSDTOne();
-		BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
-		BigDecimal multiply = availableBalance.multiply(cnyUsdt);
-		
-		MemberWalletAgentInfoVo memberWalletAgentInfoVo = new MemberWalletAgentInfoVo();
-		memberWalletAgentInfoVo.setTotalBalance(availableBalance.setScale(4, BigDecimal.ROUND_DOWN));
-		memberWalletAgentInfoVo.setTotalRMBBalance(multiply.setScale(4, BigDecimal.ROUND_DOWN));
-		return Result.ok(memberWalletAgentInfoVo);
+	        MemberAgentIntoInfoVo memberAgentIntoInfoVo = new MemberAgentIntoInfoVo();
+	        List<MemberAccountMoneyChangeInfoVo> arrayList = new ArrayList<>();
+	        if(CollUtil.isNotEmpty(contractRecordList)) {
+	        	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);
+	        		}
+	        	}
+	        }
+	        memberAgentIntoInfoVo.setMemberAccountMoneyChangeInfoVo(arrayList);
+	        return Result.ok(memberAgentIntoInfoVo);
 	}
 
 }

--
Gitblit v1.9.1