diff --git a/backend/services/auth-service/src/infrastructure/messaging/cdc/legacy-user-cdc.consumer.ts b/backend/services/auth-service/src/infrastructure/messaging/cdc/legacy-user-cdc.consumer.ts index d7d5a59b..53b33bf3 100644 --- a/backend/services/auth-service/src/infrastructure/messaging/cdc/legacy-user-cdc.consumer.ts +++ b/backend/services/auth-service/src/infrastructure/messaging/cdc/legacy-user-cdc.consumer.ts @@ -124,6 +124,18 @@ export class LegacyUserCdcConsumer implements OnModuleInit, OnModuleDestroy { } private async upsertLegacyUser(user: UnwrappedCdcUser, sequenceNum: bigint) { + // 跳过没有手机号的系统账户(user_id 1-5 通常是系统/测试账户) + if (!user.phone_number) { + this.logger.debug(`Skipped user ${user.user_id} (no phone number)`); + return; + } + + // 跳过没有密码的账户 + if (!user.password_hash) { + this.logger.debug(`Skipped user ${user.user_id} (no password)`); + return; + } + try { await this.prisma.syncedLegacyUser.upsert({ where: { legacyId: BigInt(user.user_id) },