From 6de365e70730601ef66d6dba16ab8a964d2937d6 Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 21 Jan 2026 01:09:44 -0800 Subject: [PATCH] =?UTF-8?q?fix(mining-admin):=20=E4=BF=AE=E5=A4=8D=20Syste?= =?UTF-8?q?mContributionRecordCreated=20=E4=BA=8B=E4=BB=B6=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit contribution-service 使用 systemAccountType 字段发布事件, mining-admin-service 需要正确映射到 accountType 和 regionCode Co-Authored-By: Claude Opus 4.5 --- .../infrastructure/kafka/cdc-sync.service.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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) },