f
This commit is contained in:
@@ -113,6 +113,19 @@ type QYGL2ACDReq struct {
|
|||||||
LegalPerson string `json:"legal_person" validate:"required,min=1,validName"`
|
LegalPerson string `json:"legal_person" validate:"required,min=1,validName"`
|
||||||
EntCode string `json:"ent_code" validate:"required,validUSCI"`
|
EntCode string `json:"ent_code" validate:"required,validUSCI"`
|
||||||
}
|
}
|
||||||
|
type QYGLUY3SReq struct {
|
||||||
|
EntName string `json:"ent_name" validate:"omitempty,min=1,validEnterpriseName"`
|
||||||
|
EntRegno string `json:"ent_reg_no" validate:"omitempty"`
|
||||||
|
EntCode string `json:"ent_code" validate:"omitempty,validUSCI"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type JRZQOCRYReq struct {
|
||||||
|
PhotoData string `json:"photo_data" validate:"required,validBase64Image"`
|
||||||
|
}
|
||||||
|
type JRZQOCREReq struct {
|
||||||
|
PhotoData string `json:"photo_data" validate:"omitempty,validBase64Image"`
|
||||||
|
ImageUrl string `json:"image_url" validate:"omitempty,url"`
|
||||||
|
}
|
||||||
|
|
||||||
type YYSYK9R4Req struct {
|
type YYSYK9R4Req struct {
|
||||||
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
||||||
@@ -591,6 +604,11 @@ type YYSY8B1CReq struct {
|
|||||||
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type QYGLJ0Q1Req struct {
|
||||||
|
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
||||||
|
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||||
|
Name string `json:"name" validate:"required,min=1,validName"`
|
||||||
|
}
|
||||||
type YYSY6D9AReq struct {
|
type YYSY6D9AReq struct {
|
||||||
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
||||||
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||||
|
|||||||
@@ -178,6 +178,8 @@ func registerAllProcessors(combService *comb.CombService) {
|
|||||||
"QYGLNIO8": qygl.ProcessQYGLNIO8Request, //企业基本信息
|
"QYGLNIO8": qygl.ProcessQYGLNIO8Request, //企业基本信息
|
||||||
"QYGLP0HT": qygl.ProcessQYGLP0HTRequest, //股权穿透
|
"QYGLP0HT": qygl.ProcessQYGLP0HTRequest, //股权穿透
|
||||||
"QYGL5S1I": qygl.ProcessQYGL5S1IRequest, //企业司法涉诉I
|
"QYGL5S1I": qygl.ProcessQYGL5S1IRequest, //企业司法涉诉I
|
||||||
|
"QYGLJ0Q1": qygl.ProcessQYGLJ0Q1Request, //企业股权结构全景查询
|
||||||
|
"QYGLUY3S": qygl.ProcessQYGLUY3SRequest, //企业经营状态全景查询
|
||||||
|
|
||||||
// YYSY系列处理器
|
// YYSY系列处理器
|
||||||
"YYSYD50F": yysy.ProcessYYSYD50FRequest,
|
"YYSYD50F": yysy.ProcessYYSYD50FRequest,
|
||||||
@@ -249,6 +251,7 @@ func registerAllProcessors(combService *comb.CombService) {
|
|||||||
"IVYZX5QZ": ivyz.ProcessIVYZX5QZRequest, //活体检测
|
"IVYZX5QZ": ivyz.ProcessIVYZX5QZRequest, //活体检测
|
||||||
"IVYZX5Q2": ivyz.ProcessIVYZX5Q2Request, //活体识别步骤二
|
"IVYZX5Q2": ivyz.ProcessIVYZX5Q2Request, //活体识别步骤二
|
||||||
"IVYZOCR1": ivyz.ProcessIVYZOCR1Request, //身份证OCR
|
"IVYZOCR1": ivyz.ProcessIVYZOCR1Request, //身份证OCR
|
||||||
|
"IVYZOCR2": ivyz.ProcessIVYZOCR2Request, //身份证OCR2数卖
|
||||||
|
|
||||||
// COMB系列处理器 - 只注册有自定义逻辑的组合包
|
// COMB系列处理器 - 只注册有自定义逻辑的组合包
|
||||||
"COMB86PM": comb.ProcessCOMB86PMRequest, // 有自定义逻辑:重命名ApiCode
|
"COMB86PM": comb.ProcessCOMB86PMRequest, // 有自定义逻辑:重命名ApiCode
|
||||||
|
|||||||
@@ -256,6 +256,9 @@ func (s *FormConfigServiceImpl) getDTOStruct(ctx context.Context, apiCode string
|
|||||||
"QCXG3M7Z": &dto.QCXG3M7ZReq{}, //人车关系核验(ETC)10093 月更
|
"QCXG3M7Z": &dto.QCXG3M7ZReq{}, //人车关系核验(ETC)10093 月更
|
||||||
"JRZQ1P5G": &dto.JRZQ1P5GReq{}, //全国自然人借贷压力指数查询(2)
|
"JRZQ1P5G": &dto.JRZQ1P5GReq{}, //全国自然人借贷压力指数查询(2)
|
||||||
"IVYZOCR1": &dto.IVYZOCR1Req{}, //身份证OCR
|
"IVYZOCR1": &dto.IVYZOCR1Req{}, //身份证OCR
|
||||||
|
"IVYZOCR2": &dto.IVYZOCR1Req{}, //身份证OCR2数卖
|
||||||
|
"QYGLJ0Q1": &dto.QYGLJ0Q1Req{}, //企业股权结构全景查询
|
||||||
|
"QYGLUY3S": &dto.QYGLUY3SReq{}, //企业经营状态全景查询
|
||||||
}
|
}
|
||||||
|
|
||||||
// 优先返回已配置的DTO
|
// 优先返回已配置的DTO
|
||||||
@@ -439,6 +442,7 @@ func (s *FormConfigServiceImpl) generateFieldLabel(jsonTag string) string {
|
|||||||
"ent_name": "企业名称",
|
"ent_name": "企业名称",
|
||||||
"legal_person": "法人姓名",
|
"legal_person": "法人姓名",
|
||||||
"ent_code": "企业代码",
|
"ent_code": "企业代码",
|
||||||
|
"ent_reg_no": "企业注册号",
|
||||||
"auth_date": "授权日期",
|
"auth_date": "授权日期",
|
||||||
"date_range": "日期范围",
|
"date_range": "日期范围",
|
||||||
"time_range": "时间范围",
|
"time_range": "时间范围",
|
||||||
@@ -472,7 +476,7 @@ func (s *FormConfigServiceImpl) generateFieldLabel(jsonTag string) string {
|
|||||||
"notice_model": "车辆型号",
|
"notice_model": "车辆型号",
|
||||||
"vlphoto_data": "行驶证图片",
|
"vlphoto_data": "行驶证图片",
|
||||||
"carplate_type": "车辆号牌类型",
|
"carplate_type": "车辆号牌类型",
|
||||||
"image_url": "行驶证图片地址",
|
"image_url": "入参图片地址",
|
||||||
"reg_url": "车辆登记证图片地址",
|
"reg_url": "车辆登记证图片地址",
|
||||||
"token": "token采集及获取结果时所使用的凭证,有效期2个小时,在此时效内,应用侧可以发起采集请求(重复的采集所触发的结果会被忽略)和结果查询",
|
"token": "token采集及获取结果时所使用的凭证,有效期2个小时,在此时效内,应用侧可以发起采集请求(重复的采集所触发的结果会被忽略)和结果查询",
|
||||||
"vehicle_name": "车型名称",
|
"vehicle_name": "车型名称",
|
||||||
@@ -501,6 +505,7 @@ func (s *FormConfigServiceImpl) generateExampleValue(fieldType reflect.Type, jso
|
|||||||
"ent_name": "示例企业有限公司",
|
"ent_name": "示例企业有限公司",
|
||||||
"legal_person": "王五",
|
"legal_person": "王五",
|
||||||
"ent_code": "91110000123456789X",
|
"ent_code": "91110000123456789X",
|
||||||
|
"ent_reg_no": "110000000123456",
|
||||||
"auth_date": "20240101-20241231",
|
"auth_date": "20240101-20241231",
|
||||||
"date_range": "20240101-20241231",
|
"date_range": "20240101-20241231",
|
||||||
"time_range": "09:00-18:00",
|
"time_range": "09:00-18:00",
|
||||||
@@ -572,6 +577,7 @@ func (s *FormConfigServiceImpl) generatePlaceholder(jsonTag string, fieldType st
|
|||||||
"ent_name": "请输入企业全称",
|
"ent_name": "请输入企业全称",
|
||||||
"legal_person": "请输入法人真实姓名",
|
"legal_person": "请输入法人真实姓名",
|
||||||
"ent_code": "请输入统一社会信用代码",
|
"ent_code": "请输入统一社会信用代码",
|
||||||
|
"ent_reg_no": "请输入企业注册号(统一社会信用代码)",
|
||||||
"auth_date": "请输入授权日期范围(YYYYMMDD-YYYYMMDD)",
|
"auth_date": "请输入授权日期范围(YYYYMMDD-YYYYMMDD)",
|
||||||
"date_range": "请输入日期范围(YYYYMMDD-YYYYMMDD)",
|
"date_range": "请输入日期范围(YYYYMMDD-YYYYMMDD)",
|
||||||
"time_range": "请输入时间范围(HH:MM-HH:MM)",
|
"time_range": "请输入时间范围(HH:MM-HH:MM)",
|
||||||
@@ -593,7 +599,7 @@ func (s *FormConfigServiceImpl) generatePlaceholder(jsonTag string, fieldType st
|
|||||||
"plate_type": "请选择号牌类型(01或02)",
|
"plate_type": "请选择号牌类型(01或02)",
|
||||||
"vin_code": "请输入17位车辆识别代号VIN码",
|
"vin_code": "请输入17位车辆识别代号VIN码",
|
||||||
"return_type": "请选择返回类型",
|
"return_type": "请选择返回类型",
|
||||||
"photo_data": "请输入base64编码的人脸图片(支持JPG、BMP、PNG格式)",
|
"photo_data": "请输入base64编码的入参图片(支持JPG、BMP、PNG格式)",
|
||||||
"ownerType": "请选择企业主类型",
|
"ownerType": "请选择企业主类型",
|
||||||
"type": "请选择查询类型",
|
"type": "请选择查询类型",
|
||||||
"query_reason_id": "请选择查询原因ID",
|
"query_reason_id": "请选择查询原因ID",
|
||||||
@@ -645,6 +651,7 @@ func (s *FormConfigServiceImpl) generateDescription(jsonTag string, validation s
|
|||||||
"ent_name": "请输入企业全称",
|
"ent_name": "请输入企业全称",
|
||||||
"legal_person": "请输入法人真实姓名",
|
"legal_person": "请输入法人真实姓名",
|
||||||
"ent_code": "请输入统一社会信用代码",
|
"ent_code": "请输入统一社会信用代码",
|
||||||
|
"ent_reg_no": "请输入企业注册号(统一社会信用代码)",
|
||||||
"auth_date": "请输入授权日期范围,格式:YYYYMMDD-YYYYMMDD,且日期范围必须包括今天",
|
"auth_date": "请输入授权日期范围,格式:YYYYMMDD-YYYYMMDD,且日期范围必须包括今天",
|
||||||
"date_range": "请输入日期范围,格式:YYYYMMDD-YYYYMMDD",
|
"date_range": "请输入日期范围,格式:YYYYMMDD-YYYYMMDD",
|
||||||
"time_range": "请输入时间范围,格式:HH:MM-HH:MM",
|
"time_range": "请输入时间范围,格式:HH:MM-HH:MM",
|
||||||
|
|||||||
@@ -4170,7 +4170,7 @@ func extractProvinceFromAddress(address string) string {
|
|||||||
// 处理"XX省"格式(最后处理,因为可能与其他模式冲突)
|
// 处理"XX省"格式(最后处理,因为可能与其他模式冲突)
|
||||||
{"省", func(addr string) string {
|
{"省", func(addr string) string {
|
||||||
if idx := strings.Index(addr, "省"); idx > 0 {
|
if idx := strings.Index(addr, "省"); idx > 0 {
|
||||||
return addr[:idx+1]
|
return addr[:idx+len("省")]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}},
|
}},
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package ivyz
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"tyapi-server/internal/domains/api/dto"
|
||||||
|
"tyapi-server/internal/domains/api/services/processors"
|
||||||
|
"tyapi-server/internal/infrastructure/external/shumai"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProcessIVYZOCR2Request IVYZOCR2 OCR识别API处理方法
|
||||||
|
func ProcessIVYZOCR2Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||||
|
var paramsDto dto.IVYZOCR1Req
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
reqFormData := map[string]interface{}{
|
||||||
|
"photo_data": paramsDto.PhotoData,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 以表单方式调用数脉 API;参数在 CallAPIForm 内转为 application/x-www-form-urlencoded
|
||||||
|
apiPath := "/v4/idcard/ocr" // 接口路径,根据数脉文档填写(如 v4/xxx)
|
||||||
|
respBytes, err := deps.ShumaiService.CallAPIForm(ctx, apiPath, reqFormData)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, shumai.ErrNotFound) {
|
||||||
|
// 查无记录情况
|
||||||
|
return nil, errors.Join(processors.ErrNotFound, err)
|
||||||
|
} else if errors.Is(err, shumai.ErrDatasource) {
|
||||||
|
// 数据源错误
|
||||||
|
return nil, errors.Join(processors.ErrDatasource, err)
|
||||||
|
} else if errors.Is(err, shumai.ErrSystem) {
|
||||||
|
// 系统错误
|
||||||
|
return nil, errors.Join(processors.ErrSystem, err)
|
||||||
|
} else {
|
||||||
|
// 其他未知错误
|
||||||
|
return nil, errors.Join(processors.ErrSystem, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return respBytes, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package jrzq
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"tyapi-server/internal/domains/api/dto"
|
||||||
|
"tyapi-server/internal/domains/api/services/processors"
|
||||||
|
"tyapi-server/internal/infrastructure/external/shumai"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProcessJRZQOCREERequest JRZQOCRE 银行卡OCR API 数卖服务示例
|
||||||
|
func ProcessJRZQOCREERequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||||
|
var paramsDto dto.JRZQOCREReq
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
if paramsDto.PhotoData == "" && paramsDto.ImageUrl == "" {
|
||||||
|
return nil, errors.Join(processors.ErrInvalidParam, errors.New("photo_data or image_url is required"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2选1:有值的用对应 key,空则用另一个
|
||||||
|
reqFormData := make(map[string]interface{})
|
||||||
|
if paramsDto.PhotoData != "" {
|
||||||
|
reqFormData["image"] = paramsDto.PhotoData
|
||||||
|
} else {
|
||||||
|
reqFormData["url"] = paramsDto.ImageUrl
|
||||||
|
}
|
||||||
|
// 以表单方式调用数脉 API;参数在 CallAPIForm 内转为 application/x-www-form-urlencoded
|
||||||
|
apiPath := "/v2/bankcard/ocr" // 接口路径,根据数脉文档填写(如 v4/xxx)
|
||||||
|
respBytes, err := deps.ShumaiService.CallAPIForm(ctx, apiPath, reqFormData)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, shumai.ErrDatasource) {
|
||||||
|
// 数据源错误
|
||||||
|
return nil, errors.Join(processors.ErrDatasource, err)
|
||||||
|
} else if errors.Is(err, shumai.ErrSystem) {
|
||||||
|
// 系统错误
|
||||||
|
return nil, errors.Join(processors.ErrSystem, err)
|
||||||
|
} else {
|
||||||
|
// 其他未知错误
|
||||||
|
return nil, errors.Join(processors.ErrSystem, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return respBytes, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package jrzq
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"tyapi-server/internal/domains/api/dto"
|
||||||
|
"tyapi-server/internal/domains/api/services/processors"
|
||||||
|
"tyapi-server/internal/infrastructure/external/shujubao"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProcessJRZQOCRYERequest JRZQOCRY 银行卡OCR API 处理方法(使用数据宝服务示例)
|
||||||
|
func ProcessJRZQOCRYERequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||||
|
var paramsDto dto.JRZQOCRYReq
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建数据宝入参:姓名、身份证、手机号、银行卡号(sign 外的业务参数可按需 AES 加密后作为 bodyData)
|
||||||
|
reqParams := map[string]interface{}{
|
||||||
|
"key": "3ee8e7a7a71870db2c0bf98e7e6b8b5c",
|
||||||
|
"imageId": paramsDto.PhotoData,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 最终请求 URL = https://api.chinadatapay.com/communication + 拼接接口地址值,如 personal/197
|
||||||
|
apiPath := "/trade/user/1986"
|
||||||
|
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) {
|
||||||
|
return nil, errors.Join(processors.ErrNotFound, 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
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
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/shujubao"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProcessQYGLJ0Q1Request QYGLJ0Q1 企业股权结构全景查询 API 处理方法(使用数据宝服务示例)
|
||||||
|
func ProcessQYGLJ0Q1Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||||
|
var paramsDto dto.QYGLJ0Q1Req
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建数据宝入参:姓名、身份证、手机号、银行卡号(sign 外的业务参数可按需 AES 加密后作为 bodyData)
|
||||||
|
reqParams := map[string]interface{}{
|
||||||
|
"key": "adac456f7b4ced764b606c8b07fed4d3",
|
||||||
|
"mobile": paramsDto.MobileNo,
|
||||||
|
"idcard": paramsDto.IDCard,
|
||||||
|
"name": paramsDto.Name,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 最终请求 URL = https://api.chinadatapay.com/communication + 拼接接口地址值,如 personal/197
|
||||||
|
apiPath := "/communication/personal/1979"
|
||||||
|
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) {
|
||||||
|
return nil, errors.Join(processors.ErrNotFound, 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
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
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/shujubao"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProcessQYGLUY3SRequest QYGLUY3S 企业经营状态全景查询 API 处理方法(使用数据宝服务示例)
|
||||||
|
func ProcessQYGLUY3SRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||||
|
var paramsDto dto.QYGLUY3SReq
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建数据宝入参:姓名、身份证、手机号、银行卡号(sign 外的业务参数可按需 AES 加密后作为 bodyData)
|
||||||
|
reqParams := map[string]interface{}{
|
||||||
|
"key": "5131227a847c06c111f624a22ebacc06",
|
||||||
|
"entName": paramsDto.EntName,
|
||||||
|
"regno": paramsDto.EntRegno,
|
||||||
|
"creditcode": paramsDto.EntCode,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 最终请求 URL = https://api.chinadatapay.com/communication + 拼接接口地址值,如 personal/197
|
||||||
|
apiPath := "/communication/personal/10195"
|
||||||
|
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) {
|
||||||
|
return nil, errors.Join(processors.ErrNotFound, 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user