f
This commit is contained in:
@@ -1166,6 +1166,9 @@ func (s *ProductApplicationServiceImpl) getDTOMap() map[string]interface{} {
|
||||
"IVYZ6G7H": &dto.IVYZ6G7HReq{},
|
||||
"IVYZ8I9J": &dto.IVYZ8I9JReq{},
|
||||
"JRZQ0L85": &dto.JRZQ0L85Req{},
|
||||
"JRZQK9P2": &dto.JRZQK9P2Req{}, //洞侦1.0(海宇)
|
||||
"JRZQR4N7": &dto.JRZQR4N7Req{}, //借贷意向验证3.0(海宇)
|
||||
"JRZQP8D2": &dto.JRZQP8D2Req{}, //全景雷达BH(海宇)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,27 @@ type JRZQ5T8SReq struct {
|
||||
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||
Name string `json:"name" validate:"required,min=1,validName"`
|
||||
}
|
||||
|
||||
// JRZQK9P2Req 洞侦1.0(转发海宇 JRZQK9P2)
|
||||
type JRZQK9P2Req struct {
|
||||
Name string `json:"name" validate:"required,min=1,validName"`
|
||||
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
||||
}
|
||||
|
||||
// JRZQR4N7Req 借贷意向验证3.0(转发海宇 JRZQR4N7)
|
||||
type JRZQR4N7Req struct {
|
||||
Name string `json:"name" validate:"required,min=1,validName"`
|
||||
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
||||
}
|
||||
|
||||
// JRZQP8D2Req 全景雷达BH(转发海宇 JRZQP8D2)
|
||||
type JRZQP8D2Req struct {
|
||||
Name string `json:"name" validate:"required,min=1,validName"`
|
||||
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
||||
}
|
||||
type JRZQT57ZReq struct {
|
||||
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
||||
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||
|
||||
@@ -240,6 +240,9 @@ func registerAllProcessors(combService *comb.CombService) {
|
||||
"JRZQV7MD": jrzq.ProcessJRZQV7MDRequest, // 特殊名单
|
||||
"JRZQ5T8S": jrzq.ProcessJRZQ5T8SRequest, // 借贷意向验证V2
|
||||
"JRZQT57Z": jrzq.ProcessJRZQT57ZRequest, // 团伙欺诈风险识别
|
||||
"JRZQK9P2": jrzq.ProcessJRZQK9P2Request, // 洞侦1.0(海宇,查空计费)
|
||||
"JRZQR4N7": jrzq.ProcessJRZQR4N7Request, // 借贷意向验证3.0(海宇,查空计费)
|
||||
"JRZQP8D2": jrzq.ProcessJRZQP8D2Request, // 全景雷达BH(海宇,查空不计费)
|
||||
|
||||
// QYGL系列处理器
|
||||
"QYGL8261": qygl.ProcessQYGL8261Request,
|
||||
|
||||
@@ -342,6 +342,9 @@ func (s *FormConfigServiceImpl) getDTOStruct(ctx context.Context, apiCode string
|
||||
"QCXGCP77": &dto.QCXGCP77Req{}, //全国车辆配置查验(车辆详情)
|
||||
"JRZQ5T8S": &dto.JRZQ5T8SReq{}, //借贷意向验证V22
|
||||
"JRZQT57Z": &dto.JRZQT57ZReq{}, //团伙欺诈风险识别
|
||||
"JRZQK9P2": &dto.JRZQK9P2Req{}, //洞侦1.0(海宇,查空计费)
|
||||
"JRZQR4N7": &dto.JRZQR4N7Req{}, //借贷意向验证3.0(海宇,查空计费)
|
||||
"JRZQP8D2": &dto.JRZQP8D2Req{}, //全景雷达BH(海宇,查空不计费)
|
||||
"IVYZX7J9": &dto.IVYZX7J9Req{}, //学历核验政务
|
||||
"IVYZFC59": &dto.IVYZFC59Req{}, //房产核验
|
||||
"IVYZGJ99": &dto.IVYZGJ99Req{}, //公积金核验
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
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/haiyuapi"
|
||||
)
|
||||
|
||||
// ProcessJRZQK9P2Request JRZQK9P2 API处理方法 - 洞侦1.0(转发海宇 JRZQK9P2,查空计费)
|
||||
func ProcessJRZQK9P2Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||
var paramsDto dto.JRZQK9P2Req
|
||||
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.HaiyuapiService == nil {
|
||||
return nil, errors.Join(processors.ErrSystem, errors.New("海宇API服务未初始化"))
|
||||
}
|
||||
|
||||
reqParams := map[string]interface{}{
|
||||
"name": paramsDto.Name,
|
||||
"id_card": paramsDto.IDCard,
|
||||
"mobile_no": paramsDto.MobileNo,
|
||||
}
|
||||
|
||||
respBytes, err := deps.HaiyuapiService.CallAPI(ctx, "JRZQK9P2", reqParams)
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
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/haiyuapi"
|
||||
)
|
||||
|
||||
// ProcessJRZQP8D2Request JRZQP8D2 API处理方法 - 全景雷达BH(转发海宇 JRZQP8D2,查空不计费)
|
||||
func ProcessJRZQP8D2Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||
var paramsDto dto.JRZQP8D2Req
|
||||
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.HaiyuapiService == nil {
|
||||
return nil, errors.Join(processors.ErrSystem, errors.New("海宇API服务未初始化"))
|
||||
}
|
||||
|
||||
reqParams := map[string]interface{}{
|
||||
"name": paramsDto.Name,
|
||||
"id_card": paramsDto.IDCard,
|
||||
"mobile_no": paramsDto.MobileNo,
|
||||
}
|
||||
|
||||
respBytes, err := deps.HaiyuapiService.CallAPI(ctx, "JRZQP8D2", reqParams)
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
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/haiyuapi"
|
||||
)
|
||||
|
||||
// ProcessJRZQR4N7Request JRZQR4N7 API处理方法 - 借贷意向验证3.0(转发海宇 JRZQR4N7,查空计费)
|
||||
func ProcessJRZQR4N7Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||
var paramsDto dto.JRZQR4N7Req
|
||||
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.HaiyuapiService == nil {
|
||||
return nil, errors.Join(processors.ErrSystem, errors.New("海宇API服务未初始化"))
|
||||
}
|
||||
|
||||
reqParams := map[string]interface{}{
|
||||
"name": paramsDto.Name,
|
||||
"id_card": paramsDto.IDCard,
|
||||
"mobile_no": paramsDto.MobileNo,
|
||||
}
|
||||
|
||||
respBytes, err := deps.HaiyuapiService.CallAPI(ctx, "JRZQR4N7", reqParams)
|
||||
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
|
||||
}
|
||||
@@ -80,6 +80,18 @@ func requestParamsForLog(params map[string]interface{}) map[string]interface{} {
|
||||
return out
|
||||
}
|
||||
|
||||
// queryBillingProductCodes 查询计费产品:查空(code=1000)仍按成功返回空数据,由平台侧计费
|
||||
// 与 hyapi 侧 jiyi.queryBillingAPIKeys 对齐:洞侦1.0、借贷意向验证3.0 查空计费;全景雷达BH(JRZQP8D2) 查空不计费
|
||||
var queryBillingProductCodes = map[string]struct{}{
|
||||
"JRZQK9P2": {}, // 洞侦1.0(hyapi jy000022)
|
||||
"JRZQR4N7": {}, // 借贷意向验证3.0(hyapi jy000042)
|
||||
}
|
||||
|
||||
func isQueryBillingProduct(productCode string) bool {
|
||||
_, ok := queryBillingProductCodes[productCode]
|
||||
return ok
|
||||
}
|
||||
|
||||
// CallAPI 调用海宇平台指定产品(产品编号与处理器 ApiCode 一致)
|
||||
func (s *HaiyuapiService) CallAPI(ctx context.Context, productCode string, params map[string]interface{}) ([]byte, error) {
|
||||
startTime := time.Now()
|
||||
@@ -176,6 +188,10 @@ func (s *HaiyuapiService) CallAPI(ctx context.Context, productCode string, param
|
||||
}
|
||||
|
||||
if outer.Code != CodeSuccess {
|
||||
// 查询计费产品:查空仍返回空数据,由平台计费(对齐 hyapi)
|
||||
if outer.Code == CodeQueryEmpty && isQueryBillingProduct(productCode) {
|
||||
return []byte("{}"), nil
|
||||
}
|
||||
mappedErr := mapBusinessError(outer.Code, outer.Message)
|
||||
if s.logger != nil {
|
||||
s.logger.LogError(requestID, transactionID, productCode, mappedErr, map[string]interface{}{
|
||||
|
||||
@@ -19,3 +19,12 @@ func TestMapBusinessError(t *testing.T) {
|
||||
t.Fatal("expected ErrSystem for 1003")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsQueryBillingProduct(t *testing.T) {
|
||||
if !isQueryBillingProduct("JRZQK9P2") || !isQueryBillingProduct("JRZQR4N7") {
|
||||
t.Fatal("洞侦1.0/借贷意向验证3.0 应查空计费")
|
||||
}
|
||||
if isQueryBillingProduct("JRZQP8D2") {
|
||||
t.Fatal("全景雷达BH 查空不计费,不应在白名单中")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user