From cf3fbd17f3eaa432b38b637fe08534e80c06fc95 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Mon, 29 Jun 2020 16:55:39 +0800
Subject: [PATCH] modify
---
src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 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 21a2833..2bff1e0 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
@@ -188,6 +188,7 @@
contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount());
contractOrderEntity.setClosingPrice(closePrice);
contractOrderEntity.setClosingType(6);
+ contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_MORE);
BigDecimal totalReturn = BigDecimal.ZERO;
contractOrderService.save(contractOrderEntity);
@@ -198,6 +199,7 @@
totalReturn = needReturn.subtract(contractOrderEntity.getClosingFeeAmount());
// 总的是收益-平仓手续费
BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
+
memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
// 流水记录 TODO 531e
@@ -276,6 +278,7 @@
contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount());
contractOrderEntity.setClosingPrice(closePrice);
contractOrderEntity.setClosingType(7);
+ contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_MORE);
BigDecimal totalReturn = BigDecimal.ZERO;
contractOrderService.save(contractOrderEntity);
@@ -287,8 +290,8 @@
// 更新钱包
// 总的是收益-平仓手续费
BigDecimal totalBalance = profitLossPrice.subtract(contractOrderEntity.getClosingFeeAmount());
- memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
+ memberWalletContractService.increaseWalletContractBalanceById(totalReturn, totalBalance, null, wallet.getId());
insertAccountFlow(order, wallet, profitLossPrice, "止盈平仓");
@@ -366,21 +369,20 @@
contractOrderEntity.setRewardRatio(returnRate);
contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount());
contractOrderEntity.setClosingPrice(closePrice);
+ contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_MORE);
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(totalReturn, totalBalance, null, wallet.getId());
insertAccountFlow(order, wallet, profitLossPrice, "开多止损平仓");
@@ -425,7 +427,7 @@
String symbol = order.getSymbol();
Long memberId = order.getMemberId();
// 本次需要退回的预付款
- BigDecimal prePrice = order.getPrePaymentAmount();
+ BigDecimal prePrice = order.getBondAmount();
MemberWalletContractEntity wallet = memberWalletContractService.findWalletContractByMemberIdAndSymbol(memberId, "USDT");
if (wallet != null) {
@@ -459,6 +461,7 @@
contractOrderEntity.setClosingFeeAmount(order.getOpeningFeeAmount());
contractOrderEntity.setClosingPrice(closePrice);
contractOrderEntity.setClosingType(9);
+ contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_LESS);
BigDecimal totalReturn = BigDecimal.ZERO;
contractOrderService.save(contractOrderEntity);
@@ -555,6 +558,7 @@
contractOrderEntity.setEntrustOpeningPrice(coinsCoinsOrder.getEntrustPrice());
contractOrderEntity.setEntrustTime(coinsCoinsOrder.getCreateTime());
contractOrderEntity.setOpeningTime(new Date());
+
contractOrderEntity.setId(null);
contractOrderService.save(contractOrderEntity);
// 发送爆仓的队列
@@ -622,7 +626,12 @@
if (isDone) {
//删除次仓订单
contractHoldOrderService.removeById(orderId);
-
+ // 订单状态转换
+ if (ContractOrderEntity.ORDER_TYPE_OPEN_MORE == contractOrderEntity.getOrderType()) {
+ contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_MORE);
+ } else {
+ contractOrderEntity.setOrderType(ContractOrderEntity.ORDER_TYPE_CLOSE_LESS);
+ }
//更新主表订单状态位为“已平仓”
contractOrderEntity.setId(null);
contractOrderEntity.setClosingPrice(nowPrice);
--
Gitblit v1.9.1