f
This commit is contained in:
@@ -7,10 +7,10 @@ import (
|
|||||||
|
|
||||||
"tyapi-server/internal/domains/api/dto"
|
"tyapi-server/internal/domains/api/dto"
|
||||||
"tyapi-server/internal/domains/api/services/processors"
|
"tyapi-server/internal/domains/api/services/processors"
|
||||||
"tyapi-server/internal/infrastructure/external/shujubao"
|
"tyapi-server/internal/infrastructure/external/haiyuapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProcessQCXGA8V3Request QCXGA8V3 全国车辆配置查验(车五项+使用性质+承保) API 处理方法(使用数据宝服务示例)
|
// ProcessQCXGA8V3Request QCXGA8V3 全国车辆配置查验(车五项+使用性质+承保)API 处理方法(海宇API)
|
||||||
func ProcessQCXGA8V3Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
func ProcessQCXGA8V3Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||||
var paramsDto dto.QCXGA8V3Req
|
var paramsDto dto.QCXGA8V3Req
|
||||||
if err := json.Unmarshal(params, ¶msDto); err != nil {
|
if err := json.Unmarshal(params, ¶msDto); err != nil {
|
||||||
@@ -21,28 +21,24 @@ func ProcessQCXGA8V3Request(ctx context.Context, params []byte, deps *processors
|
|||||||
return nil, errors.Join(processors.ErrInvalidParam, err)
|
return nil, errors.Join(processors.ErrInvalidParam, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建数据宝入参:姓名、身份证、手机号、银行卡号(sign 外的业务参数可按需 AES 加密后作为 bodyData)
|
if deps.HaiyuapiService == nil {
|
||||||
reqParams := map[string]interface{}{
|
return nil, errors.Join(processors.ErrSystem, errors.New("海宇API服务未初始化"))
|
||||||
"key": "df456d08f3cd3420e2806a6d0181c454",
|
|
||||||
"vin": paramsDto.VinCode,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 最终请求 URL = https://api.chinadatapay.com/communication + 拼接接口地址值,如 personal/197
|
reqParams := map[string]interface{}{
|
||||||
apiPath := "/government/traffic/10533"
|
"vin_code": paramsDto.VinCode,
|
||||||
data, err := deps.ShujubaoService.CallAPI(ctx, apiPath, reqParams)
|
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, shujubao.ErrDatasource) {
|
|
||||||
return nil, errors.Join(processors.ErrDatasource, err)
|
|
||||||
}
|
}
|
||||||
if errors.Is(err, shujubao.ErrQueryEmpty) {
|
|
||||||
|
respBytes, err := deps.HaiyuapiService.CallAPI(ctx, "QCXGA8V3", reqParams)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, haiyuapi.ErrNotFound) {
|
||||||
return nil, errors.Join(processors.ErrNotFound, err)
|
return nil, errors.Join(processors.ErrNotFound, err)
|
||||||
}
|
}
|
||||||
|
if errors.Is(err, haiyuapi.ErrDatasource) {
|
||||||
|
return nil, errors.Join(processors.ErrDatasource, err)
|
||||||
|
}
|
||||||
return nil, errors.Join(processors.ErrSystem, err)
|
return nil, errors.Join(processors.ErrSystem, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
respBytes, err := json.Marshal(data)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Join(processors.ErrSystem, err)
|
|
||||||
}
|
|
||||||
return respBytes, nil
|
return respBytes, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user