From 0e2ecf41e6ff7dadd8b2f5bd18d118e88f23d9eb Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Tue, 30 Mar 2021 16:37:13 +0800 Subject: [PATCH] modify --- src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 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 06164aa..3829dbd 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 @@ -39,6 +39,7 @@ import com.xcong.excoin.modules.member.service.MemberWalletContractService; import com.xcong.excoin.modules.platform.entity.PlatformTradeSettingEntity; import com.xcong.excoin.rabbit.pricequeue.OrderModel; +import com.xcong.excoin.rabbit.producer.FollowProducer; import com.xcong.excoin.rabbit.producer.OrderProducer; import com.xcong.excoin.utils.*; import lombok.extern.slf4j.Slf4j; @@ -104,6 +105,9 @@ private RedisUtils redisUtils; @Resource private FollowOrderOperationService followOrderOperationService; + + @Resource + private FollowProducer followProducer; public void dealOrderFromMq(List<OrderModel> list, Integer type) { if (CollectionUtils.isNotEmpty(list)) { @@ -625,6 +629,16 @@ contractHoldOrderEntity.setOpeningType(ContractHoldOrderEntity.OPENING_TYPE_LESS); } + // 判断是否开启了带单 + boolean isOpenFollow = false; + FollowTraderInfoEntity tradeInfo = null; + if (MemberEntity.IS_TRADER_Y.equals(memberEntity.getIsTrader())) { + tradeInfo = followTraderInfoDao.selectTraderInfoByMemberId(memberEntity.getId()); + if (FollowTraderInfoEntity.ISOPEN_Y.equals(tradeInfo.getIsOpen())) { + isOpenFollow = true; + } + } + //持仓单赋值 contractHoldOrderEntity.setMemberId(memId); contractHoldOrderEntity.setIsCanClosing(ContractHoldOrderEntity.ORDER_CAN_CLOSING_Y); @@ -647,6 +661,7 @@ contractHoldOrderEntity.setTradeType(ContractHoldOrderEntity.TRADE_TYPE_LIMIT); contractHoldOrderEntity.setOperateNo(1); contractHoldOrderEntity.setSymbolCntSale(contractHoldOrderEntity.getSymbolCnt()); + contractHoldOrderEntity.setContractType(isOpenFollow ? ContractOrderEntity.CONTRACTTYPE_DOCUMENTARY : ContractOrderEntity.CONTRACTTYPE_NORMAL); contractHoldOrderService.save(contractHoldOrderEntity); // 需要一个历史插入 @@ -675,6 +690,12 @@ //返佣 ThreadPoolUtils.calReturnMoney(memberEntity.getId(), openFeePrice, contractOrderEntity, AgentReturnEntity.ORDER_TYPE_OPEN); + + // 若该用户为交易员且开启带单模式,则发送带单异步 + if (isOpenFollow) { + contractHoldOrderService.sendFollowOrder(tradeInfo, contractHoldOrderEntity); + } + } } } @@ -916,10 +937,10 @@ QueryWrapper<FollowFollowerSettingEntity> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("member_id",coinsOrder.getMemberId()); FollowFollowerSettingEntity followFollowerSettingEntity = followFollowerSettingDao.selectOne(queryWrapper); - if(ObjectUtil.isNotEmpty(followFollowerSettingEntity)){ - Long traderMemberId = followFollowerSettingEntity.getTraderMemberId(); - followFollowerProfitDao.updateFollowerProfitByTradeMemberId(coinsOrder.getBondAmount().negate(), coinsOrder.getBondAmount().negate(), traderMemberId, memberEntity.getId()); - } +// if(ObjectUtil.isNotEmpty(followFollowerSettingEntity)){ +// Long traderMemberId = followFollowerSettingEntity.getTraderMemberId(); +// followFollowerProfitDao.updateFollowerProfitByTradeMemberId(coinsOrder.getBondAmount().negate(), coinsOrder.getBondAmount().negate(), traderMemberId, memberEntity.getId()); +// } FollowTraderInfoEntity followTraderInfoEntity = followTraderInfoDao.selectById(followFollowerSettingEntity.getTraderId()); //更新跟随者-订单关联表 updateFollowOrderRelation(coinsOrder.getId(), contractOrderEntity.getId()); -- Gitblit v1.9.1