f
This commit is contained in:
@@ -1697,7 +1697,7 @@ func (s *CertificationApplicationServiceImpl) checkAndUpdateSignStatus(ctx conte
|
||||
} else {
|
||||
reason = "合同签署中"
|
||||
}
|
||||
err = s.aggregateService.SaveCertification(ctx, cert)
|
||||
err = s.aggregateService.SaveCertification(txCtx, cert)
|
||||
if err != nil {
|
||||
return fmt.Errorf("保存认证信息失败: %s", err.Error())
|
||||
}
|
||||
@@ -1767,6 +1767,17 @@ func (s *CertificationApplicationServiceImpl) handleContractAfterSignComplete(ct
|
||||
cert.ContractCode,
|
||||
)
|
||||
if err != nil {
|
||||
// 重试场景:合同可能已落库,视为成功继续后续激活
|
||||
if strings.Contains(err.Error(), "合同文件ID已存在") {
|
||||
s.logger.Info("合同文件已存在,跳过重复保存",
|
||||
zap.String("file_name", fileName),
|
||||
zap.String("file_id", fileId),
|
||||
)
|
||||
if i == 0 && cert.ContractURL == "" {
|
||||
cert.ContractURL = qiniuURL
|
||||
}
|
||||
continue
|
||||
}
|
||||
s.logger.Error("保存合同信息到聚合根失败", zap.String("file_name", fileName), zap.Error(err))
|
||||
continue
|
||||
}
|
||||
@@ -1837,15 +1848,18 @@ func firstNonEmptyStr(values ...string) string {
|
||||
}
|
||||
|
||||
// completeUserActivationWithoutContract 创建钱包、API用户并在用户域标记完成认证(不依赖合同信息)
|
||||
// 钱包与 API 用户已存在时幂等跳过,避免重复创建导致事务中止
|
||||
func (s *CertificationApplicationServiceImpl) completeUserActivationWithoutContract(ctx context.Context, cert *entities.Certification) error {
|
||||
// 创建钱包
|
||||
// 创建钱包(已存在则幂等返回,不中断流程)
|
||||
if _, err := s.walletAggregateService.CreateWallet(ctx, cert.UserID); err != nil {
|
||||
s.logger.Error("创建钱包失败", zap.String("user_id", cert.UserID), zap.Error(err))
|
||||
return fmt.Errorf("创建钱包失败: %w", err)
|
||||
}
|
||||
|
||||
// 创建API用户
|
||||
// 创建API用户(已存在则幂等成功,不重复插入)
|
||||
if err := s.apiUserAggregateService.CreateApiUser(ctx, cert.UserID); err != nil {
|
||||
s.logger.Error("创建API用户失败", zap.String("user_id", cert.UserID), zap.Error(err))
|
||||
return fmt.Errorf("创建API用户失败: %w", err)
|
||||
}
|
||||
|
||||
// 标记用户域完成认证
|
||||
|
||||
Reference in New Issue
Block a user