From 3cc2f68c9746abd93c8ced1832b0317ee8496986 Mon Sep 17 00:00:00 2001 From: wangxiu <1422795692@qq.com> Date: Sat, 22 Aug 2026 14:39:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=B3=BB=E7=BB=9F=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=8F=90=E7=A4=BA=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docking/auth/FortispayHmacAuthStrategy.java | 8 ++++++-- .../lyxh/api/docking/client/GenericApiClient.java | 4 ++-- .../api/docking/service/PaymentProfileService.java | 3 ++- 对接接口文档.md | 14 +++++++------- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/lyxh/api/docking/auth/FortispayHmacAuthStrategy.java b/src/main/java/com/lyxh/api/docking/auth/FortispayHmacAuthStrategy.java index 36926db..c35887f 100644 --- a/src/main/java/com/lyxh/api/docking/auth/FortispayHmacAuthStrategy.java +++ b/src/main/java/com/lyxh/api/docking/auth/FortispayHmacAuthStrategy.java @@ -4,6 +4,8 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.lyxh.api.docking.exception.ApiCallException; import com.lyxh.api.docking.service.SignatureService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; @@ -17,6 +19,8 @@ import org.springframework.stereotype.Component; @Component public class FortispayHmacAuthStrategy implements AuthStrategy { + private static final Logger log = LoggerFactory.getLogger(FortispayHmacAuthStrategy.class); + private final SignatureService signatureService; private final ObjectMapper objectMapper; @@ -38,8 +42,8 @@ public class FortispayHmacAuthStrategy implements AuthStrategy { try { node = objectMapper.readTree(authConfigJson); } catch (Exception e) { - throw new ApiCallException("AUTH_CONFIG_ERROR", - "Failed to parse auth_config: " + e.getMessage(), ""); + log.error("Failed to parse auth_config", e); + throw new ApiCallException("AUTH_CONFIG_ERROR", "Service temporarily unavailable", ""); } String secretId = node.get("secret_id").asText(); String secretKey = node.get("secret_key").asText(); diff --git a/src/main/java/com/lyxh/api/docking/client/GenericApiClient.java b/src/main/java/com/lyxh/api/docking/client/GenericApiClient.java index 1be0025..3422085 100644 --- a/src/main/java/com/lyxh/api/docking/client/GenericApiClient.java +++ b/src/main/java/com/lyxh/api/docking/client/GenericApiClient.java @@ -96,7 +96,7 @@ public class GenericApiClient { log.error("Third-party network error after {} attempts: url={} requestId={}", attempt, url, requestId, e); throw new ApiCallException("NETWORK_ERROR", - "External API unreachable after " + attempt + " attempts", "") + "Connection error", "") .withRequest(url, reqHeadersJson); } } catch (RestClientException e) { @@ -109,7 +109,7 @@ public class GenericApiClient { attempt, url, requestId, e); Integer statusCode = e instanceof HttpStatusCodeException ? ((HttpStatusCodeException) e).getRawStatusCode() : null; - throw new ApiCallException("HTTP_ERROR", e.getMessage(), "") + throw new ApiCallException("HTTP_ERROR", "Service temporarily unavailable", "") .withRequest(url, reqHeadersJson) .withStatusCode(statusCode); } diff --git a/src/main/java/com/lyxh/api/docking/service/PaymentProfileService.java b/src/main/java/com/lyxh/api/docking/service/PaymentProfileService.java index f8dde70..103e58d 100644 --- a/src/main/java/com/lyxh/api/docking/service/PaymentProfileService.java +++ b/src/main/java/com/lyxh/api/docking/service/PaymentProfileService.java @@ -71,7 +71,8 @@ public class PaymentProfileService { JsonNode root = objectMapper.readTree(respJson); return parseResponse(root, filterType); } catch (JsonProcessingException e) { - throw new ApiCallException("PARSE_ERROR", "Failed to parse Fortispay response: " + e.getMessage(), null); + log.error("Failed to parse third-party response: weOrderNo={}", weOrderNo, e); + throw new ApiCallException("PARSE_ERROR", "Service temporarily unavailable", null); } catch (ApiCallException e) { // 插入日志 (调用三方api失败) invokeLogService.logError( diff --git a/对接接口文档.md b/对接接口文档.md index 0b1ea88..6388190 100644 --- a/对接接口文档.md +++ b/对接接口文档.md @@ -73,7 +73,7 @@ ```json { "code": "503", - "message": "External API unreachable after 1 attempts", + "message": "Connection error", "responseId": "a1b2c3d4e5f6789012345678abcdef01", "data": { "status": 0, @@ -82,12 +82,12 @@ } ``` -| HTTP状态码 | code | 说明 | -|---|---|---| -| 400 | 400 | 请求参数校验失败 | -| 502 | 502 | 三方 API HTTP 错误 | -| 503 | 503 | 三方 API 网络不可达 | -| 500 | 500 | 服务内部未知异常 | +| HTTP状态码 | code | 对外 message | 说明 | +|---|---|---|---| +| 400 | 400 | `{字段}: {校验提示}` | 请求参数校验失败 | +| 502 | 502 | `Service temporarily unavailable` | 三方 API HTTP 错误 / 响应解析失败 / 内部配置错误 | +| 503 | 503 | `Connection error` | 三方 API 网络不可达 | +| 500 | 500 | `Internal server error` | 服务内部未知异常 | ---