Administrator
2025-12-11 9b50e4457d7d950697167b053f7f266634c469c7
feat(okxNewPrice): 优化订单状态检查与下单控制逻辑

- 统一导入 okxWs 包下所有类,简化代码结构
- 在 CaoZuoServiceImpl 中增加下单状态判断,防止重复下单
- 在 OrderInfoWs 中过滤非 LIVE 状态订单,避免无效处理
- 下单成功后设置订单状态为 ORDER_LIVE 并记录 clOrdId
- 在 TradeOrderWs 中增加下单状态检查,确保下单流程安全
- 添加日志提示正在下单中的状态,增强调试信息可读性
3 files modified
15 ■■■■ changed files
src/main/java/com/xcong/excoin/modules/okxNewPrice/celue/CaoZuoServiceImpl.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/OrderInfoWs.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/TradeOrderWs.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/okxNewPrice/celue/CaoZuoServiceImpl.java
@@ -1,10 +1,7 @@
package com.xcong.excoin.modules.okxNewPrice.celue;
import cn.hutool.core.util.StrUtil;
import com.xcong.excoin.modules.okxNewPrice.okxWs.AccountWs;
import com.xcong.excoin.modules.okxNewPrice.okxWs.InstrumentsWs;
import com.xcong.excoin.modules.okxNewPrice.okxWs.PositionsWs;
import com.xcong.excoin.modules.okxNewPrice.okxWs.TradeOrderWs;
import com.xcong.excoin.modules.okxNewPrice.okxWs.*;
import com.xcong.excoin.modules.okxNewPrice.okxWs.enums.CoinEnums;
import com.xcong.excoin.modules.okxNewPrice.okxWs.enums.OrderParamEnums;
import com.xcong.excoin.modules.okxNewPrice.wangge.WangGeQueue;
@@ -57,6 +54,10 @@
        String state = (String) redisUtils.get(instrumentsStateKey);
        log.info("开始执行操作CaoZuoServiceImpl......{}",state);
        String live = (String) redisUtils.get(TradeOrderWs.ORDERWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":state");
        if (!CoinEnums.ORDER_LIVE.getCode().equals( live)){
            log.warn("正在下单中,等待下单结束...");
        }
        // 获取合约执行操作状态
        String outStr = (String) redisUtils.get(instrumentsOutKey);
        if (OrderParamEnums.OUT_YES.getValue().equals(outStr) && OrderParamEnums.STATE_3.getValue().equals(state)){
src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/OrderInfoWs.java
@@ -87,6 +87,7 @@
                                && clOrdId.equals(clOrdIdStr)
                                && StrUtil.isNotBlank(stateStr)
                                && state.equals(stateStr)
                                && !CoinEnums.ORDER_LIVE.getCode().equals(state)
                ){
                    boolean setResult = false;
                    String outStr = (String) redisUtils.get(InstrumentsWs.INSTRUMENTSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":out");
@@ -96,6 +97,7 @@
                        setResult = redisUtils.set(InstrumentsWs.INSTRUMENTSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":state", OrderParamEnums.STATE_1.getValue(), 0);
                    }
                    if (setResult){
                        redisUtils.set(TradeOrderWs.ORDERWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":state", CoinEnums.ORDER_LIVE.getCode(), 0);
                        log.info("订单详情-币种: {}, 自定义编号: {}, 订单状态: {}", CoinEnums.HE_YUE.getCode(), clOrdId, OrderParamEnums.STATE_1.getValue());
                    }
                }
src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/TradeOrderWs.java
@@ -28,6 +28,10 @@
            log.warn("止损了,下次再战...");
            return;
        }
        String live = (String) redisUtils.get(ORDERWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":state");
        if (!CoinEnums.ORDER_LIVE.getCode().equals( live)){
            log.warn("正在下单中,等待下单结束...");
        }
        String buyCnt = null;
        String ctval = getRedisValue(redisUtils, InstrumentsWs.INSTRUMENTSWS_CHANNEL, ":ctVal");