Administrator
4 days ago aeb69b0cff3d1770e741ccc12be65fe026ff773d
src/main/java/com/xcong/excoin/modules/gateApi/GateConfigPersistenceService.java
@@ -111,6 +111,14 @@
                .addPositionQuantity(dto.getAddPositionQuantity() > 0 ? dto.getAddPositionQuantity() : 1)
                .maxPositionPerSide(dto.getMaxPositionPerSide())
                .addPositionStartThreshold(dto.getAddPositionStartThreshold() >= 0 ? dto.getAddPositionStartThreshold() : 1)
                .placeExcessTakeProfit(normalizeTakeProfitMode(dto.getPlaceExcessTakeProfit()))
                .dualStopLossEnabled(nvl(dto.getDualStopLossEnabled(), false))
                .longStopLossPrice(dto.getLongStopLossPrice())
                .shortStopLossPrice(dto.getShortStopLossPrice())
                .tpTriggerOppositeAddEnabled(nvl(dto.getTpTriggerOppositeAddEnabled(), false))
                .tpTriggerOppositeAddQuantity(dto.getTpTriggerOppositeAddQuantity() != null && dto.getTpTriggerOppositeAddQuantity() > 0 ? dto.getTpTriggerOppositeAddQuantity() : 0)
                .baseTakeProfitPerGrid(dto.getBaseTakeProfitPerGrid() != null && dto.getBaseTakeProfitPerGrid().compareTo(BigDecimal.ZERO) > 0 ? dto.getBaseTakeProfitPerGrid() : BigDecimal.ZERO)
                .baseTakeProfitGridCount(dto.getBaseTakeProfitGridCount() != null && dto.getBaseTakeProfitGridCount() > 0 ? dto.getBaseTakeProfitGridCount() : 0)
                .build();
    }
@@ -140,4 +148,24 @@
    private static <T> T nvl(T value, T fallback) {
        return value != null ? value : fallback;
    }
    /**
     * 归一化止盈挂单模式,兼容旧版 boolean 配置(旧 JSON 的 true/false 会被 Jackson 反序列化为字符串)。
     */
    private static String normalizeTakeProfitMode(String raw) {
        if (raw == null || raw.trim().isEmpty()) {
            return GateConfig.EXCESS_TP_OFF;
        }
        switch (raw.trim()) {
            case "off":
                return GateConfig.EXCESS_TP_OFF;
            case "true":
            case "concentrated":
                return GateConfig.EXCESS_TP_CONCENTRATED;
            case "dispersed":
                return GateConfig.EXCESS_TP_DISPERSED;
            default:
                return GateConfig.EXCESS_TP_OFF;
        }
    }
}