fix(identity-service): KYC成功后发布KYCVerified事件
之前实名认证成功后只更新数据库,没有发布事件, 导致planting-service无法收到通知来创建合同签署任务。 修改内容: - 注入 EventPublisherService - 查询时增加 accountSequence 字段 - 认证成功后发布 KYCVerifiedEvent 到 identity.KYCVerified topic 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
fd04de8696
commit
b3014744ab
|
|
@ -9,6 +9,8 @@ import { SmsService } from '@/infrastructure/external/sms/sms.service';
|
||||||
import { StorageService } from '@/infrastructure/external/storage/storage.service';
|
import { StorageService } from '@/infrastructure/external/storage/storage.service';
|
||||||
import { AliyunKycProvider } from '@/infrastructure/external/kyc/aliyun-kyc.provider';
|
import { AliyunKycProvider } from '@/infrastructure/external/kyc/aliyun-kyc.provider';
|
||||||
import { ApplicationError } from '@/shared/exceptions/domain.exception';
|
import { ApplicationError } from '@/shared/exceptions/domain.exception';
|
||||||
|
import { EventPublisherService } from '@/infrastructure/kafka/event-publisher.service';
|
||||||
|
import { KYCVerifiedEvent } from '@/domain/events';
|
||||||
|
|
||||||
// KYC 综合状态枚举
|
// KYC 综合状态枚举
|
||||||
export enum KycStatus {
|
export enum KycStatus {
|
||||||
|
|
@ -39,6 +41,7 @@ export class KycApplicationService {
|
||||||
private readonly smsService: SmsService,
|
private readonly smsService: SmsService,
|
||||||
private readonly storageService: StorageService,
|
private readonly storageService: StorageService,
|
||||||
private readonly aliyunKycProvider: AliyunKycProvider,
|
private readonly aliyunKycProvider: AliyunKycProvider,
|
||||||
|
private readonly eventPublisher: EventPublisherService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -233,6 +236,7 @@ export class KycApplicationService {
|
||||||
realNameVerified: true,
|
realNameVerified: true,
|
||||||
kycStatus: true,
|
kycStatus: true,
|
||||||
phoneNumber: true,
|
phoneNumber: true,
|
||||||
|
accountSequence: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -303,6 +307,21 @@ export class KycApplicationService {
|
||||||
|
|
||||||
this.logger.log(`[KYC] [Level1] Verification SUCCESS for user: ${userId}`);
|
this.logger.log(`[KYC] [Level1] Verification SUCCESS for user: ${userId}`);
|
||||||
|
|
||||||
|
// 发布 KYCVerified 事件,通知其他服务(如 planting-service)
|
||||||
|
try {
|
||||||
|
const verifiedAt = new Date();
|
||||||
|
const event = new KYCVerifiedEvent({
|
||||||
|
userId,
|
||||||
|
accountSequence: user.accountSequence,
|
||||||
|
verifiedAt,
|
||||||
|
});
|
||||||
|
await this.eventPublisher.publish(event);
|
||||||
|
this.logger.log(`[KYC] [Level1] Published KYCVerified event for user: ${userId}, accountSequence: ${user.accountSequence}`);
|
||||||
|
} catch (eventError) {
|
||||||
|
// 事件发布失败不影响 KYC 结果,只记录日志
|
||||||
|
this.logger.error(`[KYC] [Level1] Failed to publish KYCVerified event for user: ${userId}`, eventError);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
level: 1,
|
level: 1,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue