fix(mining-admin): 修复 SystemContributionRecordCreated 事件字段映射

contribution-service 使用 systemAccountType 字段发布事件,
mining-admin-service 需要正确映射到 accountType 和 regionCode

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-21 01:09:44 -08:00
parent 96da7518bf
commit 6de365e707
1 changed files with 15 additions and 2 deletions

View File

@ -620,8 +620,21 @@ export class CdcSyncService implements OnModuleInit {
private async handleSystemContributionRecordCreated(event: ServiceEvent, tx: TransactionClient): Promise<void> {
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) },