From 7c0127773885de45b3ff55f80e3c7bf7c5f5a3a3 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Tue, 09 Jun 2020 15:10:25 +0800
Subject: [PATCH] 20200609  代码提交

---
 src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java |  249 ++++++++++++++++++++++++++++++-------------------
 1 files changed, 150 insertions(+), 99 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java b/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
index 01834ca..0dbfb7a 100644
--- a/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
@@ -12,9 +12,15 @@
 
 import javax.annotation.Resource;
 
+import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
+import com.xcong.excoin.modules.platform.entity.PlatformSymbolsCoinEntity;
+
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+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.MemberWalletCoinEnum;
@@ -23,12 +29,13 @@
 import com.xcong.excoin.modules.coin.dao.MemberSelectSymbolsDao;
 import com.xcong.excoin.modules.coin.dao.OrderCoinDealDao;
 import com.xcong.excoin.modules.coin.dao.OrderCoinsDao;
-import com.xcong.excoin.modules.coin.entity.CnyUsdtExchange;
 import com.xcong.excoin.modules.coin.entity.MemberAccountFlowEntity;
 import com.xcong.excoin.modules.coin.entity.OrderCoinsDealEntity;
 import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity;
 import com.xcong.excoin.modules.coin.mapper.OrderWalletCoinDealMapper;
 import com.xcong.excoin.modules.coin.mapper.OrderWalletCoinMapper;
+import com.xcong.excoin.modules.coin.parameter.dto.FindAllWalletCoinOrderDto;
+import com.xcong.excoin.modules.coin.parameter.vo.FindCollectListVo;
 import com.xcong.excoin.modules.coin.parameter.vo.MemberSelectSymbolsVo;
 import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinDealListVo;
 import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinDealVo;
@@ -36,13 +43,19 @@
 import com.xcong.excoin.modules.coin.parameter.vo.OrderWalletCoinVo;
 import com.xcong.excoin.modules.coin.parameter.vo.TransactionPageOfWalletCoinVo;
 import com.xcong.excoin.modules.coin.service.OrderCoinService;
+import com.xcong.excoin.modules.contract.entity.ContractOrderEntity;
+import com.xcong.excoin.modules.contract.mapper.ContractOrderEntityMapper;
+import com.xcong.excoin.modules.contract.parameter.vo.OrderListVo;
 import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
 import com.xcong.excoin.modules.member.entity.MemberSelectSymbolsEntity;
 import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
-import com.xcong.excoin.modules.platform.dao.CnyUsdtExchangeDao;
+import com.xcong.excoin.modules.platform.dao.PlatformCnyUsdtExchangeDao;
+import com.xcong.excoin.modules.platform.dao.PlatformSymbolsCoinDao;
 import com.xcong.excoin.modules.platform.dao.TradeSettingDao;
 import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity;
+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;
@@ -59,13 +72,17 @@
 	@Resource
 	MemberSelectSymbolsDao memberSelectSymbolsDao;
 	@Resource
-	CnyUsdtExchangeDao cnyUsdtExchangeDao;
+    PlatformCnyUsdtExchangeDao cnyUsdtExchangeDao;
 	@Resource
 	OrderCoinsDao orderCoinsDao;
 	@Resource
 	OrderCoinDealDao orderCoinDealDao;
 	@Resource
 	MemberAccountFlowEntityDao memberAccountFlowEntityDao;
+    @Resource
+    RedisUtils redisUtils;
+    @Resource
+    PlatformSymbolsCoinDao platformSymbolsCoinDao;
 	
 	@Override
 	public String generateSimpleSerialno(String userId) {
@@ -93,7 +110,7 @@
 	}
 
 	@Override
-	public Result enterTransactionPageOfWalletCoin(String symbol, String type) {
+	public Result enterTransactionPageOfWalletCoin(String symbol) {
 		if (StrUtil.isBlank(symbol)) {
 			return Result.fail(MessageSourceUtils.getString("order_service_0001"));
 		}
@@ -109,16 +126,12 @@
 		//获取USDT的币币账户信息
 		MemberWalletCoinEntity walletCoinUsdt = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, 
 															MemberWalletCoinEnum.WALLETCOINCODE.getValue());
-		/**
-		 * todo
-		 */
-		//获取某个币种的收盘价
-		//Double closePrice = symbolsService.getCloseSymbolsBySymbolsName(symbol+"/USDT");
-		BigDecimal closePrice = new BigDecimal("100.0000");
+		
+		BigDecimal closePrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol+"/USDT")));
 		
 		List<MemberSelectSymbolsEntity> memSymbols = memberSelectSymbolsDao.selectSymbolByMemIdAndSymbol(memberId, symbol);
-		
-		CnyUsdtExchange cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
+
+		PlatformCnyUsdtExchangeEntity cnyUsdtExchange = cnyUsdtExchangeDao.getCNYAndUSDTOne();
 		BigDecimal cnyUsdt = cnyUsdtExchange.getValue();
 		TransactionPageOfWalletCoinVo transactionPageOfWalletCoinVo = new TransactionPageOfWalletCoinVo();
 		//是否自选
@@ -132,13 +145,10 @@
 		// 点差
 		transactionPageOfWalletCoinVo.setSpread(tradeSetting.getSpread().setScale(4, BigDecimal.ROUND_DOWN));
 		// 手续费用率
-		transactionPageOfWalletCoinVo.setFeeRatio(tradeSetting.getFeeRatio().setScale(4, BigDecimal.ROUND_DOWN));
+		transactionPageOfWalletCoinVo.setFeeRatio(tradeSetting.getCoinFeeRatio().setScale(4, BigDecimal.ROUND_DOWN));
 		// 用户可用金额
-		if(MemberWalletCoinEnum.ENTERTRANSACTIONPAGEOFWALLETCOIN_BUY.getValue().equals(type)) {//买入
-			transactionPageOfWalletCoinVo.setAvailableBalance(walletCoinUsdt.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
-		}else {
-			transactionPageOfWalletCoinVo.setAvailableBalance(walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
-		}
+		transactionPageOfWalletCoinVo.setAvailableBalanceBuy(walletCoinUsdt.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
+		transactionPageOfWalletCoinVo.setAvailableBalanceSell(walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
 		//当前价
 		transactionPageOfWalletCoinVo.setCurrentPrice(closePrice.setScale(4, BigDecimal.ROUND_DOWN));
 		//比例
@@ -147,24 +157,18 @@
 		transactionPageOfWalletCoinVo.setCurrentPriceCny(cnyUsdt.multiply(closePrice).setScale(4, BigDecimal.ROUND_DOWN));
 		
 		transactionPageOfWalletCoinVo.setSymbol(symbol);
-		transactionPageOfWalletCoinVo.setType(type);
 		return Result.ok(transactionPageOfWalletCoinVo);
 	}
 
 	@Override
 	@Transactional
-	public Result submitSalesWalletCoinOrder(String symbol, Integer type, Integer tradeType, BigDecimal price,
-			BigDecimal amount) {
+	public Result submitSalesWalletCoinOrder(String symbol, Integer type, Integer tradeType, BigDecimal price,BigDecimal amount) {
 			//获取用户ID
 			Long memberId = LoginUserUtils.getAppLoginUser().getId();
 			
-			/**
-			 * todo
-			*/
 			//查询当前价
-			//BigDecimal nowPrice = new BigDecimal(redisUtil.getString(CoinTypeConConvert.convertToKey(symbol+"/USDT")));
+			BigDecimal nowPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol+"/USDT")));
 			
-			BigDecimal nowPrice = new BigDecimal("10.0000");
 			// 获取交易管理的杠杠倍率,手续费率等信息,由平台进行设置
 			symbol = symbol.toUpperCase();
 			MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
@@ -177,7 +181,7 @@
 				return Result.fail(MessageSourceUtils.getString("order_service_0009"));
 			}
 			// 手续费用(手续费=建仓价X数量X手续费率)
-			BigDecimal closingPrice = price.multiply(amount).multiply(new BigDecimal(MemberWalletCoinEnum.SUBMITSALESWALLETCOINORDER_SERVICERATE.getValue()));
+			BigDecimal closingPrice = price.multiply(amount).multiply(tradeSetting.getCoinFeeRatio());
 			//总费用 = 成交价*数量+手续费
 			BigDecimal totalPayPrice = price.multiply(amount).add(closingPrice);
 			
@@ -205,15 +209,15 @@
 				order.setOrderNo(generateSimpleSerialno(memberId.toString()));
 				order.setOrderType(type);
 				order.setSymbol(symbol);
-				order.setMarkPrice(nowPrice.setScale(4, BigDecimal.ROUND_DOWN));
-				order.setEntrustCnt(amount.setScale(4, BigDecimal.ROUND_DOWN));
-				order.setEntrustPrice(price.setScale(4, BigDecimal.ROUND_DOWN));
-				order.setDealCnt(amount.setScale(4, BigDecimal.ROUND_DOWN));
-				order.setDealPrice(price.setScale(4, BigDecimal.ROUND_DOWN));
-				order.setDealAmount(totalPayPrice.setScale(4, BigDecimal.ROUND_DOWN));
+				order.setMarkPrice(nowPrice);
+				order.setEntrustCnt(amount);
+				order.setEntrustPrice(price);
+				order.setDealCnt(amount);
+				order.setDealPrice(price);
+				order.setDealAmount(totalPayPrice);
 				order.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_DODING);
 				order.setTradeType(tradeType);
-				order.setFeeAmount(closingPrice.setScale(4, BigDecimal.ROUND_DOWN));
+				order.setFeeAmount(closingPrice);
 				orderCoinsDao.insert(order);
 				
 				//更新用户钱包信息
@@ -222,15 +226,15 @@
 					//如果是买入,所对应的币种增加,USDT账户减少金额
 					BigDecimal availableBalance = walletCoinUsdt.getAvailableBalance().subtract(totalPayPrice);
 					BigDecimal frozenBalance = walletCoinUsdt.getFrozenBalance().add(totalPayPrice);
-					walletCoinUsdt.setAvailableBalance(availableBalance.setScale(4, BigDecimal.ROUND_DOWN));
-					walletCoinUsdt.setFrozenBalance(frozenBalance.setScale(4, BigDecimal.ROUND_DOWN));
+					walletCoinUsdt.setAvailableBalance(availableBalance);
+					walletCoinUsdt.setFrozenBalance(frozenBalance);
 					memberWalletCoinDao.updateById(walletCoinUsdt);
 				}else {
 					//如果是卖出,币种减少,USDT增加
 					BigDecimal availableBalance = walletCoin.getAvailableBalance().subtract(amount);
 					BigDecimal frozenBalance = walletCoin.getFrozenBalance().add(amount);
-					walletCoin.setAvailableBalance(availableBalance.setScale(4, BigDecimal.ROUND_DOWN));
-					walletCoin.setFrozenBalance(frozenBalance.setScale(4, BigDecimal.ROUND_DOWN));
+					walletCoin.setAvailableBalance(availableBalance);
+					walletCoin.setFrozenBalance(frozenBalance);
 					memberWalletCoinDao.updateById(walletCoin);
 				} 
 			} else {
@@ -239,15 +243,15 @@
 				order.setOrderNo(generateSimpleSerialno(memberId.toString()));
 				order.setOrderType(type);
 				order.setSymbol(symbol);
-				order.setMarkPrice(nowPrice.setScale(4, BigDecimal.ROUND_DOWN));
-				order.setEntrustCnt(amount.setScale(4, BigDecimal.ROUND_DOWN));
-				order.setEntrustPrice(price.setScale(4, BigDecimal.ROUND_DOWN));
-				order.setDealCnt(amount.setScale(4, BigDecimal.ROUND_DOWN));
-				order.setDealPrice(price.setScale(4, BigDecimal.ROUND_DOWN));
-				order.setDealAmount(totalPayPrice.setScale(4, BigDecimal.ROUND_DOWN));
+				order.setMarkPrice(nowPrice);
+				order.setEntrustCnt(amount);
+				order.setEntrustPrice(price);
+				order.setDealCnt(amount);
+				order.setDealPrice(price);
+				order.setDealAmount(totalPayPrice);
 				order.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_DONE);
 				order.setTradeType(tradeType);
-				order.setFeeAmount(closingPrice.setScale(4, BigDecimal.ROUND_DOWN));
+				order.setFeeAmount(closingPrice);
 				orderCoinsDao.insert(order);
 				
 				OrderCoinsDealEntity detail = new OrderCoinsDealEntity();
@@ -257,27 +261,29 @@
 				detail.setOrderType(type);
 				detail.setTradeType(tradeType);
 				detail.setSymbol(symbol);
-				detail.setSymbolCnt(amount.setScale(4, BigDecimal.ROUND_DOWN));
-				detail.setEntrustPrice(price.setScale(4, BigDecimal.ROUND_DOWN));
-				detail.setDealPrice(price.setScale(4, BigDecimal.ROUND_DOWN));
-				detail.setDealAmount(totalPayPrice.setScale(4, BigDecimal.ROUND_DOWN));
-				detail.setFeeAmount(closingPrice.setScale(4, BigDecimal.ROUND_DOWN));
+				detail.setSymbolCnt(amount);
+				detail.setEntrustPrice(price);
+				detail.setDealPrice(price);
+				detail.setDealAmount(totalPayPrice);
+				detail.setFeeAmount(closingPrice);
+				detail.setOrderStatus(OrderCoinsDealEntity.ORDERSTATUS_DONE);
 				orderCoinDealDao.insert(detail);
 				
 				if(OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) {
 					//如果是买入,所对应的币种增加,USDT账户减少金额
 					// 更新用户的可用金额
-					walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(amount).setScale(4, BigDecimal.ROUND_DOWN));
+					walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(amount));
 					memberWalletCoinDao.updateById(walletCoin);
 					
-					walletCoinUsdt.setAvailableBalance(walletCoinUsdt.getAvailableBalance().subtract(totalPayPrice).setScale(4, BigDecimal.ROUND_DOWN));
+					walletCoinUsdt.setAvailableBalance(walletCoinUsdt.getAvailableBalance().subtract(totalPayPrice));
 					memberWalletCoinDao.updateById(walletCoinUsdt);
 				}else {
 					//如果是卖出,币种减少,USDT增加
-					walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().subtract(amount).setScale(4, BigDecimal.ROUND_DOWN));
+					walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().subtract(amount));
 					memberWalletCoinDao.updateById(walletCoin);
 					
-					walletCoinUsdt.setAvailableBalance(walletCoinUsdt.getAvailableBalance().add(totalPayPrice).setScale(4, BigDecimal.ROUND_DOWN));
+					BigDecimal subtract = totalPayPrice.subtract(closingPrice).subtract(closingPrice);
+					walletCoinUsdt.setAvailableBalance(walletCoinUsdt.getAvailableBalance().add(subtract));
 					memberWalletCoinDao.updateById(walletCoinUsdt);
 				}
 			}
@@ -287,14 +293,14 @@
 			if (OrderCoinsEntity.ORDERTYPE_BUY.equals(type)) {
 				record.setPrice(totalPayPrice.setScale(4, BigDecimal.ROUND_DOWN));
 				record.setSource(MemberAccountFlowEntity.SOURCE_BUY+symbol);
-				record.setRemark(MemberAccountFlowEntity.REMARK_BUY+symbol+":"+amount.setScale(4, BigDecimal.ROUND_DOWN));
+				record.setRemark(MemberAccountFlowEntity.REMARK_BUY+symbol+":"+amount);
 			} else {
 				record.setPrice(totalPayPrice.negate().setScale(4, BigDecimal.ROUND_DOWN));
 				record.setSource(MemberAccountFlowEntity.SOURCE_SALE+symbol);
-				record.setRemark(MemberAccountFlowEntity.REMARK_SALE+symbol+":"+amount.setScale(4, BigDecimal.ROUND_DOWN));
+				record.setRemark(MemberAccountFlowEntity.REMARK_SALE+symbol+":"+amount);
 			}
 			record.setSymbol(symbol);
-			record.setBalance(walletCoinUsdt.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
+			record.setBalance(walletCoinUsdt.getAvailableBalance());
 			
 			memberAccountFlowEntityDao.insert(record);
 			
@@ -321,10 +327,10 @@
 
 	@Override
 	@Transactional
-	public Result cancelEntrustWalletCoinOrder(String orderNo) {
+	public Result cancelEntrustWalletCoinOrder(String orderId) {
 			//获取用户ID
 			Long memberId = LoginUserUtils.getAppLoginUser().getId();
-			OrderCoinsEntity orderCoinsEntity = orderCoinsDao.findWalletCoinOrderByOrderNo(orderNo);
+			OrderCoinsEntity orderCoinsEntity = orderCoinsDao.selectById(orderId);
 				if(ObjectUtil.isNotEmpty(orderCoinsEntity) && orderCoinsEntity.getMemberId() == memberId) {
 					if(orderCoinsEntity.getOrderStatus() == OrderCoinsEntity.ORDERSTATUS_CANCEL){
 						return Result.fail(MessageSourceUtils.getString("order_service_0012"));
@@ -334,7 +340,22 @@
 					
 					String symbol = orderCoinsEntity.getSymbol();
 					
-					if(orderCoinsEntity.getOrderType() == OrderCoinsEntity.TRADETYPE_FIXEDPRICE) {
+					OrderCoinsDealEntity detail = new OrderCoinsDealEntity();
+					detail.setMemberId(memberId);
+					detail.setOrderId(orderCoinsEntity.getId());
+					detail.setOrderNo(generateSimpleSerialno(memberId.toString()));
+					detail.setOrderType(orderCoinsEntity.getOrderType());
+					detail.setTradeType(orderCoinsEntity.getTradeType());
+					detail.setSymbol(symbol);
+					detail.setOrderStatus(OrderCoinsDealEntity.ORDERSTATUS_CANCEL);
+					detail.setSymbolCnt(orderCoinsEntity.getEntrustCnt());
+					detail.setEntrustPrice(orderCoinsEntity.getEntrustPrice());
+					detail.setDealPrice(orderCoinsEntity.getDealPrice());
+					detail.setDealAmount(orderCoinsEntity.getDealAmount());
+					detail.setFeeAmount(orderCoinsEntity.getFeeAmount());
+					orderCoinDealDao.insert(detail);
+					
+					if(OrderCoinsEntity.ORDERTYPE_BUY.equals(orderCoinsEntity.getOrderType())) {
 						//如果是限价买入,撤单将USDT账户冻结金额返回
 						String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
 						MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
@@ -342,16 +363,16 @@
 						if (ObjectUtil.isNotEmpty(walletCoin)) {
 							//手续费 = 开仓价*数量*手续费率
 							//返还金额=开仓价*未成交数量+手续费
-							BigDecimal returnBalance = orderCoinsEntity.getEntrustPrice().add(orderCoinsEntity.getFeeAmount());
+							BigDecimal returnBalance = orderCoinsEntity.getDealAmount();
 							
-							walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(returnBalance).setScale(4, BigDecimal.ROUND_DOWN));
-							walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(returnBalance).setScale(4, BigDecimal.ROUND_DOWN));
+							walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(returnBalance));
+							walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(returnBalance));
 							memberWalletCoinDao.updateById(walletCoin);
 							// 流水记录
 							MemberAccountFlowEntity record = new MemberAccountFlowEntity();
 							record.setSource(MemberAccountFlowEntity.SOURCE_CANCEL);
 							record.setRemark(MemberAccountFlowEntity.REMARK_CANCEL+symbol+MemberAccountFlowEntity.REMARK_RETURNBALANCE+returnBalance);
-							record.setBalance(walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
+							record.setBalance(walletCoin.getAvailableBalance());
 							record.setMemberId(memberId);
 							record.setSymbol(symbol);
 							record.setPrice(returnBalance);
@@ -360,61 +381,42 @@
 						}
 					}else {
 						//如果是限价卖出,撤单将对应的钱包冻结金额返回
-						String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
-						MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
+						MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, symbol);
 						if (ObjectUtil.isNotEmpty(walletCoin)) {
-							//返还金额=开仓价*未成交数量
-							BigDecimal returnBalance = walletCoin.getAvailableBalance().add(walletCoin.getFrozenBalance());
-							walletCoin.setAvailableBalance(returnBalance.setScale(4, BigDecimal.ROUND_DOWN));
-							walletCoin.setFrozenBalance(BigDecimal.ZERO);
+							
+							BigDecimal returnBalance = orderCoinsEntity.getEntrustCnt();
+							walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(returnBalance));
+							walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(returnBalance));
 							memberWalletCoinDao.updateById(walletCoin);
 							// 流水记录
 							MemberAccountFlowEntity record = new MemberAccountFlowEntity();
 							record.setSource(MemberAccountFlowEntity.SOURCE_CANCEL);
 							record.setRemark(MemberAccountFlowEntity.REMARK_CANCEL+symbol+MemberAccountFlowEntity.REMARK_RETURNBALANCE+returnBalance);
-							record.setBalance(walletCoin.getAvailableBalance().setScale(4, BigDecimal.ROUND_DOWN));
+							record.setBalance(walletCoin.getAvailableBalance());
 							record.setMemberId(memberId);
 							record.setSymbol(symbol);
-							record.setPrice(walletCoin.getFrozenBalance().setScale(4, BigDecimal.ROUND_DOWN));
+							record.setPrice(walletCoin.getFrozenBalance());
 							memberAccountFlowEntityDao.insert(record);
 							return Result.ok(MessageSourceUtils.getString("order_service_0013"));
 						}
 					}
-					
-					OrderCoinsDealEntity detail = new OrderCoinsDealEntity();
-					detail.setMemberId(memberId);
-					detail.setOrderId(orderCoinsEntity.getId());
-					detail.setOrderNo(generateSimpleSerialno(memberId.toString()));
-					detail.setOrderType(orderCoinsEntity.getOrderType());
-					detail.setTradeType(orderCoinsEntity.getTradeType());
-					detail.setSymbol(symbol);
-					detail.setSymbolCnt(orderCoinsEntity.getEntrustCnt());
-					detail.setEntrustPrice(orderCoinsEntity.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN));
-					detail.setDealPrice(orderCoinsEntity.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
-					detail.setDealAmount(orderCoinsEntity.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
-					detail.setFeeAmount(orderCoinsEntity.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
-					orderCoinDealDao.insert(detail);
 				}
 		return Result.fail(MessageSourceUtils.getString("order_service_0043"));
 	}
 
 	@Override
-	public Result findAllWalletCoinOrder() {
+	public Result findAllWalletCoinOrder(FindAllWalletCoinOrderDto findAllWalletCoinOrderDto) {
 		//获取用户ID
 		Long memberId = LoginUserUtils.getAppLoginUser().getId();
 		
-		OrderWalletCoinDealListVo orderWalletCoinDealListVo = new OrderWalletCoinDealListVo();
-		List<OrderWalletCoinDealVo> arrayList = new ArrayList<OrderWalletCoinDealVo>();
-		
-		List<OrderCoinsDealEntity> selectAllWalletCoinOrder = orderCoinDealDao.selectAllWalletCoinOrder(memberId);
-		if(CollUtil.isNotEmpty(selectAllWalletCoinOrder)) {
-			for(OrderCoinsDealEntity orderCoinsDealEntity: selectAllWalletCoinOrder) {
-				OrderWalletCoinDealVo entityToVo = OrderWalletCoinDealMapper.INSTANCE.entityToVoOrder(orderCoinsDealEntity);
-				arrayList.add(entityToVo);
-			}
-		}
-		orderWalletCoinDealListVo.setOrderWalletCoinDealVo(arrayList);
-		return Result.ok(orderWalletCoinDealListVo);
+		Page<OrderCoinsDealEntity> page = new Page<>(findAllWalletCoinOrderDto.getPageNum(), findAllWalletCoinOrderDto.getPageSize());
+		OrderCoinsDealEntity orderCoinsDealEntity = new OrderCoinsDealEntity();
+		orderCoinsDealEntity.setMemberId(memberId);
+		orderCoinsDealEntity.setSymbol(findAllWalletCoinOrderDto.getSymbol());
+        IPage<OrderCoinsDealEntity> list = orderCoinDealDao.findAllWalletCoinOrderInPage(page, orderCoinsDealEntity);
+        Page<OrderWalletCoinDealVo> pageEntityToPageVo = OrderWalletCoinDealMapper.INSTANCE.pageEntityToPageVo(list);
+        
+		return Result.ok(pageEntityToPageVo);
 	}
 
 	@Override
@@ -462,4 +464,53 @@
 		return Result.ok(memberSelectSymbolsVo);
 	}
 
+	@Override
+	public Result findCollectList() {
+		//获取用户ID
+		Long memberId = LoginUserUtils.getAppLoginUser().getId();
+		List<MemberSelectSymbolsEntity> selectByMap = memberSelectSymbolsDao.selectSymbolByMemId(memberId);
+		
+		FindCollectListVo findCollectListVo = new FindCollectListVo();
+		List<MemberSelectSymbolsVo> arrayList = new ArrayList<>();
+		if(CollUtil.isNotEmpty(selectByMap)) {
+			for(MemberSelectSymbolsEntity memberSelectSymbolsEntity : selectByMap) {
+				MemberSelectSymbolsVo memberSelectSymbolsVo = new MemberSelectSymbolsVo();
+				memberSelectSymbolsVo.setSymbol(memberSelectSymbolsEntity.getSymbol());
+				arrayList.add(memberSelectSymbolsVo);
+			}
+		}
+		findCollectListVo.setMemberSelectSymbolsVo(arrayList);
+		
+		return Result.ok(findCollectListVo);
+	}
+
+	@Override
+	public Result searchSymbolResultList() {
+		//获取用户ID
+		Long memberId = LoginUserUtils.getAppLoginUser().getId();
+		FindCollectListVo findCollectListVo = new FindCollectListVo();
+		List<MemberSelectSymbolsVo> list = new ArrayList<>();
+		
+		Map<String, Object> columnMap = new HashMap<>();
+		List<PlatformSymbolsCoinEntity> selectByMap = platformSymbolsCoinDao.selectByMap(columnMap);
+		
+		List<MemberSelectSymbolsEntity> selectSymbolByMemIdAndSymbol = memberSelectSymbolsDao.selectSymbolByMemId(memberId);
+		for(PlatformSymbolsCoinEntity platformSymbolsCoinEntity : selectByMap) {
+			MemberSelectSymbolsVo memberSelectSymbolsVo = new MemberSelectSymbolsVo();
+			memberSelectSymbolsVo.setSymbol(platformSymbolsCoinEntity.getName());
+			if(CollUtil.isNotEmpty(selectSymbolByMemIdAndSymbol)) {
+				for(MemberSelectSymbolsEntity memberSelectSymbolsEntity : selectSymbolByMemIdAndSymbol) {
+					if(platformSymbolsCoinEntity.getName().equals(memberSelectSymbolsEntity.getSymbol())) {
+						memberSelectSymbolsVo.setIsCollect(MemberSelectSymbolsVo.ISCOLLECT_YES);
+					}
+				}
+			}else {
+				memberSelectSymbolsVo.setIsCollect(MemberSelectSymbolsVo.ISCOLLECT_NO);
+			}
+			list.add(memberSelectSymbolsVo);
+		}
+		findCollectListVo.setMemberSelectSymbolsVo(list);
+		return Result.ok(findCollectListVo);
+	}
+
 }

--
Gitblit v1.9.1