From 411814a852dd16cd634b79eceeff5d5aa9483d96 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 05 Jun 2020 16:17:28 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/chonggaoxiao/new_excoin.git

---
 src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java b/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java
index fdbcec5..21a2833 100644
--- a/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java
@@ -191,14 +191,14 @@
                         BigDecimal totalReturn = BigDecimal.ZERO;
                         contractOrderService.save(contractOrderEntity);
 
-                        contractEntrustOrderService.removeById(order.getId());
+                        contractHoldOrderService.removeById(order.getId());
                         // 将需要退回的减去手续费
                         BigDecimal needReturn = prePrice.add(profitLossPrice);
                         //总退回金额=保证金+收益-手续费
                         totalReturn = needReturn.subtract(contractOrderEntity.getClosingFeeAmount());
                         // 总的是收益-平仓手续费
                         BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
-                        memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId());
+                        memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
 
                         // 流水记录 TODO 531e
                         insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓");
@@ -287,7 +287,7 @@
                         // 更新钱包
                         // 总的是收益-平仓手续费
                         BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
-                        memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId());
+                        memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
 
 
                         insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓");
@@ -369,14 +369,19 @@
                         contractOrderEntity.setClosingType(8);
                         BigDecimal totalReturn = BigDecimal.ZERO;
                         contractOrderService.save(contractOrderEntity);
+
+                        contractHoldOrderService.removeById(order.getId());
+                        log.info("保证金:{}", prePrice);
+                        log.info("盈亏:{}", profitLossPrice);
                         // 将需要退回的减去手续费
                         BigDecimal needReturn = prePrice.add(profitLossPrice);
+                        log.info("退回的钱:{}", needReturn);
                         //总退回金额=保证金+收益-手续费
                         totalReturn = needReturn.subtract(contractOrderEntity.getClosingFeeAmount());
                         // 更新钱包
                         // 总的是收益-平仓手续费
                         BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
-                        memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId());
+                        memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
 
                         insertAccountFlow(order, wallet, profitLossPrice, "开多止损平仓");
 
@@ -456,6 +461,9 @@
                         contractOrderEntity.setClosingType(9);
                         BigDecimal totalReturn = BigDecimal.ZERO;
                         contractOrderService.save(contractOrderEntity);
+
+                        contractHoldOrderService.removeById(order.getId());
+
                         // 将需要退回的减去手续费
                         BigDecimal needReturn = prePrice.add(profitLossPrice);
                         //总退回金额=保证金+收益-手续费
@@ -463,7 +471,7 @@
                         // 更新钱包
                         // 总的是收益-平仓手续费
                         BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
-                        memberWalletContractService.increaseWalletContractBalanceById(totalBalance, totalReturn, null, wallet.getId());
+                        memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
 
                         insertAccountFlow(order, wallet, profitLossPrice, "开空止损平仓");
 

--
Gitblit v1.9.1