diff --git a/backend/services/mining-admin-service/src/infrastructure/kafka/cdc-sync.service.ts b/backend/services/mining-admin-service/src/infrastructure/kafka/cdc-sync.service.ts index d3babc9a..97115630 100644 --- a/backend/services/mining-admin-service/src/infrastructure/kafka/cdc-sync.service.ts +++ b/backend/services/mining-admin-service/src/infrastructure/kafka/cdc-sync.service.ts @@ -620,8 +620,21 @@ export class CdcSyncService implements OnModuleInit { private async handleSystemContributionRecordCreated(event: ServiceEvent, tx: TransactionClient): Promise { const { payload } = event; - const accountType = payload.accountType; - const regionCode = payload.regionCode || null; + // contribution-service 使用 systemAccountType 字段,需要兼容处理 + const systemAccountType = payload.systemAccountType || payload.accountType; + + // 解析 systemAccountType:可能是 "PROVINCE_440000" 或 "PROVINCE" + let accountType: string; + let regionCode: string | null = null; + + if (systemAccountType?.includes('_')) { + const parts = systemAccountType.split('_'); + accountType = parts[0]; + regionCode = parts.slice(1).join('_'); + } else { + accountType = systemAccountType; + regionCode = payload.regionCode || null; + } await tx.syncedSystemContributionRecord.upsert({ where: { originalRecordId: BigInt(payload.recordId) },