add 11.29

This commit is contained in:
2025-11-29 15:16:24 +08:00
parent 11fe48809e
commit 500264e9e5

View File

@@ -0,0 +1,65 @@
package qygl
import (
"context"
"encoding/json"
"errors"
"tyapi-server/internal/domains/api/dto"
"tyapi-server/internal/domains/api/services/processors"
"tyapi-server/internal/infrastructure/external/xingwei"
)
// Processqygl2s0wRequest QYGL2S0W API处理方法 - 失信被执行企业个人查询
func ProcessQYGL2S0WRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.QYGL2S0WReq
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)
}
// 条件验证逻辑
if paramsDto.Type == "per" {
// 当失信被执行人类型为个人时idCardNum 必填
if paramsDto.IDCardNum == "" {
return nil, errors.Join(processors.ErrInvalidParam, errors.New("当失信被执行人类型为个人时,身份证件号不能为空"))
}
} else if paramsDto.Type == "ent" {
// 当查询为企业时name 和 entMark 两者必填其一
if paramsDto.Name == "" && paramsDto.EntMark == "" {
return nil, errors.Join(processors.ErrInvalidParam, errors.New("当查询为企业时,企业名称和企业标识统一代码注册号两者必填其一"))
}
}
// 构建请求数据,直接传递姓名、身份证、手机号
reqData := map[string]interface{}{
"name": paramsDto.Name,
"idCardNum": paramsDto.IDCardNum,
"entMark": paramsDto.EntMark,
"type": paramsDto.Type,
}
// 调用行为数据API使用指定的project_id
projectID := "CDJ-1079244717102657536"
respBytes, err := deps.XingweiService.CallAPI(ctx, projectID, reqData)
if err != nil {
if errors.Is(err, xingwei.ErrNotFound) {
// 查空情况,返回特定的查空错误
return nil, errors.Join(processors.ErrNotFound, err)
} else if errors.Is(err, xingwei.ErrDatasource) {
// 数据源错误
return nil, errors.Join(processors.ErrDatasource, err)
} else if errors.Is(err, xingwei.ErrSystem) {
// 系统错误
return nil, errors.Join(processors.ErrSystem, err)
} else {
// 其他未知错误
return nil, errors.Join(processors.ErrSystem, err)
}
}
return respBytes, nil
}