This commit is contained in:
2025-09-12 01:15:09 +08:00
parent c563b2266b
commit e05ad9e223
103 changed files with 20034 additions and 1041 deletions

View File

@@ -21,6 +21,9 @@ type CertificationApplicationService interface {
// 申请合同签署
ApplyContract(ctx context.Context, cmd *commands.ApplyContractCommand) (*responses.ContractSignUrlResponse, error)
// OCR营业执照识别
RecognizeBusinessLicense(ctx context.Context, imageBytes []byte) (*responses.BusinessLicenseResult, error)
// ================ 查询用例 ================
// 获取认证详情

View File

@@ -22,6 +22,7 @@ import (
"tyapi-server/internal/infrastructure/external/storage"
"tyapi-server/internal/shared/database"
"tyapi-server/internal/shared/esign"
sharedOCR "tyapi-server/internal/shared/ocr"
"go.uber.org/zap"
)
@@ -40,6 +41,7 @@ type CertificationApplicationServiceImpl struct {
walletAggregateService finance_service.WalletAggregateService
apiUserAggregateService api_service.ApiUserAggregateService
enterpriseInfoSubmitRecordService *services.EnterpriseInfoSubmitRecordService
ocrService sharedOCR.OCRService
// 仓储依赖
queryRepository repositories.CertificationQueryRepository
enterpriseInfoSubmitRecordRepo repositories.EnterpriseInfoSubmitRecordRepository
@@ -62,6 +64,7 @@ func NewCertificationApplicationService(
walletAggregateService finance_service.WalletAggregateService,
apiUserAggregateService api_service.ApiUserAggregateService,
enterpriseInfoSubmitRecordService *services.EnterpriseInfoSubmitRecordService,
ocrService sharedOCR.OCRService,
txManager *database.TransactionManager,
logger *zap.Logger,
) CertificationApplicationService {
@@ -78,6 +81,7 @@ func NewCertificationApplicationService(
walletAggregateService: walletAggregateService,
apiUserAggregateService: apiUserAggregateService,
enterpriseInfoSubmitRecordService: enterpriseInfoSubmitRecordService,
ocrService: ocrService,
txManager: txManager,
logger: logger,
}
@@ -987,3 +991,33 @@ func (s *CertificationApplicationServiceImpl) AddStatusMetadata(ctx context.Cont
return metadata, nil
}
// RecognizeBusinessLicense OCR识别营业执照
func (s *CertificationApplicationServiceImpl) RecognizeBusinessLicense(
ctx context.Context,
imageBytes []byte,
) (*responses.BusinessLicenseResult, error) {
s.logger.Info("开始OCR识别营业执照", zap.Int("image_size", len(imageBytes)))
// 调用OCR服务识别营业执照
result, err := s.ocrService.RecognizeBusinessLicense(ctx, imageBytes)
if err != nil {
s.logger.Error("OCR识别营业执照失败", zap.Error(err))
return nil, fmt.Errorf("营业执照识别失败: %w", err)
}
// 验证识别结果
if err := s.ocrService.ValidateBusinessLicense(result); err != nil {
s.logger.Error("营业执照识别结果验证失败", zap.Error(err))
return nil, fmt.Errorf("营业执照识别结果不完整: %w", err)
}
s.logger.Info("营业执照OCR识别成功",
zap.String("company_name", result.CompanyName),
zap.String("unified_social_code", result.UnifiedSocialCode),
zap.String("legal_person_name", result.LegalPersonName),
zap.Float64("confidence", result.Confidence),
)
return result, nil
}