diff --git a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/LogisticsServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/LogisticsServiceImpl.java index c9b4d84..2778874 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/LogisticsServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/jarvis/service/impl/LogisticsServiceImpl.java @@ -199,7 +199,8 @@ public class LogisticsServiceImpl implements ILogisticsService { logger.info("企业微信推送设置接收人 - 订单ID: {}, 分销标识: {}, 接收人: {}", order.getId(), distributionMark, touser); } else { - logger.warn("未找到分销标识对应的接收人配置 - 订单ID: {}, 分销标识: {}", + // 未配置接收人时,使用远程接口的默认接收人,这是正常情况 + logger.info("未找到分销标识对应的接收人配置,将使用远程接口默认接收人 - 订单ID: {}, 分销标识: {}", order.getId(), distributionMark); } @@ -327,6 +328,31 @@ public class LogisticsServiceImpl implements ILogisticsService { return true; } + // 检查是否包含明确的错误标识 + String responseStr = pushResult.toLowerCase(); + boolean hasErrorKeyword = responseStr.contains("\"error\"") || responseStr.contains("\"fail\"") || + responseStr.contains("\"failed\"") || responseStr.contains("\"errmsg\""); + + // 如果包含错误标识,检查是否有明确的错误码 + if (hasErrorKeyword) { + if (code != null && code < 0) { + logger.warn("推送失败(检测到错误标识和负错误码) - code: {}, 完整响应: {}", code, pushResult); + return false; + } + if (errcode != null && !"0".equals(errcode) && !errcode.isEmpty()) { + logger.warn("推送失败(检测到错误标识和非零错误码) - errcode: {}, 完整响应: {}", errcode, pushResult); + return false; + } + } + + // 如果响应是有效的JSON,且没有明确的错误标识,视为成功 + // 因为远程接口有默认接收人,即使没有配置接收人,推送也应该成功 + // 如果响应格式特殊(不是标准格式),只要没有错误,也视为成功 + if (!hasErrorKeyword) { + logger.info("推送成功(响应格式有效且无错误标识,使用默认接收人) - 完整响应: {}", pushResult); + return true; + } + // 如果所有判断都失败,记录详细信息 logger.warn("推送响应未确认成功 - code: {}, success: {}, status: {}, msg: {}, errcode: {}, 完整响应: {}", code, successFlag, status, message, errcode, pushResult);