This commit is contained in:
2026-07-22 17:16:35 +08:00
52 changed files with 6336 additions and 293 deletions

View File

@@ -1347,3 +1347,9 @@ type QYGLLUCMReq struct {
EntName string `json:"ent_name" validate:"required,min=1,validEnterpriseName"`
AuthPDFBase64 string `json:"auth_pdf_base64" validate:"required,validAuthPDFBase64"`
}
type JRZQ0OO1Req 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"`
}

View File

@@ -23,6 +23,7 @@ import (
jiyiext "hyapi-server/internal/infrastructure/external/jiyi"
"hyapi-server/internal/infrastructure/external/muzi"
nuoerext "hyapi-server/internal/infrastructure/external/nuoer"
"hyapi-server/internal/infrastructure/external/rongxing"
"hyapi-server/internal/infrastructure/external/shujubao"
"hyapi-server/internal/infrastructure/external/tianyancha"
"hyapi-server/internal/infrastructure/external/tianyuanapi"
@@ -69,6 +70,7 @@ func NewApiRequestService(
nuoerService *nuoerext.NuoerService,
jiyiService *jiyiext.JiyiService,
huiboService *huibo.HuiboService,
rongxingService *rongxing.RongxingService,
validator interfaces.RequestValidator,
productManagementService *services.ProductManagementService,
cfg *appconfig.Config,
@@ -87,6 +89,7 @@ func NewApiRequestService(
nuoerService,
jiyiService,
huiboService,
rongxingService,
validator,
productManagementService,
cfg,
@@ -110,6 +113,7 @@ func NewApiRequestServiceWithRepos(
nuoerService *nuoerext.NuoerService,
jiyiService *jiyiext.JiyiService,
huiboService *huibo.HuiboService,
rongxingService *rongxing.RongxingService,
validator interfaces.RequestValidator,
productManagementService *services.ProductManagementService,
cfg *appconfig.Config,
@@ -139,6 +143,7 @@ func NewApiRequestServiceWithRepos(
nuoerService,
jiyiService,
huiboService,
rongxingService,
validator,
combService,
reportRepo,
@@ -202,6 +207,7 @@ func registerAllProcessors(combService *comb.CombService) {
"JRZQR4N7": jrzq.ProcessJRZQR4N7Request, //借贷意向验证3.0
"JRZQH6M3": jrzq.ProcessJRZQH6M3Request, //无间司南-纯黑A版
"JRZQW3L8": jrzq.ProcessJRZQW3L8Request, //信用司南
"JRZQ0OO1": jrzq.ProcessJRZQ0OO1Request, //戎行贷后信息
// QYGL系列处理器
"QYGL7HBN": qygl.ProcessQYGL7HBNRequest, //企业全景报告(聚合 QYGLUY3S/QYGLJ0Q1/QYGL5S1I

View File

@@ -318,7 +318,8 @@ func (s *FormConfigServiceImpl) getDTOStruct(ctx context.Context, apiCode string
"JRZQW3L8": &dto.JRZQW3L8Req{}, //信用司南
"IVYZX7J9": &dto.IVYZX7J9Req{}, //学籍核验
"QCXG6U5G": &dto.QCXG6U5GReq{}, //车辆核验
"QCXG7K2N": &dto.QCXG7K2NReq{}, //人车核验加强版
"JRZQ0OO1": &dto.JRZQ0OO1Req{}, //戎行贷后信息 Info360
}
// 优先返回已配置的DTO

View File

@@ -11,9 +11,10 @@ import (
"hyapi-server/internal/infrastructure/external/jiyi"
"hyapi-server/internal/infrastructure/external/muzi"
"hyapi-server/internal/infrastructure/external/nuoer"
"hyapi-server/internal/infrastructure/external/rongxing"
"hyapi-server/internal/infrastructure/external/shujubao"
"hyapi-server/internal/infrastructure/external/tianyuanapi"
"hyapi-server/internal/infrastructure/external/tianyancha"
"hyapi-server/internal/infrastructure/external/tianyuanapi"
"hyapi-server/internal/infrastructure/external/westdex"
"hyapi-server/internal/infrastructure/external/xingwei"
"hyapi-server/internal/infrastructure/external/yushan"
@@ -33,23 +34,24 @@ type CallContext struct {
// ProcessorDependencies 处理器依赖容器
type ProcessorDependencies struct {
WestDexService *westdex.WestDexService
ShujubaoService *shujubao.ShujubaoService
MuziService *muzi.MuziService
YushanService *yushan.YushanService
TianYanChaService *tianyancha.TianYanChaService
AlicloudService *alicloud.AlicloudService
ZhichaService *zhicha.ZhichaService
XingweiService *xingwei.XingweiService
JiguangService *jiguang.JiguangService
WestDexService *westdex.WestDexService
ShujubaoService *shujubao.ShujubaoService
MuziService *muzi.MuziService
YushanService *yushan.YushanService
TianYanChaService *tianyancha.TianYanChaService
AlicloudService *alicloud.AlicloudService
ZhichaService *zhicha.ZhichaService
XingweiService *xingwei.XingweiService
JiguangService *jiguang.JiguangService
TianyuanapiService *tianyuanapi.TianyuanapiService
NuoerService *nuoer.NuoerService
JiyiService *jiyi.JiyiService
HuiboService *huibo.HuiboService
Validator interfaces.RequestValidator
CombService CombServiceInterface // Changed to interface to break import cycle
Options *commands.ApiCallOptions // 添加Options支持
CallContext *CallContext // 添加CallApi调用上下文
NuoerService *nuoer.NuoerService
JiyiService *jiyi.JiyiService
HuiboService *huibo.HuiboService
RongxingService *rongxing.RongxingService
Validator interfaces.RequestValidator
CombService CombServiceInterface // Changed to interface to break import cycle
Options *commands.ApiCallOptions // 添加Options支持
CallContext *CallContext // 添加CallApi调用上下文
// 企业报告记录仓储,用于持久化 QYGLJ1U9 生成的企业报告
ReportRepo repositories.ReportRepository
@@ -76,6 +78,7 @@ func NewProcessorDependencies(
nuoerService *nuoer.NuoerService,
jiyiService *jiyi.JiyiService,
huiboService *huibo.HuiboService,
rongxingService *rongxing.RongxingService,
validator interfaces.RequestValidator,
combService CombServiceInterface, // Changed to interface
reportRepo repositories.ReportRepository,
@@ -96,6 +99,7 @@ func NewProcessorDependencies(
NuoerService: nuoerService,
JiyiService: jiyiService,
HuiboService: huiboService,
RongxingService: rongxingService,
Validator: validator,
CombService: combService,
Options: nil, // 初始化为nil在调用时设置

View File

@@ -0,0 +1,46 @@
package jrzq
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/rongxing"
)
func ProcessJRZQ0OO1Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.JRZQ0OO1Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if deps.RongxingService == nil {
return nil, errors.Join(processors.ErrSystem, errors.New("戎行服务未初始化"))
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
// 业务入参在处理器侧组装;三要素按接口要求 MD5 大写后入请求体
reqdata := map[string]interface{}{
"phone": rongxing.MD5Upper(paramsDto.MobileNo),
"idCard": rongxing.MD5Upper(paramsDto.IDCard),
"name": rongxing.MD5Upper(paramsDto.Name),
}
respBytes, err := deps.RongxingService.CallAPI(ctx, "/third/loan/info360", reqdata)
if err != nil {
if errors.Is(err, rongxing.ErrNotFound) {
return nil, errors.Join(processors.ErrNotFound, err)
}
if errors.Is(err, rongxing.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
}
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}

View File

@@ -3,6 +3,7 @@ package entities
import (
"errors"
"fmt"
"strings"
"time"
"hyapi-server/internal/domains/certification/entities/value_objects"
@@ -28,14 +29,17 @@ type Certification struct {
CompletedAt *time.Time `json:"completed_at,omitempty" comment:"认证完成时间"`
ContractFileCreatedAt *time.Time `json:"contract_file_created_at,omitempty" comment:"合同文件生成时间"`
// === e签宝相关信息 ===
// === 签署平台esign | fadada===
SignPlatform enums.SignPlatform `gorm:"type:varchar(20);index" json:"sign_platform,omitempty" comment:"签署平台: esign|fadada"`
// === 第三方认证/签署信息(字段名历史兼容,语义为平台无关)===
AuthFlowID string `gorm:"type:varchar(500)" json:"auth_flow_id,omitempty" comment:"企业认证流程ID"`
AuthURL string `gorm:"type:varchar(500)" json:"auth_url,omitempty" comment:"企业认证链接"`
AuthURL string `gorm:"type:text" json:"auth_url,omitempty" comment:"企业认证链接"`
ContractCode string `gorm:"type:varchar(100)" json:"contract_code,omitempty" comment:"合同/协议编号"`
ContractFileID string `gorm:"type:varchar(500)" json:"contract_file_id,omitempty" comment:"合同文件ID"`
EsignFlowID string `gorm:"type:varchar(500)" json:"esign_flow_id,omitempty" comment:"签署流程ID"`
ContractURL string `gorm:"type:varchar(500)" json:"contract_url,omitempty" comment:"合同文件访问链接"`
ContractSignURL string `gorm:"type:varchar(500)" json:"contract_sign_url,omitempty" comment:"合同签署链接"`
EsignFlowID string `gorm:"type:varchar(500)" json:"esign_flow_id,omitempty" comment:"签署流程ID(兼容字段名)"`
ContractURL string `gorm:"type:text" json:"contract_url,omitempty" comment:"合同文件访问链接(法大大下载链可能很长)"`
ContractSignURL string `gorm:"type:text" json:"contract_sign_url,omitempty" comment:"合同签署链接(短链/长链)"`
// === 失败信息 ===
FailureReason enums.FailureReason `gorm:"type:varchar(100)" json:"failure_reason,omitempty" comment:"失败原因"`
@@ -238,8 +242,11 @@ func (c *Certification) RejectEnterpriseInfoReview(actorID, message string) erro
return nil
}
// 完成企业认证
// 完成企业认证(幂等:已是 enterprise_verified 则跳过状态流转,便于中途失败后重试)
func (c *Certification) CompleteEnterpriseVerification() error {
if c.Status == enums.StatusEnterpriseVerified {
return nil
}
if c.Status != enums.StatusInfoSubmitted {
return fmt.Errorf("当前状态 %s 不允许完成企业认证", enums.GetStatusName(c.Status))
}
@@ -310,8 +317,12 @@ func (c *Certification) ApplyContract(EsignFlowID string, ContractSignURL string
if err := c.TransitionTo(enums.StatusContractApplied, enums.ActorTypeUser, c.UserID, "用户申请合同签署"); err != nil {
return err
}
c.EsignFlowID = EsignFlowID
c.ContractSignURL = ContractSignURL
if EsignFlowID != "" {
c.EsignFlowID = EsignFlowID
}
if ContractSignURL != "" {
c.ContractSignURL = ContractSignURL
}
now := time.Now()
c.ContractFileCreatedAt = &now
// 添加业务事件
@@ -324,6 +335,18 @@ func (c *Certification) ApplyContract(EsignFlowID string, ContractSignURL string
return nil
}
// BindSignTask 企业认证完成后预创建签署任务(不改状态;乙方可先免签)
func (c *Certification) BindSignTask(esignFlowID, contractSignURL string) {
if esignFlowID != "" {
c.EsignFlowID = esignFlowID
}
if contractSignURL != "" {
c.ContractSignURL = contractSignURL
}
now := time.Now()
c.ContractFileCreatedAt = &now
}
// AddContractFileID 生成合同文件
func (c *Certification) AddContractFileID(contractFileID string, contractURL string) error {
c.ContractFileID = contractFileID
@@ -500,13 +523,58 @@ func (c *Certification) CompleteCertification() error {
return nil
}
// ResolvedSignPlatform 解析签署平台(空则默认 e签宝兼容历史数据
func (c *Certification) ResolvedSignPlatform() enums.SignPlatform {
if enums.IsValidSignPlatform(c.SignPlatform) {
return c.SignPlatform
}
return enums.DefaultSignPlatform()
}
// ResetAfterSignTaskCreateFailed 签署任务未创建却已到 enterprise_verified 时,回退到待选平台
func (c *Certification) ResetAfterSignTaskCreateFailed() error {
if c.Status != enums.StatusEnterpriseVerified {
return fmt.Errorf("当前状态 %s 无需回退", enums.GetStatusName(c.Status))
}
if strings.TrimSpace(c.EsignFlowID) != "" {
return fmt.Errorf("签署任务已存在,不能回退到选平台")
}
c.Status = enums.StatusInfoPendingReview
c.SignPlatform = ""
c.AuthURL = ""
c.AuthFlowID = ""
c.ContractFileID = ""
c.ContractURL = ""
c.ContractSignURL = ""
c.EsignFlowID = ""
c.EnterpriseVerifiedAt = nil
c.UpdatedAt = time.Now()
return nil
}
// SetSignPlatform 设置签署平台(选定后锁定)
func (c *Certification) SetSignPlatform(platform enums.SignPlatform) error {
if !enums.IsValidSignPlatform(platform) {
return fmt.Errorf("无效的签署平台: %s", platform)
}
if c.SignPlatform != "" && c.SignPlatform != platform {
return fmt.Errorf("签署平台已选择为 %s不可更改", enums.GetSignPlatformName(c.SignPlatform))
}
c.SignPlatform = platform
return nil
}
// ================ 查询方法 ================
// GetDataByStatus 根据当前状态获取对应的数据
func (c *Certification) GetDataByStatus() map[string]interface{} {
data := map[string]interface{}{}
if c.SignPlatform != "" {
data["sign_platform"] = string(c.SignPlatform)
data["sign_platform_name"] = enums.GetSignPlatformName(c.SignPlatform)
}
switch c.Status {
case enums.StatusInfoPendingReview:
// 待审核,额外数据
// 待审核/待选平台,额外数据由应用层补充
case enums.StatusInfoSubmitted:
data["auth_url"] = c.AuthURL
case enums.StatusInfoRejected:
@@ -514,11 +582,24 @@ func (c *Certification) GetDataByStatus() map[string]interface{} {
data["failure_message"] = c.FailureMessage
case enums.StatusEnterpriseVerified:
data["ContractURL"] = c.ContractURL
data["contract_url"] = c.ContractURL
if c.EsignFlowID != "" {
data["esign_flow_id"] = c.EsignFlowID
data["sign_task_ready"] = true
}
case enums.StatusContractApplied:
data["contract_sign_url"] = c.ContractSignURL
data["ContractURL"] = c.ContractURL
data["contract_url"] = c.ContractURL
if c.EsignFlowID != "" {
data["esign_flow_id"] = c.EsignFlowID
}
case enums.StatusContractSigned:
case enums.StatusCompleted:
data["completed_at"] = c.CompletedAt
if c.ContractURL != "" {
data["contract_url"] = c.ContractURL
}
case enums.StatusContractRejected:
data["failure_reason"] = c.FailureReason
data["failure_message"] = c.FailureMessage

View File

@@ -15,7 +15,9 @@ type ContractInfo struct {
ContractFileID string `json:"contract_file_id"` // 合同文件ID
EsignFlowID string `json:"esign_flow_id"` // e签宝签署流程ID
ContractURL string `json:"contract_url"` // 合同文件访问链接
ContractSignURL string `json:"contract_sign_url"` // 合同签署链接
ContractSignURL string `json:"contract_sign_url"` // 合同签署链接iframe 长链,可能短期有效)
// ContractSignShortURL 短链(法大大不可 iframe可选
ContractSignShortURL string `json:"contract_sign_short_url,omitempty"`
// 合同元数据
ContractTitle string `json:"contract_title"` // 合同标题

View File

@@ -0,0 +1,36 @@
package enums
// SignPlatform 签署/认证平台
type SignPlatform string
const (
SignPlatformEsign SignPlatform = "esign"
SignPlatformFadada SignPlatform = "fadada"
)
// IsValidSignPlatform 是否为合法平台
func IsValidSignPlatform(p SignPlatform) bool {
switch p {
case SignPlatformEsign, SignPlatformFadada:
return true
default:
return false
}
}
// GetSignPlatformName 平台中文名
func GetSignPlatformName(p SignPlatform) string {
switch p {
case SignPlatformEsign:
return "e签宝"
case SignPlatformFadada:
return "法大大"
default:
return string(p)
}
}
// DefaultSignPlatform 历史数据默认平台
func DefaultSignPlatform() SignPlatform {
return SignPlatformEsign
}

View File

@@ -0,0 +1,152 @@
package ports
import (
"context"
"hyapi-server/internal/domains/certification/enums"
)
// EnterpriseAuthRequest 企业认证链接请求
type EnterpriseAuthRequest struct {
ClientCorpID string
ClientUserID string
CompanyName string
UnifiedSocialCode string
LegalPersonName string
LegalPersonID string
TransactorName string
TransactorMobile string
TransactorID string
}
// AuthLinkResult 企业认证链接结果
type AuthLinkResult struct {
AuthFlowID string
AuthURL string
AuthShortURL string
}
// OrgIdentityQuery 企业实名查询
type OrgIdentityQuery struct {
OrgName string
OrgIdentNo string
OpenCorpID string
ClientCorpID string
}
// ContractGenerateRequest 合同模板填单
type ContractGenerateRequest struct {
AgreementNo string
CompanyName string
UnifiedSocialCode string
EnterpriseAddress string
AuthorizedRepName string
SignDate string
FileName string
}
// ContractFileResult 合同文件结果
type ContractFileResult struct {
FileID string
FileDownloadURL string
}
// SignFlowCreateRequest 创建签署流程
type SignFlowCreateRequest struct {
Subject string
FileID string
DocName string
PartyAOpenCorpID string
PartyAName string
PartyAUSCC string
TransactorName string
TransactorMobile string
TransactorID string
TransReferenceID string
Fill *ContractGenerateRequest
// SkipActorURL 为企业认证后预创建任务时跳过取签署链接(避免消耗 10 分钟单次 EmbedURL
SkipActorURL bool
}
// SignFlowResult 签署流程创建结果
type SignFlowResult struct {
SignFlowID string
// SignURL 可供 iframe 嵌入的签署长链(法大大 actorSignTaskEmbedUrl / e签宝 url
SignURL string
// ShortURL 短链(法大大 actorSignTaskUrl不可 iframe
ShortURL string
}
// GetActorSignURLRequest 重新获取参与方签署链接
type GetActorSignURLRequest struct {
SignFlowID string
TransactorMobile string
PartyAName string
}
// ActorSignURLResult 参与方签署链接(长链可 iframe短链不可
type ActorSignURLResult struct {
SignFlowID string
EmbedURL string // iframe 用
ShortURL string // 短链,一年有效,需登录
}
// SignTaskPreviewURLResult 签署任务预览链接
type SignTaskPreviewURLResult struct {
SignFlowID string
PreviewURL string
}
// SignStatusResult 签署状态
type SignStatusResult struct {
SignFlowID string
Status string
Completed bool
Rejected bool
Expired bool
Message string
}
// SignedFile 已签文件
type SignedFile struct {
DownloadURL string
DownloadID string
}
// CallbackEvent 回调事件
type CallbackEvent struct {
Event string
AuthPassed bool
SignCompleted bool
SignRejected bool
SignFlowID string
AuthFlowID string
OrgName string
Raw map[string]interface{}
}
// SignPlatformProvider 签署平台统一能力e签宝 / 法大大)
type SignPlatformProvider interface {
Platform() enums.SignPlatform
GenerateEnterpriseAuth(ctx context.Context, req *EnterpriseAuthRequest) (*AuthLinkResult, error)
QueryOrgVerified(ctx context.Context, req *OrgIdentityQuery) (bool, error)
GenerateContractFile(ctx context.Context, req *ContractGenerateRequest) (*ContractFileResult, error)
CreateSignFlow(ctx context.Context, req *SignFlowCreateRequest) (*SignFlowResult, error)
// GetActorSignURL 按已有签署任务重新获取参与方链接(法大大长链 10 分钟/单次,进入签署页时应刷新)
GetActorSignURL(ctx context.Context, req *GetActorSignURLRequest) (*ActorSignURLResult, error)
// GetSignTaskPreviewURL 获取签署任务预览链接(法大大 EUI约 2 小时/单次;勿用 PDF 直链做预览)
GetSignTaskPreviewURL(ctx context.Context, signFlowID string) (*SignTaskPreviewURLResult, error)
QuerySignStatus(ctx context.Context, flowID string) (*SignStatusResult, error)
DownloadSignedFiles(ctx context.Context, flowID string) ([]*SignedFile, error)
VerifyCallback(ctx context.Context, headers map[string]string, body []byte) error
ParseCallback(ctx context.Context, headers map[string]string, body []byte) (*CallbackEvent, error)
}
// SignPlatformRegistry 按平台路由 Provider
type SignPlatformRegistry interface {
Get(platform enums.SignPlatform) (SignPlatformProvider, error)
List() []SignPlatformProvider
}