From fe3f5b8061b40803c93a91940d17088b7080c5ec Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 29 Oct 2020 11:14:22 +0800
Subject: [PATCH] modify
---
src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractEntrustOrderServiceImpl.java | 36 ++++++++++++++++++++++++++----------
1 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractEntrustOrderServiceImpl.java b/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractEntrustOrderServiceImpl.java
index 317e73d..96c64d6 100644
--- a/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractEntrustOrderServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractEntrustOrderServiceImpl.java
@@ -157,12 +157,12 @@
// 发送委托单队列消息
if (submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE) {
- OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol());
+ OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol(), entrustOrderEntity.getMemberId());
producer.sendPriceOperate(JSONObject.toJSONString(model));
LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), entrustTotalAmount, walletContract.getAvailableBalance().subtract(entrustTotalAmount), submitEntrustDto.getSymbol(), "委托买涨", "买涨:" + submitEntrustDto.getSymbol());
} else {
- OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol());
+ OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol(), entrustOrderEntity.getMemberId());
producer.sendPriceOperate(JSONObject.toJSONString(model));
LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), entrustTotalAmount, walletContract.getAvailableBalance().subtract(entrustTotalAmount), submitEntrustDto.getSymbol(), "委托买跌", "买跌:" + submitEntrustDto.getSymbol());
@@ -180,7 +180,7 @@
MemberWalletContractEntity walletContract = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberEntity.getId(), CoinTypeConvert.convertContractTypeToCoin(submitEntrustDto.getSymbol()));
- ContractHoldOrderEntity holdOrderEntity = contractHoldOrderDao.selectWholeHoldOrderByOrderType(memberEntity.getId(), submitEntrustDto.getEntrustType());
+ ContractHoldOrderEntity holdOrderEntity = contractHoldOrderDao.selectWholeHoldOrderByOrderType(memberEntity.getId(), submitEntrustDto.getEntrustType(), submitEntrustDto.getSymbol());
BigDecimal bondAmount;
BigDecimal openFeePrice;
@@ -213,20 +213,20 @@
int i = contractEntrustOrderDao.insert(entrustOrderEntity);
memberWalletContractDao.increaseWalletContractBalanceById(entrustTotalAmount.negate(), null, entrustOrderEntity.getBondAmount(), walletContract.getId());
if (i > 0) {
-
// 发送委托单队列消息
if (submitEntrustDto.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE) {
- OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol());
+ OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol(), entrustOrderEntity.getMemberId());
producer.sendPriceOperate(JSONObject.toJSONString(model));
LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), entrustTotalAmount, walletContract.getAvailableBalance().subtract(entrustTotalAmount), submitEntrustDto.getSymbol(), "委托买涨", "买涨:" + submitEntrustDto.getSymbol());
} else {
- OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol());
+ OrderModel model = new OrderModel(entrustOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(), submitEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), submitEntrustDto.getSymbol(), entrustOrderEntity.getMemberId());
producer.sendPriceOperate(JSONObject.toJSONString(model));
LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), entrustTotalAmount, walletContract.getAvailableBalance().subtract(entrustTotalAmount), submitEntrustDto.getSymbol(), "委托买跌", "买跌:" + submitEntrustDto.getSymbol());
}
+ ThreadPoolUtils.sendWholeForceClosingPrice(submitEntrustDto.getSymbol(), memberEntity);
return Result.ok(MessageSourceUtils.getString("result_success_msg"));
} else {
return Result.fail(MessageSourceUtils.getString("result_fail_msg"));
@@ -263,16 +263,32 @@
LogRecordUtils.insertMemberAccountFlow(memberEntity.getId(), total, walletContractEntity.getAvailableBalance().add(total), entrustOrderEntity.getSymbol(), "撤销委托单", "撤销委托单");
} else {
walletContractEntity = memberWalletContractDao.findWalletContractByMemberIdAndSymbol(memberEntity.getId(), CoinTypeConvert.convertContractTypeToCoin(entrustOrderEntity.getSymbol()));
+
+ if (ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE == entrustOrderEntity.getEntrustType() || ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_LESS == entrustOrderEntity.getEntrustType()) {
+ memberWalletContractDao.increaseWalletContractBalanceById(entrustOrderEntity.getEntrustAmount(), null, entrustOrderEntity.getBondAmount().negate(), walletContractEntity.getId());
+ }
}
ContractOrderEntity orderEntity = ContractEntrustOrderEntityMapper.INSTANCE.entrustOrderToOrder(entrustOrderEntity);
orderEntity.setTradeType(ContractOrderEntity.TRADE_TYPE_MARK_PRICE);
orderEntity.setOrderStatus(ContractOrderEntity.ORDER_STATUS_CANCEL);
+
+ if (entrustOrderEntity.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_CLOSE_MORE) {
+ orderEntity.setClosingType(RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue());
+ }
+
+ if (entrustOrderEntity.getEntrustType() == ContractEntrustOrderEntity.ENTRUST_TYPE_CLOSE_LESS) {
+ orderEntity.setClosingType(RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue());
+ }
+
int i = contractOrderDao.insert(orderEntity);
contractEntrustOrderDao.deleteById(entrustOrderEntity.getId());
if (i > 0) {
+ if (ContractEntrustOrderEntity.POSITION_TYPE_ALL == entrustOrderEntity.getPositionType()) {
+ ThreadPoolUtils.sendWholeForceClosingPrice(entrustOrderEntity.getSymbol(), memberEntity);
+ }
return Result.ok(MessageSourceUtils.getString("cancellation_success"));
}
return Result.fail(MessageSourceUtils.getString("cancellation_fail"));
@@ -351,21 +367,21 @@
entrustOrder.setLeverRatio(holdOrderEntity.getLeverRatio());
entrustOrder.setSymbolSku(holdOrderEntity.getSymbolSku());
entrustOrder.setEntrustType(closeType);
- entrustOrder.setSymbolCnt(holdOrderEntity.getSymbolCnt());
+ entrustOrder.setSymbolCnt(submitCloseEntrustDto.getSymbolCnt());
entrustOrder.setSymbol(holdOrderEntity.getSymbol());
int i = contractEntrustOrderDao.insert(entrustOrder);
- memberWalletContractDao.increaseWalletContractBalanceById(null, null, bondAmount, walletContract.getId());
+// memberWalletContractDao.increaseWalletContractBalanceById(null, null, bondAmount, walletContract.getId());
if (i > 0) {
// 发送委托消息
if (holdOrderEntity.getOpeningType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE) {
- OrderModel model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_MORE.getValue(), submitCloseEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol());
+ OrderModel model = new OrderModel(entrustOrder.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_MORE.getValue(), submitCloseEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol(), holdOrderEntity.getMemberId());
producer.sendPriceOperate(JSONObject.toJSONString(model));
} else {
- OrderModel model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_LESS.getValue(), submitCloseEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol());
+ OrderModel model = new OrderModel(entrustOrder.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_LESS.getValue(), submitCloseEntrustDto.getEntrustPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol(), holdOrderEntity.getMemberId());
producer.sendPriceOperate(JSONObject.toJSONString(model));
}
}
--
Gitblit v1.9.1