Administrator
6 days ago 875336c34c44092126fa6ae6a7a6ef98953eac22
fix(gateApi): 修复网格交易止盈订单ID计算逻辑

- 在短期止盈订单计算中添加索引偏移修正
- 在长期止盈订单计算中添加索引偏移修正
- 确保止盈订单ID按预期递增或递减
- 防止重复创建相同ID的止盈订单
1 files modified
7 ■■■■■ changed files
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -651,6 +651,9 @@
                    int shortExcessCount = shortExcess.divide(shortGridQty, 0, RoundingMode.DOWN).intValue();
                    for (int i = 0; i < shortExcessCount; i++) {
                        int tpGridId = shortGridElement.getId() - 2 - i;
                        if (i > 0){
                            tpGridId = tpGridId - 1;
                        }
                        GridElement tpElem = GridElement.findById(tpGridId);
                        if (tpElem == null || tpElem.getShortTakeProfitOrderId() != null) {
                            continue;
@@ -693,6 +696,10 @@
                    int longExcessCount = longExcess.divide(longGridQty, 0, RoundingMode.DOWN).intValue();
                    for (int i = 0; i < longExcessCount; i++) {
                        int tpGridId = longGridElement.getId() + 2 + i;
                        if (i > 0){
                            tpGridId = tpGridId + 1;
                        }
                        GridElement tpElem = GridElement.findById(tpGridId);
                        if (tpElem == null || tpElem.getLongTakeProfitOrderId() != null) {
                            continue;