修改接口响应结构

This commit is contained in:
wangxiu 2026-07-09 23:59:46 +08:00
parent 9ecbba9b84
commit f9bfc0a6ce
4 changed files with 28 additions and 54 deletions

View File

@ -8,7 +8,12 @@ public class PaymentProfileResponse {
private String code;
private String message;
private Integer status;
private String responseId;
private Map<String, Object> data;
}
private DataNode data;
@Data
public static class DataNode {
private Integer status;
private Map<String, Object> result;
}
}

View File

@ -14,9 +14,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
/**
* 印尼支付行为画像 — 特征查询,缓存/日志/调用委托给 {@link GenericApiService}
@ -27,11 +25,6 @@ public class PaymentProfileService {
private static final Logger log = LoggerFactory.getLogger(PaymentProfileService.class);
private static final ApiType API_TYPE = ApiType.ID_PAYMENT_PROF_ADVANCED;
private static final Set<String> FEATURE_FIELDS = Set.of(
"app_behavior", "loan_behavior", "repay_behavior",
"time_structure", "delinq_monitor", "flow_anomaly"
);
@Autowired
private GenericApiService genericApiService;
@ -72,17 +65,6 @@ public class PaymentProfileService {
} catch (JsonProcessingException e) {
throw new ApiCallException("PARSE_ERROR", "Failed to parse Fortispay response: " + e.getMessage(), null);
} catch (ApiCallException e) {
// genericApiService.logError(
// API_TYPE.getConfigGroup(),
// API_TYPE.getThirdPartyCode(),
// API_TYPE.getApiCode(),
// ftRequest,
// weOrderNo,
// xRequestId,
// e.getCode() + ": " + e.getMessage(),
// e.getReqUrl(),
// e.getReqHeaders()
// );
throw e;
}
}
@ -116,19 +98,15 @@ public class PaymentProfileService {
}
JsonNode data = node.get("data");
if (data != null) {
response.setStatus(data.path("status").asInt());
PaymentProfileResponse.DataNode dataNode = new PaymentProfileResponse.DataNode();
dataNode.setStatus(data.path("status").asInt());
JsonNode result = data.get("result");
if (result != null) {
@SuppressWarnings("unchecked")
Map<String, Object> resultMap = objectMapper.convertValue(result, Map.class);
Map<String, Object> filtered = new LinkedHashMap<>();
for (String field : FEATURE_FIELDS) {
if (resultMap.containsKey(field)) {
filtered.put(field, resultMap.get(field));
}
}
response.setData(filtered);
dataNode.setResult(resultMap);
}
response.setData(dataNode);
}
return response;
}

View File

@ -2,7 +2,7 @@
-- 联调环境:api_url = https://openapi-dev.fortispaytech.com/data-service/query/IdPaymentProfAdvanced
-- 生产环境:api_url = https://openapi.fortispaytech.com/data-service/query/IdPaymentProfAdvanced
-- auth_config 为 AES 加密存储,明文: {"secret_id":"xxx","secret_key":"yyy"}
-- auth_config 为 AES 加密存储(使用AuthConfigEncryptor类中的工具),明文: {"secret_id":"xxx","secret_key":"yyy"}
-- 联调环境:auth_config = eUh5XEM+MyeY3/n9+c+BVcOTBQPccDhaRyzcpROYjCMRJ3+wu3s05/M1l/LP6ooOGbdZtD7T1YNmyoVtwpwkx3szkpi36DoAyV1s3hsBm5daeILFXfgJjIOBKLfbP9RWVdX7zYGxrQ4H/j7MmHqZew==
-- 生产环境:auth_config = eUh5XEM+MyeY3/n9+c+BVcOTBQPccDhaRyzcpROYjCMRJ3+wu3s05/M1l/LP6ooOaZG/07mJkMOFzCZTAg8kTRfFztaTZkzVvlhkWBg4SyeZeo0XgQ6gZk4zmi1Odj0wVdX7zYGxrQ4H/j7MmHqZew==
INSERT INTO `third_party_config` (

View File

@ -57,22 +57,16 @@
## 响应体
返回以下 6 个特征字段:
- `app_behavior` — 申请行为变量
- `loan_behavior` — 放款行为变量
- `repay_behavior` — 还款行为变量
- `time_structure` — 行为时间结构变量
- `delinq_monitor` — 逾期行为监控
- `flow_anomaly` — 资金流量异常监控变量
服务透传三方接口原始响应,不做字段裁剪。
| 字段 | 类型 | 说明 |
|---|---|-------------------------------------------|
| code | String | 响应码,`"0"` 表示成功,更多请查看富通接口规范.pdf 常见响应编码表 |
| message | String | 提示消息,如 `"success"` |
| status | Integer | 查询状态,仅code为 `"0"` 时有值(`1` = 查得,`0` = 未查得) |
| responseId | String | 三方响应的唯一标识ID |
| data | Object | 结果数据(Map),仅code为 `"0"` 时不为null |
| data | Object | 数据节点,包含 status 和 result |
| data.status | Integer | 查询状态,仅code为 `"0"` 时有值(`1` = 查得,`0` = 未查得) |
| data.result | Object | 结果数据(Map),三方返回的原始 result 对象 |
### 成功响应示例
@ -80,15 +74,17 @@
{
"code": "0",
"message": "success",
"status": 1,
"responseId": "0b5a09b6ea7d77dbbbb92e05dc9744ad",
"data": {
"app_behavior": { "..." : "..." },
"loan_behavior": { "..." : "..." },
"repay_behavior": { "..." : "..." },
"time_structure": { "..." : "..." },
"delinq_monitor": { "..." : "..." },
"flow_anomaly": { "..." : "..." }
"status": 1,
"result": {
"app_behavior": { "..." : "..." },
"loan_behavior": { "..." : "..." },
"repay_behavior": { "..." : "..." },
"time_structure": { "..." : "..." },
"delinq_monitor": { "..." : "..." },
"flow_anomaly": { "..." : "..." }
}
}
}
```
@ -99,15 +95,10 @@
{
"code": "0",
"message": "success",
"status": 0,
"responseId": "0b5a09b6ea7d77dbbbb92e05dc9744ad",
"data": {
"app_behavior": { "..." : null },
"loan_behavior": { "..." : null },
"repay_behavior": { "..." : null },
"time_structure": { "..." : null },
"delinq_monitor": { "..." : null },
"flow_anomaly": { "..." : null }
"status": 0,
"result": null
}
}
```