This commit is contained in:
2026-04-21 21:03:56 +08:00
7 changed files with 162 additions and 0 deletions

View File

@@ -499,6 +499,12 @@ type IVYZ7F3AReq struct {
Name string `json:"name" validate:"required,min=1,validName"`
Authorized string `json:"authorized" validate:"required,oneof=0 1"`
}
type IVYZRAX1Req 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"`
Authorized string `json:"authorized" validate:"required,oneof=0 1"`
}
type IVYZ3P9MReq struct {
IDCard string `json:"id_card" validate:"required,validIDCard"`

View File

@@ -330,6 +330,9 @@ func registerAllProcessors(combService *comb.CombService) {
"IVYZ38SR": ivyz.ProcessIVYZ38SRRequest, //婚姻状态核验(双人)
"IVYZ48SR": ivyz.ProcessIVYZ48SRRequest, //婚姻状态核验V2双人
"IVYZ5E22": ivyz.ProcessIVYZ5E22Request, //双人婚姻评估查询zhicha版本
"IVYZRAX1": ivyz.ProcessIVYZRAX1Request, //融安信用分
"IVYZRAX2": ivyz.ProcessIVYZRAX2Request,//融御反欺诈分
// COMB系列处理器 - 只注册有自定义逻辑的组合包
"COMB86PM": comb.ProcessCOMB86PMRequest, // 有自定义逻辑重命名ApiCode

View File

@@ -276,6 +276,8 @@ func (s *FormConfigServiceImpl) getDTOStruct(ctx context.Context, apiCode string
"IVYZ5E22": &dto.IVYZ5E22Req{}, //双人婚姻评估查询zhicha版本
"DWBG5SAM": &dto.DWBG5SAMReq{}, //天远指迷报告
"QYGLDJ33": &dto.QYGLDJ33Req{}, //企业年报信息核验
"IVYZRAX1": &dto.IVYZRAX1Req{},//融安信用分
"IVYZRAX2": &dto.IVYZRAX1Req{},//融御反欺诈
}
// 优先返回已配置的DTO

View File

@@ -0,0 +1,68 @@
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/zhicha"
)
// ProcessIVYZRAX1Request IVYZRAX1 API处理方法 - 融安信用分
func ProcessIVYZRAX1Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.IVYZRAX1Req
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)
}
// encryptedName, err := deps.ZhichaService.Encrypt(paramsDto.Name)
// if err != nil {
// return nil, errors.Join(processors.ErrSystem, err)
// }
// encryptedIDCard, err := deps.ZhichaService.Encrypt(paramsDto.IDCard)
// if err != nil {
// return nil, errors.Join(processors.ErrSystem, err)
// }
// encryptedMoblie, err := deps.ZhichaService.Encrypt(paramsDto.MobileNo)
// if err != nil {
// return nil, errors.Join(processors.ErrSystem, err)
// }
md5Name := deps.ZhichaService.MD5(paramsDto.Name)
md5IDCard := deps.ZhichaService.MD5(paramsDto.IDCard)
md5Mobile := deps.ZhichaService.MD5(paramsDto.MobileNo)
reqData := map[string]interface{}{
// "name": encryptedName,
// "idCard": encryptedIDCard,
// "phone": encryptedMoblie,
"authorized": paramsDto.Authorized,
"name": md5Name,
"idCard": md5IDCard,
"phone": md5Mobile,
}
respData, err := deps.ZhichaService.CallAPI(ctx, "ZCI084", reqData)
if err != nil {
if errors.Is(err, zhicha.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 将响应数据转换为JSON字节
respBytes, err := json.Marshal(respData)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}

View File

@@ -0,0 +1,68 @@
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/zhicha"
)
// ProcessIVYZRAX2Request IVYZRAX2 API处理方法 - 融御反欺诈分
func ProcessIVYZRAX2Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.IVYZRAX1Req
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)
}
// encryptedName, err := deps.ZhichaService.Encrypt(paramsDto.Name)
// if err != nil {
// return nil, errors.Join(processors.ErrSystem, err)
// }
// encryptedIDCard, err := deps.ZhichaService.Encrypt(paramsDto.IDCard)
// if err != nil {
// return nil, errors.Join(processors.ErrSystem, err)
// }
// encryptedMoblie, err := deps.ZhichaService.Encrypt(paramsDto.MobileNo)
// if err != nil {
// return nil, errors.Join(processors.ErrSystem, err)
// }
md5Name := deps.ZhichaService.MD5(paramsDto.Name)
md5IDCard := deps.ZhichaService.MD5(paramsDto.IDCard)
md5Mobile := deps.ZhichaService.MD5(paramsDto.MobileNo)
reqData := map[string]interface{}{
// "name": encryptedName,
// "idCard": encryptedIDCard,
// "phone": encryptedMoblie,
"authorized": paramsDto.Authorized,
"name": md5Name,
"idCard": md5IDCard,
"phone": md5Mobile,
}
respData, err := deps.ZhichaService.CallAPI(ctx, "ZCI083", reqData)
if err != nil {
if errors.Is(err, zhicha.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 将响应数据转换为JSON字节
respBytes, err := json.Marshal(respData)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}

View File

@@ -4,9 +4,11 @@ import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/md5"
"encoding/base64"
"encoding/hex"
"fmt"
"io"
)
const (
@@ -119,3 +121,10 @@ func pkcs7Unpadding(src []byte) ([]byte, error) {
return src[:length-unpadding], nil
}
// MD5 使用MD5加密数据返回十六进制字符串
func MD5(data string) string {
h := md5.New()
io.WriteString(h, data)
return hex.EncodeToString(h.Sum(nil))
}

View File

@@ -315,6 +315,12 @@ func (z *ZhichaService) Decrypt(encryptedData string) (string, error) {
return string(unpadded), nil
}
// MD5 对字符串进行MD5加密并返回32位小写十六进制字符串
func (z *ZhichaService) MD5(data string) string {
hash := md5.Sum([]byte(data))
return hex.EncodeToString(hash[:])
}
// pkcs7Padding 使用PKCS7填充数据
func (z *ZhichaService) pkcs7Padding(src []byte, blockSize int) []byte {
padding := blockSize - len(src)%blockSize