add 11/29
This commit is contained in:
@@ -38,9 +38,9 @@ func ProcessQYGL2ACDRequest(ctx context.Context, params []byte, deps *processors
|
||||
|
||||
reqData := map[string]interface{}{
|
||||
"data": map[string]interface{}{
|
||||
"entname": encryptedEntName,
|
||||
"realname": encryptedLegalPerson,
|
||||
"idcard": encryptedEntCode,
|
||||
"name": encryptedEntName,
|
||||
"oper_name": encryptedLegalPerson,
|
||||
"keyword": encryptedEntCode,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -54,4 +54,4 @@ func ProcessQYGL2ACDRequest(ctx context.Context, params []byte, deps *processors
|
||||
}
|
||||
|
||||
return respBytes, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,6 @@ func ProcessQYGL2B5CRequest(ctx context.Context, params []byte, deps *processors
|
||||
|
||||
// 两选一校验:EntName 和 EntCode 至少传一个
|
||||
var keyword string
|
||||
if paramsDto.EntName != "" && paramsDto.EntCode != "" {
|
||||
return nil, fmt.Errorf("%s: %w", processors.ErrInvalidParam, errors.New("企业名称和企业统一信用代码只能传其中一个"))
|
||||
}
|
||||
if paramsDto.EntName == "" && paramsDto.EntCode == "" {
|
||||
return nil, fmt.Errorf("%s: %w", processors.ErrInvalidParam, errors.New("必须提供企业名称或企业统一信用代码中的其中一个"))
|
||||
}
|
||||
@@ -39,7 +36,7 @@ func ProcessQYGL2B5CRequest(ctx context.Context, params []byte, deps *processors
|
||||
}
|
||||
|
||||
reqData := map[string]interface{}{
|
||||
"keyword": keyword,
|
||||
"keyword": keyword,
|
||||
"authorized": paramsDto.Authorized,
|
||||
}
|
||||
|
||||
@@ -60,4 +57,3 @@ func ProcessQYGL2B5CRequest(ctx context.Context, params []byte, deps *processors
|
||||
|
||||
return respBytes, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"tyapi-server/internal/domains/api/dto"
|
||||
"tyapi-server/internal/domains/api/services/processors"
|
||||
@@ -21,24 +22,40 @@ func ProcessQYGL2S0WRequest(ctx context.Context, params []byte, deps *processors
|
||||
return nil, errors.Join(processors.ErrInvalidParam, err)
|
||||
}
|
||||
|
||||
// 条件验证逻辑
|
||||
// 验证逻辑
|
||||
var nameValue string
|
||||
if paramsDto.Type == "per" {
|
||||
// 当失信被执行人类型为个人时,idCardNum 必填
|
||||
if paramsDto.IDCardNum == "" {
|
||||
return nil, errors.Join(processors.ErrInvalidParam, errors.New("当失信被执行人类型为个人时,身份证件号不能为空"))
|
||||
// 个人查询:idCardNum 必填
|
||||
fmt.Print("个人")
|
||||
nameValue = paramsDto.Name
|
||||
fmt.Println("nameValue", nameValue)
|
||||
if paramsDto.IDCard == "" {
|
||||
fmt.Print("个人身份证件号不能为空")
|
||||
return nil, fmt.Errorf("%s: %w", processors.ErrInvalidParam, errors.New("当失信被执行人类型为个人时,身份证件号不能为空"))
|
||||
|
||||
}
|
||||
} else if paramsDto.Type == "ent" {
|
||||
// 当查询为企业时,name 和 entMark 两者必填其一
|
||||
if paramsDto.Name == "" && paramsDto.EntMark == "" {
|
||||
return nil, errors.Join(processors.ErrInvalidParam, errors.New("当查询为企业时,企业名称和企业标识统一代码注册号两者必填其一"))
|
||||
// 企业查询:name 和 entMark 两者必填其一
|
||||
if paramsDto.EntName == "" && paramsDto.EntCode == "" {
|
||||
return nil, fmt.Errorf("%s: %w", processors.ErrInvalidParam, errors.New("当查询为企业时,企业名称和企业标识统一代码注册号两者必填其一"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 构建请求数据,直接传递姓名、身份证、手机号
|
||||
// 确定使用哪个值作为 name
|
||||
if paramsDto.Type == "ent" && paramsDto.EntName != "" {
|
||||
nameValue = paramsDto.EntName
|
||||
} else {
|
||||
nameValue = paramsDto.EntCode
|
||||
}
|
||||
|
||||
fmt.Println("dto2s0w", paramsDto)
|
||||
|
||||
// 构建请求数据(不传的参数也需要添加,值为空字符串)
|
||||
reqData := map[string]interface{}{
|
||||
"name": paramsDto.Name,
|
||||
"idCardNum": paramsDto.IDCardNum,
|
||||
"entMark": paramsDto.EntMark,
|
||||
"idCardNum": paramsDto.IDCard,
|
||||
"name": nameValue,
|
||||
"entMark": paramsDto.EntCode,
|
||||
"type": paramsDto.Type,
|
||||
}
|
||||
|
||||
|
||||
@@ -24,18 +24,18 @@ func ProcessQYGL4B2ERequest(ctx context.Context, params []byte, deps *processors
|
||||
// 设置默认值
|
||||
pageSize := paramsDto.PageSize
|
||||
if pageSize == 0 {
|
||||
pageSize = 20
|
||||
pageSize = int64(20)
|
||||
}
|
||||
pageNum := paramsDto.PageNum
|
||||
if pageNum == 0 {
|
||||
pageNum = 1
|
||||
pageNum = int64(1)
|
||||
}
|
||||
|
||||
// 构建API调用参数
|
||||
apiParams := map[string]string{
|
||||
"keyword": paramsDto.EntCode,
|
||||
"pageSize": strconv.Itoa(pageSize),
|
||||
"pageNum": strconv.Itoa(pageNum),
|
||||
"pageSize": strconv.FormatInt(pageSize, 10),
|
||||
"pageNum": strconv.FormatInt(pageNum, 10),
|
||||
}
|
||||
|
||||
// 调用天眼查API - 税收违法
|
||||
|
||||
@@ -24,18 +24,18 @@ func ProcessQYGL5A3CRequest(ctx context.Context, params []byte, deps *processors
|
||||
// 设置默认值
|
||||
pageSize := paramsDto.PageSize
|
||||
if pageSize == 0 {
|
||||
pageSize = 20
|
||||
pageSize = int64(20)
|
||||
}
|
||||
pageNum := paramsDto.PageNum
|
||||
if pageNum == 0 {
|
||||
pageNum = 1
|
||||
pageNum = int64(1)
|
||||
}
|
||||
|
||||
// 构建API调用参数
|
||||
apiParams := map[string]string{
|
||||
"keyword": paramsDto.EntCode,
|
||||
"pageSize": strconv.Itoa(pageSize),
|
||||
"pageNum": strconv.Itoa(pageNum),
|
||||
"pageSize": strconv.FormatInt(pageSize, 10),
|
||||
"pageNum": strconv.FormatInt(pageNum, 10),
|
||||
}
|
||||
|
||||
// 调用天眼查API - 对外投资历史
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package qygl
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"tyapi-server/internal/domains/api/dto"
|
||||
"tyapi-server/internal/domains/api/services/processors"
|
||||
"tyapi-server/internal/infrastructure/external/xingwei"
|
||||
)
|
||||
|
||||
// Processqygl5a9tRequest QYGL5A9T API处理方法 - 全国企业各类工商风险统计数量查询
|
||||
func ProcessQYGL5A9TRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||
|
||||
var paramsDto dto.QYGL5A9TReq
|
||||
if err := json.Unmarshal(params, ¶msDto); err != nil {
|
||||
return nil, errors.Join(processors.ErrSystem, err)
|
||||
}
|
||||
|
||||
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
|
||||
return nil, errors.Join(processors.ErrInvalidParam, err)
|
||||
}
|
||||
|
||||
// 两选一校验:EntName 和 EntCode 至少传一个
|
||||
var keyword string
|
||||
if paramsDto.EntName == "" && paramsDto.EntCode == "" {
|
||||
return nil, fmt.Errorf("%s: %w", processors.ErrInvalidParam, errors.New("必须提供企业名称或企业统一信用代码中的其中一个"))
|
||||
}
|
||||
|
||||
// 确定使用哪个值作为 keyword
|
||||
if paramsDto.EntName != "" {
|
||||
keyword = paramsDto.EntName
|
||||
} else {
|
||||
keyword = paramsDto.EntCode
|
||||
}
|
||||
|
||||
// 构建请求数据,
|
||||
reqData := map[string]interface{}{
|
||||
"nameCode": keyword,
|
||||
}
|
||||
|
||||
// 调用行为数据API,使用指定的project_id
|
||||
projectID := "CDJ-1054665422426533888"
|
||||
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
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"tyapi-server/internal/domains/api/dto"
|
||||
"tyapi-server/internal/domains/api/services/processors"
|
||||
@@ -20,24 +21,16 @@ func ProcessQYGL5F6ARequest(ctx context.Context, params []byte, deps *processors
|
||||
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
|
||||
return nil, errors.Join(processors.ErrInvalidParam, err)
|
||||
}
|
||||
fmt.Println("paramsDto", paramsDto)
|
||||
|
||||
// 构建请求数据,将项目规范的字段名转换为 XingweiService 需要的字段名
|
||||
reqData := map[string]interface{}{
|
||||
"idCardNum": paramsDto.IDCard,
|
||||
}
|
||||
|
||||
// 如果传了身份证,则添加到请求数据中
|
||||
if paramsDto.MobileNo != "" {
|
||||
reqData["phoneNumber"] = paramsDto.MobileNo
|
||||
}
|
||||
|
||||
// 如果传了企业统一信用代码,则添加到请求数据中
|
||||
if paramsDto.EntCode != "" {
|
||||
reqData["ucc"] = paramsDto.EntCode
|
||||
}
|
||||
|
||||
// 调用行为数据API,使用指定的project_id
|
||||
projectID := "CDJ-1101695397213958144"
|
||||
fmt.Println("reqData", reqData)
|
||||
respBytes, err := deps.XingweiService.CallAPI(ctx, projectID, reqData)
|
||||
if err != nil {
|
||||
if errors.Is(err, xingwei.ErrNotFound) {
|
||||
|
||||
@@ -42,4 +42,4 @@ func ProcessQYGL6F2DRequest(ctx context.Context, params []byte, deps *processors
|
||||
}
|
||||
|
||||
return respBytes, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"tyapi-server/internal/domains/api/dto"
|
||||
"tyapi-server/internal/domains/api/services/processors"
|
||||
"tyapi-server/internal/infrastructure/external/zhicha"
|
||||
)
|
||||
|
||||
// ProcessQYGL6S1BRequest QYGL6S1B API处理方法 - 董监高司法综合信息核验
|
||||
@@ -21,30 +22,28 @@ func ProcessQYGL6S1BRequest(ctx context.Context, params []byte, deps *processors
|
||||
return nil, errors.Join(processors.ErrInvalidParam, err)
|
||||
}
|
||||
|
||||
encryptedPhone, err := deps.ZhichaService.Encrypt(paramsDto.IDCard)
|
||||
encryptedIdCard, err := deps.ZhichaService.Encrypt(paramsDto.IDCard)
|
||||
if err != nil {
|
||||
return nil, errors.Join(processors.ErrSystem, err)
|
||||
}
|
||||
|
||||
// 构建API调用参数
|
||||
apiParams := map[string]string{
|
||||
"idCard": encryptedPhone,
|
||||
reqData := map[string]interface{}{
|
||||
"idCard": encryptedIdCard,
|
||||
"authorized": paramsDto.Authorized,
|
||||
}
|
||||
|
||||
// 调用天眼查API -
|
||||
response, err := deps.TianYanChaService.CallAPI(ctx, "ZCI043", apiParams)
|
||||
respData, err := deps.ZhichaService.CallAPI(ctx, "ZCI043", reqData)
|
||||
if err != nil {
|
||||
return nil, convertTianYanChaError(err)
|
||||
if errors.Is(err, zhicha.ErrDatasource) {
|
||||
return nil, errors.Join(processors.ErrDatasource, err)
|
||||
} else {
|
||||
return nil, errors.Join(processors.ErrSystem, err)
|
||||
}
|
||||
}
|
||||
|
||||
// 检查天眼查API调用是否成功
|
||||
if !response.Success {
|
||||
return nil, errors.Join(processors.ErrDatasource, errors.New(response.Message))
|
||||
}
|
||||
|
||||
// 返回天眼查响应数据
|
||||
respBytes, err := json.Marshal(response.Data)
|
||||
// 将响应数据转换为JSON字节
|
||||
respBytes, err := json.Marshal(respData)
|
||||
if err != nil {
|
||||
return nil, errors.Join(processors.ErrSystem, err)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"tyapi-server/internal/domains/api/dto"
|
||||
@@ -16,6 +17,7 @@ func ProcessQYGL7C1ARequest(ctx context.Context, params []byte, deps *processors
|
||||
if err := json.Unmarshal(params, ¶msDto); err != nil {
|
||||
return nil, errors.Join(processors.ErrSystem, err)
|
||||
}
|
||||
fmt.Println("paramsDto", paramsDto)
|
||||
|
||||
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
|
||||
return nil, errors.Join(processors.ErrInvalidParam, err)
|
||||
@@ -24,18 +26,18 @@ func ProcessQYGL7C1ARequest(ctx context.Context, params []byte, deps *processors
|
||||
// 设置默认值
|
||||
pageSize := paramsDto.PageSize
|
||||
if pageSize == 0 {
|
||||
pageSize = 20
|
||||
pageSize = int64(20)
|
||||
}
|
||||
pageNum := paramsDto.PageNum
|
||||
if pageNum == 0 {
|
||||
pageNum = 1
|
||||
pageNum = int64(1)
|
||||
}
|
||||
|
||||
// 构建API调用参数
|
||||
apiParams := map[string]string{
|
||||
"keyword": paramsDto.EntCode,
|
||||
"pageSize": strconv.Itoa(pageSize),
|
||||
"pageNum": strconv.Itoa(pageNum),
|
||||
"pageSize": strconv.FormatInt(pageSize, 10),
|
||||
"pageNum": strconv.FormatInt(pageNum, 10),
|
||||
}
|
||||
|
||||
// 调用天眼查API - 经营异常
|
||||
|
||||
@@ -24,18 +24,18 @@ func ProcessQYGL7D9ARequest(ctx context.Context, params []byte, deps *processors
|
||||
// 设置默认值
|
||||
pageSize := paramsDto.PageSize
|
||||
if pageSize == 0 {
|
||||
pageSize = 20
|
||||
pageSize = int64(20)
|
||||
}
|
||||
pageNum := paramsDto.PageNum
|
||||
if pageNum == 0 {
|
||||
pageNum = 1
|
||||
pageNum = int64(1)
|
||||
}
|
||||
|
||||
// 构建API调用参数
|
||||
apiParams := map[string]string{
|
||||
"keyword": paramsDto.EntCode,
|
||||
"pageSize": strconv.Itoa(pageSize),
|
||||
"pageNum": strconv.Itoa(pageNum),
|
||||
"pageSize": strconv.FormatInt(pageSize, 10),
|
||||
"pageNum": strconv.FormatInt(pageNum, 10),
|
||||
}
|
||||
|
||||
// 调用天眼查API - 欠税公告
|
||||
|
||||
@@ -24,18 +24,18 @@ func ProcessQYGL8B4DRequest(ctx context.Context, params []byte, deps *processors
|
||||
// 设置默认值
|
||||
pageSize := paramsDto.PageSize
|
||||
if pageSize == 0 {
|
||||
pageSize = 20
|
||||
pageSize = int64(20)
|
||||
}
|
||||
pageNum := paramsDto.PageNum
|
||||
if pageNum == 0 {
|
||||
pageNum = 1
|
||||
pageNum = int64(1)
|
||||
}
|
||||
|
||||
// 构建API调用参数
|
||||
apiParams := map[string]string{
|
||||
"keyword": paramsDto.EntCode,
|
||||
"pageSize": strconv.Itoa(pageSize),
|
||||
"pageNum": strconv.Itoa(pageNum),
|
||||
"pageSize": strconv.FormatInt(pageSize, 10),
|
||||
"pageNum": strconv.FormatInt(pageNum, 10),
|
||||
}
|
||||
|
||||
// 调用天眼查API - 融资历史
|
||||
|
||||
@@ -24,18 +24,18 @@ func ProcessQYGL9E2FRequest(ctx context.Context, params []byte, deps *processors
|
||||
// 设置默认值
|
||||
pageSize := paramsDto.PageSize
|
||||
if pageSize == 0 {
|
||||
pageSize = 20
|
||||
pageSize = int64(20)
|
||||
}
|
||||
pageNum := paramsDto.PageNum
|
||||
if pageNum == 0 {
|
||||
pageNum = 1
|
||||
pageNum = int64(1)
|
||||
}
|
||||
|
||||
// 构建API调用参数
|
||||
apiParams := map[string]string{
|
||||
"keyword": paramsDto.EntCode,
|
||||
"pageSize": strconv.Itoa(pageSize),
|
||||
"pageNum": strconv.Itoa(pageNum),
|
||||
"pageSize": strconv.FormatInt(pageSize, 10),
|
||||
"pageNum": strconv.FormatInt(pageNum, 10),
|
||||
}
|
||||
|
||||
// 调用天眼查API - 行政处罚
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// Processqygl9t1qRequest QYGL9T1Q API处理方法 - 全国企业借贷意向验证查询_V1
|
||||
func ProcessQYGL9T1QRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||
|
||||
var paramsDto dto.QYGL9T1QReq
|
||||
if err := json.Unmarshal(params, ¶msDto); err != nil {
|
||||
return nil, errors.Join(processors.ErrSystem, err)
|
||||
}
|
||||
|
||||
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
|
||||
return nil, errors.Join(processors.ErrInvalidParam, err)
|
||||
}
|
||||
|
||||
// 构建请求数据,直接传递姓名、身份证、手机号等
|
||||
reqData := map[string]interface{}{
|
||||
"ownerType": paramsDto.OwnerType,
|
||||
"phoneNumber": paramsDto.MobileNo,
|
||||
"idCardNum": paramsDto.IDCard,
|
||||
"name": paramsDto.Name,
|
||||
"searchKey": paramsDto.EntCode, // 企业统一信用代码和注册号两者必填其一
|
||||
"authAuthorizeFileCode": paramsDto.Authorized,
|
||||
}
|
||||
|
||||
// 调用行为数据API,使用指定的project_id
|
||||
projectID := "CDJ-1078965351139438592"
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user