From ea8eb9c441bb4452d153579b456467b2f5e958e4 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Tue, 04 Aug 2020 16:15:54 +0800 Subject: [PATCH] add trader closing order --- src/main/java/com/xcong/excoin/modules/contract/service/impl/RabbitOrderServiceImpl.java | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 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 2a2aac9..0ae1e39 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 @@ -10,6 +10,9 @@ import com.xcong.excoin.modules.contract.entity.ContractOrderEntity; import com.xcong.excoin.modules.contract.mapper.ContractHoldOrderEntityMapper; import com.xcong.excoin.modules.contract.service.RabbitOrderService; +import com.xcong.excoin.modules.documentary.dao.FollowFollowerOrderRelationDao; +import com.xcong.excoin.modules.documentary.entity.FollowFollowerOrderRelationEntity; +import com.xcong.excoin.modules.documentary.service.FollowOrderOperationService; import com.xcong.excoin.modules.member.dao.MemberDao; import com.xcong.excoin.modules.member.dao.MemberWalletContractDao; import com.xcong.excoin.modules.member.entity.AgentReturnEntity; @@ -58,6 +61,11 @@ @Resource private RedisUtils redisUtils; + @Resource + private FollowFollowerOrderRelationDao followFollowerOrderRelationDao; + @Resource + private FollowOrderOperationService followOrderOperationService; + @Transactional(rollbackFor = Exception.class) @Override public void cancelHoldOrder(List<Long> ids) { @@ -76,6 +84,7 @@ } } + @Transactional(rollbackFor = Exception.class) public void cancelHoldOrderMethod(ContractHoldOrderEntity holdOrderEntity) { String symbol = holdOrderEntity.getSymbol(); // 获取最新价 @@ -141,7 +150,32 @@ // 计算佣金 ThreadPoolUtils.calReturnMoney(memberEntity.getId(), contractOrderEntity.getClosingFeeAmount(), contractOrderEntity, AgentReturnEntity.ORDER_TYPE_CLOSE); + + // 判断当前持仓是否为跟单订单 + if (ContractOrderEntity.CONTRACTTYPE_DOCUMENTARY == holdOrderEntity.getContractType()) { + updateFollowOrderRelation(holdOrderEntity.getId(), contractOrderEntity.getId()); + + // 若为交易员,则平仓跟随者订单 + if (MemberEntity.IS_TRADER_Y.equals(memberEntity.getIsTrader())) { + followOrderOperationService.closingFollowOrders(holdOrderEntity.getOrderNo()); + } + } } } + + /** + * 更新跟单订单关系 + * + * @param oldOrderId 当前持仓ID + * @param newOrderId 历史订单ID + */ + public void updateFollowOrderRelation(Long oldOrderId, Long newOrderId) { + FollowFollowerOrderRelationEntity orderRelationEntity = followFollowerOrderRelationDao.selectNowOneByorderId(oldOrderId); + if (orderRelationEntity != null) { + orderRelationEntity.setOrderId(newOrderId); + orderRelationEntity.setOrderType(FollowFollowerOrderRelationEntity.ORDER_TYPE_HISTORY); + followFollowerOrderRelationDao.updateById(orderRelationEntity); + } + } } -- Gitblit v1.9.1