f
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
"tyapi-server/internal/infrastructure/external/westdex"
|
||||
"tyapi-server/internal/infrastructure/external/xingwei"
|
||||
"tyapi-server/internal/infrastructure/external/yushan"
|
||||
"tyapi-server/internal/infrastructure/external/yuyuecha"
|
||||
"tyapi-server/internal/infrastructure/external/zhicha"
|
||||
"tyapi-server/internal/shared/interfaces"
|
||||
)
|
||||
@@ -46,6 +47,7 @@ type ProcessorDependencies struct {
|
||||
HuiboService *huibo.HuiboService
|
||||
NuoerService *nuoer.NuoerService
|
||||
HaiyuapiService *haiyuapi.HaiyuapiService
|
||||
YuyuechaService *yuyuecha.YuyuechaService
|
||||
Validator interfaces.RequestValidator
|
||||
CombService CombServiceInterface // Changed to interface to break import cycle
|
||||
Options *commands.ApiCallOptions // 添加Options支持
|
||||
@@ -76,6 +78,7 @@ func NewProcessorDependencies(
|
||||
huiboService *huibo.HuiboService,
|
||||
nuoerService *nuoer.NuoerService,
|
||||
haiyuapiService *haiyuapi.HaiyuapiService,
|
||||
yuyuechaService *yuyuecha.YuyuechaService,
|
||||
validator interfaces.RequestValidator,
|
||||
combService CombServiceInterface, // Changed to interface
|
||||
reportRepo repositories.ReportRepository,
|
||||
@@ -96,6 +99,7 @@ func NewProcessorDependencies(
|
||||
HuiboService: huiboService,
|
||||
NuoerService: nuoerService,
|
||||
HaiyuapiService: haiyuapiService,
|
||||
YuyuechaService: yuyuechaService,
|
||||
Validator: validator,
|
||||
CombService: combService,
|
||||
Options: nil, // 初始化为nil,在调用时设置
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"tyapi-server/internal/domains/api/dto"
|
||||
"tyapi-server/internal/domains/api/services/processors"
|
||||
"tyapi-server/internal/infrastructure/external/nuoer"
|
||||
|
||||
@@ -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/yuyuecha"
|
||||
)
|
||||
|
||||
// ProcessQYGL101ARequest QYGL101A - 企业关系查询(愉悦查 A01 示例)
|
||||
//
|
||||
// 扣费策略(对齐上游 9.2 / 9.3):
|
||||
// - HTTP 200 + success:按 X-Billable / billing.billable 决定是否平台扣费
|
||||
// - 沙箱 / 幂等重放通常 billable=false → SuccessNoBillError(返回数据但不扣费)
|
||||
// - 正式环境 resultCode=0/1 且 billable=true → 正常成功并扣费
|
||||
// - 4xx/5xx / success=false → 哨兵错误,不扣费
|
||||
func ProcessQYGL101ARequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||
var paramsDto dto.QYGL101AReq
|
||||
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 deps.YuyuechaService == nil {
|
||||
return nil, errors.Join(processors.ErrSystem, errors.New("北京正信服务未初始化"))
|
||||
}
|
||||
|
||||
// apiPath 入参;CallAPI 内拼接为 /openapi/v1/a01/person-company-relations
|
||||
// 上游 idCard 要求 32 位 MD5(兼容 64 位 SHA-256),平台侧收明文后在此做摘要
|
||||
result, err := deps.YuyuechaService.CallAPI(ctx, "a01/person-company-relations", map[string]interface{}{
|
||||
"name": paramsDto.Name,
|
||||
"idCard": yuyuecha.HashIDCard(paramsDto.IDCard),
|
||||
})
|
||||
if err != nil {
|
||||
if errors.Is(err, yuyuecha.ErrNotFound) {
|
||||
return nil, errors.Join(processors.ErrNotFound, err)
|
||||
}
|
||||
if errors.Is(err, yuyuecha.ErrDatasource) {
|
||||
return nil, errors.Join(processors.ErrDatasource, err)
|
||||
}
|
||||
return nil, errors.Join(processors.ErrSystem, err)
|
||||
}
|
||||
|
||||
if !result.Billable {
|
||||
return nil, &processors.SuccessNoBillError{Response: result.Data}
|
||||
}
|
||||
|
||||
return result.Data, nil
|
||||
}
|
||||
Reference in New Issue
Block a user