From 32b62acd2cee84b0d7e2c80ab4528c65c24f5ce8 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Mon, 13 Jul 2020 11:49:14 +0800
Subject: [PATCH] modify

---
 src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java |   69 ++++++++++++++++++++++++----------
 1 files changed, 48 insertions(+), 21 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 84c82d9..2837bdf 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
@@ -322,15 +322,21 @@
         List<OrderCoinsEntity> findCoinOrderListByMemberIdAndSysmbol = orderCoinsDao.findCoinOrderListByMemberIdAndSysmbol(memberId, symbol, status);
         if (CollUtil.isNotEmpty(findCoinOrderListByMemberIdAndSysmbol)) {
             for (OrderCoinsEntity orderCoinsEntity : findCoinOrderListByMemberIdAndSysmbol) {
-            	orderCoinsEntity.setFeeAmount(orderCoinsEntity.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
-            	orderCoinsEntity.setMarkPrice(orderCoinsEntity.getMarkPrice().setScale(4, BigDecimal.ROUND_DOWN));
-            	orderCoinsEntity.setEntrustCnt(orderCoinsEntity.getEntrustCnt().setScale(4, BigDecimal.ROUND_DOWN));
-            	orderCoinsEntity.setEntrustPrice(orderCoinsEntity.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN));
-            	orderCoinsEntity.setDealCnt(orderCoinsEntity.getDealCnt().setScale(4, BigDecimal.ROUND_DOWN));
-            	orderCoinsEntity.setDealPrice(orderCoinsEntity.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
-            	orderCoinsEntity.setDealAmount(orderCoinsEntity.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
-            	
                 OrderWalletCoinVo entityToVo = OrderWalletCoinMapper.INSTANCE.entityToVo(orderCoinsEntity);
+                entityToVo.setFeeAmount(entityToVo.getFeeAmount()== null 
+        				? BigDecimal.ZERO : entityToVo.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
+                entityToVo.setMarkPrice(entityToVo.getMarkPrice()== null 
+        				? BigDecimal.ZERO : entityToVo.getMarkPrice().setScale(4, BigDecimal.ROUND_DOWN));
+                entityToVo.setEntrustCnt(entityToVo.getEntrustCnt()== null 
+        				? BigDecimal.ZERO : entityToVo.getEntrustCnt().setScale(4, BigDecimal.ROUND_DOWN));
+                entityToVo.setEntrustPrice(entityToVo.getEntrustPrice()== null 
+        				? BigDecimal.ZERO : entityToVo.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN));
+                entityToVo.setDealCnt(entityToVo.getDealCnt()== null 
+        				? BigDecimal.ZERO : entityToVo.getDealCnt().setScale(4, BigDecimal.ROUND_DOWN));
+                entityToVo.setDealPrice(entityToVo.getDealPrice()== null 
+        				? BigDecimal.ZERO : entityToVo.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
+                entityToVo.setDealAmount(entityToVo.getDealAmount()== null 
+        				? BigDecimal.ZERO : entityToVo.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
                 arrayList.add(entityToVo);
             }
         }
@@ -427,17 +433,27 @@
         orderCoinsDealEntity.setMemberId(memberId);
         orderCoinsDealEntity.setSymbol(findAllWalletCoinOrderDto.getSymbol());
         IPage<OrderCoinsDealEntity> list = orderCoinDealDao.findAllWalletCoinOrderInPage(page, orderCoinsDealEntity);
-        List<OrderCoinsDealEntity> records = list.getRecords();
+        Page<OrderWalletCoinDealVo> pageEntityToPageVo = OrderWalletCoinDealMapper.INSTANCE.pageEntityToPageVo(list);
+        List<OrderWalletCoinDealVo> records = pageEntityToPageVo.getRecords();
         if(CollUtil.isNotEmpty(records)) {
-        	for(OrderCoinsDealEntity OrderCoinsDealEntity : records) {
-        		orderCoinsDealEntity.setSymbolCnt(orderCoinsDealEntity.getSymbolCnt());
-        		OrderCoinsDealEntity.setEntrustPrice(orderCoinsDealEntity.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN));
-        		orderCoinsDealEntity.setDealPrice(orderCoinsDealEntity.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
-        		orderCoinsDealEntity.setDealAmount(orderCoinsDealEntity.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
-        		orderCoinsDealEntity.setFeeAmount(orderCoinsDealEntity.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
+        	for(OrderWalletCoinDealVo orderWalletCoinDealVo : records) {
+        		orderWalletCoinDealVo.setFeeAmount(orderWalletCoinDealVo.getFeeAmount() == null 
+        				? BigDecimal.ZERO : orderWalletCoinDealVo.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
+        		
+        		orderWalletCoinDealVo.setDealAmount(orderWalletCoinDealVo.getDealAmount() == null 
+        				? BigDecimal.ZERO : orderWalletCoinDealVo.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
+        		
+        		orderWalletCoinDealVo.setSymbolCnt(orderWalletCoinDealVo.getSymbolCnt() == null 
+        				? BigDecimal.ZERO : orderWalletCoinDealVo.getSymbolCnt().setScale(4, BigDecimal.ROUND_DOWN));
+        		
+        		orderWalletCoinDealVo.setEntrustPrice(orderWalletCoinDealVo.getEntrustPrice() == null 
+        				? BigDecimal.ZERO : orderWalletCoinDealVo.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN));
+        		
+        		orderWalletCoinDealVo.setDealPrice(orderWalletCoinDealVo.getDealPrice() == null 
+        				? BigDecimal.ZERO : orderWalletCoinDealVo.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
         	}
         }
-        Page<OrderWalletCoinDealVo> pageEntityToPageVo = OrderWalletCoinDealMapper.INSTANCE.pageEntityToPageVo(list);
+        
 
         return Result.ok(pageEntityToPageVo);
     }
@@ -447,12 +463,23 @@
         //获取用户ID
         Long memberId = LoginUserUtils.getAppLoginUser().getId();
         OrderCoinsDealEntity selectWalletCoinOrder = orderCoinDealDao.selectWalletCoinOrder(orderId, memberId);
-        selectWalletCoinOrder.setSymbolCnt(selectWalletCoinOrder.getSymbolCnt());
-        selectWalletCoinOrder.setEntrustPrice(selectWalletCoinOrder.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN));
-		selectWalletCoinOrder.setDealPrice(selectWalletCoinOrder.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
-		selectWalletCoinOrder.setDealAmount(selectWalletCoinOrder.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
-		selectWalletCoinOrder.setFeeAmount(selectWalletCoinOrder.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
         OrderWalletCoinDealVo entityToVo = OrderWalletCoinDealMapper.INSTANCE.entityToVoOrder(selectWalletCoinOrder);
+        if(ObjectUtil.isNotEmpty(entityToVo)) {
+        	entityToVo.setFeeAmount(entityToVo.getFeeAmount() == null 
+    				? BigDecimal.ZERO : entityToVo.getFeeAmount().setScale(4, BigDecimal.ROUND_DOWN));
+    		
+    		entityToVo.setDealAmount(entityToVo.getDealAmount() == null 
+    				? BigDecimal.ZERO : entityToVo.getDealAmount().setScale(4, BigDecimal.ROUND_DOWN));
+    		
+    		entityToVo.setSymbolCnt(entityToVo.getSymbolCnt() == null 
+    				? BigDecimal.ZERO : entityToVo.getSymbolCnt().setScale(4, BigDecimal.ROUND_DOWN));
+    		
+    		entityToVo.setEntrustPrice(entityToVo.getEntrustPrice() == null 
+    				? BigDecimal.ZERO : entityToVo.getEntrustPrice().setScale(4, BigDecimal.ROUND_DOWN));
+    		
+    		entityToVo.setDealPrice(entityToVo.getDealPrice() == null 
+    				? BigDecimal.ZERO : entityToVo.getDealPrice().setScale(4, BigDecimal.ROUND_DOWN));
+        }
         return Result.ok(entityToVo);
     }
 

--
Gitblit v1.9.1