From 305c085fd92fe752709db81edb1d8f46e8638757 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Wed, 10 Jun 2026 15:43:37 +0800
Subject: [PATCH] fix(gateApi): 修复网格交易止损触发和日志记录问题

---
 src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java b/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
index 0e9aaaa..77e3cc2 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -543,12 +543,12 @@
         }
 
         GridElement longStopLossElem = GridElement.findByLongStopLossOrderId(orderId);
-        if (longStopLossElem != null && longPositionSize.compareTo(BigDecimal.ZERO) > 0) {
+        if (longStopLossElem != null && longPositionSize.compareTo(BigDecimal.ZERO) > 0 && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0")) {
             handleLongStopLossTriggered(longStopLossElem);
             return;
         }
         GridElement shortStopLossElem = GridElement.findByShortStopLossOrderId(orderId);
-        if (shortStopLossElem != null && shortPositionSize.compareTo(BigDecimal.ZERO) > 0) {
+        if (shortStopLossElem != null && shortPositionSize.compareTo(BigDecimal.ZERO) > 0 && StrUtil.isNotEmpty(tradeId) && !tradeId.equals("0")) {
             handleShortStopLossTriggered(shortStopLossElem);
             return;
         }
@@ -873,12 +873,9 @@
 
                     GridElement cancelGridElement = GridElement.findById(newEntryGrid.getUpId());
                     if (cancelGridElement != null && cancelGridElement.isHasLongOrder()) {
-                        /**
-                         * 看是否有多仓挂单,有就取消
-                         */
+                        longEntryTraderIdParam(cancelGridElement, null, false);
                         executor.cancelConditionalOrder(cancelGridElement.getLongOrderId(), oid -> {
-                            longEntryTraderIdParam(cancelGridElement, null, false);
-                            log.info("[Gate] 多仓仓位归零, 取消gridId:{}的多单", cancelGridElement);
+                            log.info("[Gate] 多仓仓位归零, 取消gridId:{}的多单", cancelGridElement.getId());
                         });
                     }
                 }
@@ -925,9 +922,9 @@
                      * 看是否有空仓挂单,有就取消
                      */
                     if (cancelGridElement != null && cancelGridElement.isHasShortOrder()) {
+                        shortEntryTraderIdParam(cancelGridElement, null, false);
                         executor.cancelConditionalOrder(cancelGridElement.getShortOrderId(), oid -> {
-                            shortEntryTraderIdParam(cancelGridElement, null, false);
-                            log.info("[Gate] 空仓仓位归零, 取消gridId:{}的多单", cancelGridElement);
+                            log.info("[Gate] 空仓仓位归零, 取消gridId:{}的多单", cancelGridElement.getId());
                         });
                     }
 

--
Gitblit v1.9.1