Helius
2020-08-31 237d0b600b55ecbf3d4f241568862ae7b498e983
modify entrsut open order when more/less/bomb/entrustClose
11 files modified
134 ■■■■■ changed files
src/main/java/com/xcong/excoin/common/contants/AppContants.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractEntrustOrderServiceImpl.java 12 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java 22 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java 19 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/documentary/service/impl/FollowOrderOperationServiceImpl.java 8 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/rabbit/init/OrderProducerInit.java 20 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderModel.java 16 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderOperatePriceService.java 8 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/rabbit/pricequeue/WebsocketPriceService.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/utils/CalculateUtil.java 8 ●●●● patch | view | raw | blame | history
src/test/java/com/xcong/excoin/WholeTest.java 11 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/common/contants/AppContants.java
@@ -83,4 +83,6 @@
     */
    public static final String RABBIT_TYPE = "rabbit_type_";
    public static final String MEMBER_TYPE = "member_type_";
}
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());
@@ -216,12 +216,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());
@@ -371,10 +371,10 @@
        if (i > 0) {
            // 发送委托消息
            if (holdOrderEntity.getOpeningType() == ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_MORE) {
                OrderModel model = new OrderModel(entrustOrder.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(entrustOrder.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));
            }
        }
src/main/java/com/xcong/excoin/modules/contract/service/impl/ContractHoldOrderServiceImpl.java
@@ -340,7 +340,7 @@
            memberWalletContractDao.increaseWalletContractBalanceById(prePaymentAmount.negate(), openFeePrice.negate(), null, walletContract.getId());
            // 发送爆仓消息
            sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), forceClosingPrice, holdOrderEntity.getSymbol(), holdOrderEntity.getOperateNo());
            sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), forceClosingPrice, holdOrderEntity.getSymbol(), holdOrderEntity.getOperateNo(), holdOrderEntity.getMemberId());
            // 计算佣金
            ThreadPoolUtils.calReturnMoney(memberEntity.getId(), contractOrderEntity.getOpeningFeeAmount(), contractOrderEntity, AgentReturnEntity.ORDER_TYPE_OPEN);
@@ -549,7 +549,7 @@
        contractHoldOrderDao.updateById(holdOrderEntity);
        // 将待平张数放入缓存
        redisUtils.set(AppContants.CLOSING_ORDER_PREFIX + holdOrderEntity.getId(), wholeCloseOrderDto.getCount());
        redisUtils.set(AppContants.CLOSING_ORDER_PREFIX + holdOrderEntity.getId(), wholeCloseOrderDto.getCount(), 30);
        // 发送平仓消息
        List<Long> ids = new ArrayList<>();
@@ -656,23 +656,23 @@
            if (ContractHoldOrderEntity.OPENING_TYPE_MORE == holdOrderEntity.getOpeningType()) {
                // 开多止盈
                if (stopProfitPrice != null) {
                    model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_PROFIT.getValue(), stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol());
                    model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_PROFIT.getValue(), stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol(), holdOrderEntity.getMemberId());
                    producer.sendPriceOperate(JSONObject.toJSONString(model));
                }
                // 开多止损
                if (stopLessPrice != null) {
                    model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_LESS.getValue(), stopLessPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol());
                    model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_LESS.getValue(), stopLessPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol(), holdOrderEntity.getMemberId());
                    producer.sendPriceOperate(JSONObject.toJSONString(model));
                }
            } else {
                // 开空止盈
                if (stopProfitPrice != null) {
                    model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_PROFIT.getValue(), stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol());
                    model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_PROFIT.getValue(), stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol(), holdOrderEntity.getMemberId());
                    producer.sendPriceOperate(JSONObject.toJSONString(model));
                }
                // 开空止损
                if (stopLessPrice != null) {
                    model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_LESS.getValue(), stopLessPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol());
                    model = new OrderModel(holdOrderEntity.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_LESS.getValue(), stopLessPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), holdOrderEntity.getSymbol(), holdOrderEntity.getMemberId());
                    producer.sendPriceOperate(JSONObject.toJSONString(model));
                }
            }
@@ -716,7 +716,7 @@
        if (i > 0) {
            // 发送爆仓消息
            sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), forceClosingPrice, holdOrderEntity.getSymbol(), holdOrderEntity.getOperateNo());
            sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), forceClosingPrice, holdOrderEntity.getSymbol(), holdOrderEntity.getOperateNo(), holdOrderEntity.getMemberId());
            return Result.ok("调整成功");
        }
        return Result.fail("调整失败");
@@ -905,20 +905,20 @@
                    contractHoldOrderDao.updateById(holdOrderEntity);
                    // 发送爆仓消息
                    sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), newForcePrice, holdOrderEntity.getSymbol(), holdOrderEntity.getOperateNo());
                    sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), newForcePrice, holdOrderEntity.getSymbol(), holdOrderEntity.getOperateNo(), holdOrderEntity.getMemberId());
                }
            }
        }
    }
    public void sendOrderBombMsg(Long id, int type, BigDecimal forceClosingPrice, String symbol, int operateNo) {
    public void sendOrderBombMsg(Long id, int type, BigDecimal forceClosingPrice, String symbol, int operateNo, Long memberId) {
        OrderModel model = null;
        // 开多
        if (ContractHoldOrderEntity.OPENING_TYPE_MORE == type) {
            model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo);
            model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo, memberId);
            // 开空
        } else {
            model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo);
            model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo, memberId);
        }
        producer.sendPriceOperate(JSONObject.toJSONString(model));
    }
src/main/java/com/xcong/excoin/modules/contract/service/impl/OrderWebsocketServiceImpl.java
@@ -651,11 +651,11 @@
                // 市价
                if (coinsCoinsOrder.getEntrustType() == 1) {
                    // 开多
                    OrderModel model = new OrderModel(contractHoldOrderEntity.getId(), 6, contractHoldOrderEntity.getForceClosingPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), coinsCoinsOrder.getSymbol(), 1);
                    OrderModel model = new OrderModel(contractHoldOrderEntity.getId(), 6, contractHoldOrderEntity.getForceClosingPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), coinsCoinsOrder.getSymbol(), 1, coinsCoinsOrder.getMemberId());
                    producer.sendPriceOperate(JSONObject.toJSONString(model));
                } else {
                    // 开空
                    OrderModel model = new OrderModel(contractHoldOrderEntity.getId(), 7, contractHoldOrderEntity.getForceClosingPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), coinsCoinsOrder.getSymbol(), 1);
                    OrderModel model = new OrderModel(contractHoldOrderEntity.getId(), 7, contractHoldOrderEntity.getForceClosingPrice().setScale(8, RoundingMode.HALF_UP).toPlainString(), coinsCoinsOrder.getSymbol(), 1, coinsCoinsOrder.getMemberId());
                    producer.sendPriceOperate(JSONObject.toJSONString(model));
                }
                // 扣除手续费
@@ -671,6 +671,21 @@
    private void wholeEntrustOrder(ContractEntrustOrderEntity entrustOrder) {
        log.info("全仓委托逻辑处理:{}", entrustOrder.getOrderNo());
        List<Object> types = redisUtils.lGet(AppContants.MEMBER_TYPE + entrustOrder.getMemberId(), 0, -1);
        int i = 1;
        while (true) {
            if (CollUtil.isEmpty(types)) {
                break;
            }
            log.info("存在止盈/止损/爆仓/委托平仓,等待 -- {}", i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            i++;
        }
        MemberWalletContractEntity wallet = memberWalletContractService.findWalletContractByMemberIdAndSymbol(entrustOrder.getMemberId(), CoinTypeConvert.convertContractTypeToCoin(entrustOrder.getSymbol()));
        PlatformTradeSettingEntity tradeSettingEntity = cacheSettingUtils.getTradeSetting();
src/main/java/com/xcong/excoin/modules/documentary/service/impl/FollowOrderOperationServiceImpl.java
@@ -197,7 +197,7 @@
                    followFollowerOrderRelationDao.insert(relationEntity);
                    // 发送爆仓消息
                    sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), forceClosingPrice, holdOrderEntity.getSymbol(), holdOrderEntity.getOperateNo());
                    sendOrderBombMsg(holdOrderEntity.getId(), holdOrderEntity.getOpeningType(), forceClosingPrice, holdOrderEntity.getSymbol(), holdOrderEntity.getOperateNo(), holdOrderEntity.getMemberId());
                    // 计算佣金
                    ThreadPoolUtils.calReturnMoney(memberEntity.getId(), contractOrderEntity.getOpeningFeeAmount(), contractOrderEntity, AgentReturnEntity.ORDER_TYPE_OPEN);
@@ -215,14 +215,14 @@
        }
    }
    public void sendOrderBombMsg(Long id, int type, BigDecimal forceClosingPrice, String symbol, int operateNo) {
    public void sendOrderBombMsg(Long id, int type, BigDecimal forceClosingPrice, String symbol, int operateNo, Long memberId) {
        OrderModel model = null;
        // 开多
        if (ContractHoldOrderEntity.OPENING_TYPE_MORE == type) {
            model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo);
            model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo, memberId);
            // 开空
        } else {
            model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo);
            model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo, memberId);
        }
        producer.sendPriceOperate(JSONObject.toJSONString(model));
    }
src/main/java/com/xcong/excoin/rabbit/init/OrderProducerInit.java
@@ -69,7 +69,7 @@
                        if (forceSetPrice != null) {
                            if (forceSetPrice.compareTo(BigDecimal.ZERO) >= 0) {
                                OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceSetPrice.toPlainString(),
                                        order.getSymbol(), order.getOperateNo());
                                        order.getSymbol(), order.getOperateNo(), order.getMemberId());
                                producer.sendPriceOperate(JSONObject.toJSONString(model));
                            }
                        }
@@ -79,7 +79,7 @@
                    if (stopLossPrice != null && stopLossPrice.compareTo(BigDecimal.ZERO) > 0) {
                        OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_LESS.getValue(),
                                stopLossPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
                                order.getSymbol());
                                order.getSymbol(), order.getMemberId());
                        producer.sendPriceOperate(JSONObject.toJSONString(model));
                    }
                    // 止盈
@@ -87,7 +87,7 @@
                    if (stopProfitPrice != null && stopProfitPrice.compareTo(BigDecimal.ZERO) > 0) {
                        OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_MORE_STOP_PROFIT.getValue(),
                                stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
                                order.getSymbol());
                                order.getSymbol(), order.getMemberId());
                        producer.sendPriceOperate(JSONObject.toJSONString(model));
                    }
@@ -99,7 +99,7 @@
                        if (forceSetPrice != null) {
                            if (forceSetPrice.compareTo(BigDecimal.ZERO) >= 0) {
                                OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceSetPrice.toPlainString(),
                                        order.getSymbol(), order.getOperateNo());
                                        order.getSymbol(), order.getOperateNo(), order.getMemberId());
                                producer.sendPriceOperate(JSONObject.toJSONString(model));
                            }
                        }
@@ -109,7 +109,7 @@
                    if (stopLossPrice != null && stopLossPrice.compareTo(BigDecimal.ZERO) > 0) {
                        OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_LESS.getValue(),
                                stopLossPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
                                order.getSymbol());
                                order.getSymbol(), order.getMemberId());
                        producer.sendPriceOperate(JSONObject.toJSONString(model));
                    }
                    // 止盈
@@ -117,7 +117,7 @@
                    if (stopProfitPrice != null && stopProfitPrice.compareTo(BigDecimal.ZERO) > 0) {
                        OrderModel model = new OrderModel(order.getId(), RabbitPriceTypeEnum.CLOSE_LESS_STOP_PROFIT.getValue(),
                                stopProfitPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
                                order.getSymbol());
                                order.getSymbol(), order.getMemberId());
                        producer.sendPriceOperate(JSONObject.toJSONString(model));
                    }
                }
@@ -151,20 +151,20 @@
                    // 开多委托
                    model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(),
                            entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
                            order.getSymbol());
                            order.getSymbol(), order.getMemberId());
                } else if (ContractEntrustOrderEntity.ENTRUST_TYPE_OPEN_LESS == entrustType){
                    model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_OPEN_LESS.getValue(),
                            entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
                            order.getSymbol());
                            order.getSymbol(), order.getMemberId());
                } else if (ContractEntrustOrderEntity.ENTRUST_TYPE_CLOSE_MORE == entrustType) {
                    model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_MORE.getValue(),
                            entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
                            order.getSymbol());
                            order.getSymbol(), order.getMemberId());
                } else {
                    model = new OrderModel(order.getId(), RabbitPriceTypeEnum.ENTRUST_CLOSE_LESS.getValue(),
                            entrustPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(),
                            order.getSymbol());
                            order.getSymbol(), order.getMemberId());
                }
                producer.sendPriceOperate(JSONObject.toJSONString(model));
            }
src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderModel.java
@@ -25,20 +25,24 @@
     */
    private Integer operateNo;
    private Long memberId;
    public OrderModel(Long orderId, Integer type, String price, String symbol){
    public OrderModel(Long orderId, Integer type, String price, String symbol, Long memberId){
        this.orderId= orderId;
        this.type= type;
        this.price= price;
        this.symbol= symbol;
        this.memberId = memberId;
    }
    public OrderModel(Long orderId,Integer type,String price, String symbol,Integer operateNo){
    public OrderModel(Long orderId,Integer type,String price, String symbol,Integer operateNo, Long memberId){
        this.orderId= orderId;
        this.type= type;
        this.price= price;
        this.symbol= symbol;
        this.operateNo= operateNo;
        this.memberId = memberId;
    }
    public Integer getOperateNo() {
@@ -80,4 +84,12 @@
    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }
    public Long getMemberId() {
        return memberId;
    }
    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }
}
src/main/java/com/xcong/excoin/rabbit/pricequeue/OrderOperatePriceService.java
@@ -60,12 +60,12 @@
            // 判断这个单的这个类型是否有
//            if (CollectionUtils.isNotEmpty(list)) {
                // 新增
                OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo());
                OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo(), order.getMemberId());
                list.add(orderModel);
//            }
        } else {
            List<OrderModel> list = new ArrayList<OrderModel>();
            OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo());
            OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo(), order.getMemberId());
            list.add(orderModel);
            orderMap.put(price, list);
        }
@@ -95,12 +95,12 @@
            // 判断这个单的这个类型是否有
//            if (CollectionUtils.isNotEmpty(list)) {
                // 新增
                OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo());
                OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo(), order.getMemberId());
                list.add(orderModel);
//            }
        } else {
            List<OrderModel> list = new ArrayList<OrderModel>();
            OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo());
            OrderModel orderModel = new OrderModel(orderId, type, price, null,order.getOperateNo(), order.getMemberId());
            list.add(orderModel);
            orderMap.put(price, list);
        }
src/main/java/com/xcong/excoin/rabbit/pricequeue/WebsocketPriceService.java
@@ -87,6 +87,7 @@
        }
        redisUtils.lSet(AppContants.RABBIT_TYPE + model.getOrderId(), orderTypes, 10);
        redisUtils.lSet(AppContants.MEMBER_TYPE + model.getMemberId(), orderTypes, 5);
    }
    // 处理消息 正序的 包括
@@ -204,6 +205,13 @@
            // 2:开多6:爆仓平多
            // 10:止盈平空11:止损平多
            for (OrderModel model : orderModelList) {
                /*
                   问题: 1、逐仓: 当行情大时,若设置的止损点与爆仓过于接近,则可能会出现直接爆仓,而不止损的情况
                        2、全仓: 止盈价/止损价 设置的与委托平仓价相同,需优先处理止盈/止损
                   解决: 将订单ID作为Key, 该订单执行的队列类型集合作为value, 用于在执行爆仓、委托平仓时,是否存在止盈/止损,若存在则不执行该爆仓和委托平仓
                 */
                addExecType(model);
                // 开空止盈
                List<OrderModel> kkzyList = new ArrayList<OrderModel>();
                // 开多止损
src/main/java/com/xcong/excoin/utils/CalculateUtil.java
@@ -137,7 +137,7 @@
            if (forceSetPrice.compareTo(BigDecimal.ZERO) > 0) {
                log.info("id:{}, type:{}, forceSetPrice:{}, symbol:{}, operateNo:{}", id, type, forceSetPrice, symbol, operateNo);
                sendOrderBombMsg(id, type, forceSetPrice, symbol, operateNo);
                sendOrderBombMsg(id, type, forceSetPrice, symbol, operateNo, memberEntity.getId());
            }
        }
    }
@@ -221,14 +221,14 @@
     */
    private static void sendOrderBombMsg(Long id, int type, BigDecimal forceClosingPrice, String symbol, int operateNo) {
    private static void sendOrderBombMsg(Long id, int type, BigDecimal forceClosingPrice, String symbol, int operateNo, Long memberId) {
        OrderModel model = null;
        // 开多
        if (ContractHoldOrderEntity.OPENING_TYPE_MORE == type) {
            model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo);
            model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_MORE_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo, memberId);
            // 开空
        } else {
            model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo);
            model = new OrderModel(id, RabbitPriceTypeEnum.CLOSE_LESS_BOMB.getValue(), forceClosingPrice.setScale(8, RoundingMode.HALF_UP).toPlainString(), symbol, operateNo, memberId);
        }
        SpringContextHolder.getBean(OrderProducer.class).sendPriceOperate(JSONObject.toJSONString(model));
    }
src/test/java/com/xcong/excoin/WholeTest.java
@@ -96,14 +96,6 @@
    @Autowired
    private OrderProducer orderProducer;
    @Test
    public void sendMsg() {
        List<OrderModel> list = new ArrayList<>();
        OrderModel orderModel = new OrderModel(1L, RabbitPriceTypeEnum.ENTRUST_OPEN_MORE.getValue(), "111", "BTC");
        list.add(orderModel);
        orderProducer.sendLimitClose(JSONObject.toJSONString(list));
    }
    // 面值*(多单张数*多单开仓价-空单张数*空单开仓价)-余额-已实现盈亏 / 面值*(多单张数-空单张数)-(维持保证金率+TAKER手续费)*面值*(开多张数+开空张数)
@@ -144,6 +136,9 @@
    @Test
    public void redisTest() {
        for (int i = 827; i < 999; i++) {
            redisUtils.del(AppContants.CLOSING_ORDER_PREFIX + i);
        }
    }
}