new feature

This commit is contained in:
2025-04-24 13:59:33 +08:00
parent bb79a92176
commit 3671c40c46
2 changed files with 50 additions and 4 deletions

View File

@@ -243,6 +243,7 @@ var requestProcessors = map[string]func(*ApiRequestService, context.Context, []b
"G09XM02": (*ApiRequestService).ProcessG09XM02Request,
"G10XM02": (*ApiRequestService).ProcessG10XM02Request,
"G11BJ06": (*ApiRequestService).ProcessG11BJ06Request,
"G29BJ05": (*ApiRequestService).ProcessG29BJ05Request,
}
// PreprocessRequestApi 调用指定的请求处理函数
@@ -2518,3 +2519,48 @@ func (a *ApiRequestService) ProcessG11BJ06Request(ctx context.Context, params []
Data: jsonResult,
}, nil
}
func (a *ApiRequestService) ProcessG29BJ05Request(ctx context.Context, params []byte) (*APIInternalResult, error) {
idCard := gjson.GetBytes(params, "id_card")
name := gjson.GetBytes(params, "name")
mobile := gjson.GetBytes(params, "mobile")
if !idCard.Exists() || !name.Exists() || !mobile.Exists() {
return nil, errors.New("api请求, G29BJ05, 获取相关参数失败")
}
request := map[string]interface{}{
"data": map[string]interface{}{
"id": a.westDexService.Encrypt(idCard.String()),
"name": a.westDexService.Encrypt(name.String()),
"cell": a.westDexService.Encrypt(mobile.String()),
},
}
resp, err := a.westDexService.CallAPI("G29BJ05", request)
if err != nil && resp == nil {
return nil, fmt.Errorf("偿贷压力查询失败: %v", err)
}
// 获取响应码和偿贷压力标志
code := gjson.GetBytes(resp, "code").String()
flagDebtRepayStress := gjson.GetBytes(resp, "flag_debtrepaystress").String()
// 判断是否成功
if code != "00" || flagDebtRepayStress != "1" {
return nil, fmt.Errorf("偿贷压力查询失败: %+v", resp)
}
// 获取偿贷压力分数
drsNoDebtScore := gjson.GetBytes(resp, "drs_nodebtscore").String()
// 构建结果
result := map[string]interface{}{
"score": drsNoDebtScore,
}
// 将结果转为JSON
jsonResult, err := json.Marshal(result)
if err != nil {
return nil, fmt.Errorf("处理偿贷压力查询结果失败: %v", err)
}
return &APIInternalResult{
Data: jsonResult,
}, nil
}