src/main/java/com/xcong/excoin/modules/contract/service/ContractHoldOrderService.java
@@ -4,6 +4,8 @@ import com.xcong.excoin.common.response.Result; import com.xcong.excoin.modules.contract.entity.ContractHoldOrderEntity; import com.xcong.excoin.modules.contract.parameter.dto.*; import com.xcong.excoin.modules.documentary.entity.FollowTraderInfoEntity; import com.xcong.excoin.modules.member.entity.MemberEntity; import com.xcong.excoin.rabbit.pricequeue.OrderModel; import org.apache.ibatis.annotations.Param; @@ -49,4 +51,6 @@ public Result changePositionType(); public void calHoldFeeAmountForBondAmount(); public void sendFollowOrder(FollowTraderInfoEntity traderInfoEntity, ContractHoldOrderEntity holdOrderEntity); } src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java
@@ -385,6 +385,18 @@ // 若该用户为交易员且开启带单模式,则发送带单异步 if (isOpenFollow) { sendFollowOrder(tradeInfo, holdOrderEntity); // ThreadPoolUtils.sendFollowOrderTask(holdOrderEntity.getId()); } // 提交成功 return Result.ok(MessageSourceUtils.getString("member_service_0024")); } // 提交失败 return Result.fail(MessageSourceUtils.getString("member_service_0067")); } @Override public void sendFollowOrder(FollowTraderInfoEntity tradeInfo, ContractHoldOrderEntity holdOrderEntity) { FollowFollowerOrderRelationEntity relationEntity = new FollowFollowerOrderRelationEntity(); relationEntity.setIsShow(FollowFollowerOrderRelationEntity.IS_SHOW_Y); relationEntity.setMemberId(holdOrderEntity.getMemberId()); @@ -396,15 +408,7 @@ followFollowerOrderRelationDao.insert(relationEntity); followProducer.sendAddFollowOrder(holdOrderEntity.getId()); // ThreadPoolUtils.sendFollowOrderTask(holdOrderEntity.getId()); } // 提交成功 return Result.ok(MessageSourceUtils.getString("member_service_0024")); } // 提交失败 return Result.fail(MessageSourceUtils.getString("member_service_0067")); } /** * 全仓模式--若当前已经存在持仓,则合并当前持仓 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); } } } }