From 7abc2d13af01dde090dfd2eb945aa1ad71e2e957 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 20 Aug 2020 19:15:51 +0800
Subject: [PATCH] add entrust order info

---
 src/main/java/com/xcong/excoin/modules/contract/service/impl/RabbitOrderServiceImpl.java |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/impl/RabbitOrderServiceImpl.java b/src/main/java/com/xcong/excoin/modules/contract/service/impl/RabbitOrderServiceImpl.java
index fe49e0a..beb8f51 100644
--- a/src/main/java/com/xcong/excoin/modules/contract/service/impl/RabbitOrderServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/contract/service/impl/RabbitOrderServiceImpl.java
@@ -261,7 +261,7 @@
 
         MemberEntity memberEntity = memberDao.selectById(holdOrderEntity.getMemberId());
 
-        MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(holdOrderEntity.getMemberId(), CoinTypeEnum.USDT.name());
+        MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(holdOrderEntity.getMemberId(), CoinTypeConvert.convertContractTypeToCoin(symbol));
         if (walletContract != null) {
             BigDecimal lotNumber = cacheSettingUtils.getSymbolSku(symbol);
             // 盈亏
@@ -303,8 +303,13 @@
             BigDecimal bondAmount = CalculateUtil.getBondAmount(holdOrderEntity.getOpeningPrice(), lotNumber, closeCnt, holdOrderEntity.getLeverRatio());
 
             log.info("bondAmount:{}", bondAmount);
-            // 平仓手续费
-            BigDecimal fee = holdOrderEntity.getOpeningFeeAmount().divide(BigDecimal.valueOf(holdOrderEntity.getSymbolCnt()), 8, BigDecimal.ROUND_DOWN).multiply(BigDecimal.valueOf(closeCnt));
+            // 平仓手续费  TODO 可能需要修复手续费
+            BigDecimal fee = BigDecimal.ZERO;
+            if (holdOrderEntity.getSymbolCnt() != 0) {
+                fee = holdOrderEntity.getOpeningFeeAmount().divide(BigDecimal.valueOf(holdOrderEntity.getSymbolCnt()), 8, BigDecimal.ROUND_DOWN).multiply(BigDecimal.valueOf(closeCnt));
+            } else {
+                fee = holdOrderEntity.getOpeningFeeAmount();
+            }
             log.info("fee:{}", fee);
             ContractOrderEntity contractOrderEntity = ContractHoldOrderEntityMapper.INSTANCE.holdOrderToOrder(holdOrderEntity);
             contractOrderEntity.setId(null);
@@ -318,6 +323,7 @@
             contractOrderDao.insert(contractOrderEntity);
 
             if (holdOrderEntity.getSymbolCntSale() != 0) {
+                holdOrderEntity.setOpeningFeeAmount(holdOrderEntity.getOpeningFeeAmount().subtract(fee));
                 contractHoldOrderDao.updateById(holdOrderEntity);
             } else {
                 contractHoldOrderDao.deleteById(holdOrderEntity.getId());

--
Gitblit v1.9.1