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:
parent
96da7518bf
commit
6de365e707
|
|
@ -620,8 +620,21 @@ export class CdcSyncService implements OnModuleInit {
|
||||||
private async handleSystemContributionRecordCreated(event: ServiceEvent, tx: TransactionClient): Promise<void> {
|
private async handleSystemContributionRecordCreated(event: ServiceEvent, tx: TransactionClient): Promise<void> {
|
||||||
const { payload } = event;
|
const { payload } = event;
|
||||||
|
|
||||||
const accountType = payload.accountType;
|
// contribution-service 使用 systemAccountType 字段,需要兼容处理
|
||||||
const regionCode = payload.regionCode || null;
|
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({
|
await tx.syncedSystemContributionRecord.upsert({
|
||||||
where: { originalRecordId: BigInt(payload.recordId) },
|
where: { originalRecordId: BigInt(payload.recordId) },
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue