add QCXG7K2N

This commit is contained in:
2026-07-05 00:48:37 +08:00
parent c08f40d212
commit 192ed5d009
9 changed files with 264 additions and 112 deletions

View File

@@ -0,0 +1,61 @@
package qcxg
import (
"context"
"encoding/json"
"errors"
"tyapi-server/internal/domains/api/dto"
"tyapi-server/internal/domains/api/services/processors"
"tyapi-server/internal/infrastructure/external/haiyuapi"
"tyapi-server/internal/infrastructure/external/shujubao"
)
// ProcessQCXG7K2NRequest QCXG7K2N 人车核验加强版:
// 优先走数据宝 10093人车关系核验 ETC查无结果时降级走海宇 QCXGX2X6行驶证信息核验V2
func ProcessQCXG7K2NRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.QCXG7K2NReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
data, err := deps.ShujubaoService.CallAPI(ctx, "/communication/personal/10093", map[string]interface{}{
"key": "a2f32fc54b44ebc85b97a2aaff1734ec",
"carNo": paramsDto.PlateNo,
"name": paramsDto.Name,
})
if err == nil {
respBytes, marshalErr := json.Marshal(data)
if marshalErr != nil {
return nil, errors.Join(processors.ErrSystem, marshalErr)
}
return respBytes, nil
}
if !errors.Is(err, shujubao.ErrQueryEmpty) {
if errors.Is(err, shujubao.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
}
return nil, errors.Join(processors.ErrSystem, err)
}
if deps.HaiyuapiService == nil {
return nil, errors.Join(processors.ErrSystem, errors.New("海宇API服务未初始化"))
}
respBytes, err := deps.HaiyuapiService.CallAPI(ctx, "QCXGX2X6", map[string]interface{}{
"plate_no": paramsDto.PlateNo,
"name": paramsDto.Name,
})
if err != nil {
if errors.Is(err, haiyuapi.ErrNotFound) {
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 respBytes, nil
}