fix(admin): add SystemAccountSynced event handler for system contribution sync
The mining-admin-service was only listening for SystemContributionUpdated events, but contribution-service publishes SystemAccountSynced events. Added the missing handler to properly sync system account contribution data. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1f0bd15946
commit
b645621c81
|
|
@ -779,7 +779,9 @@
|
||||||
"Bash(ssh -o StrictHostKeyChecking=no -J ceshi@103.39.231.231 ceshi@192.168.1.111 \"curl -s http://localhost:3020/api/v1/ | head -100\")",
|
"Bash(ssh -o StrictHostKeyChecking=no -J ceshi@103.39.231.231 ceshi@192.168.1.111 \"curl -s http://localhost:3020/api/v1/ | head -100\")",
|
||||||
"Bash(ssh -o StrictHostKeyChecking=no -J ceshi@103.39.231.231 ceshi@192.168.1.111:*)",
|
"Bash(ssh -o StrictHostKeyChecking=no -J ceshi@103.39.231.231 ceshi@192.168.1.111:*)",
|
||||||
"Bash(bc:*)",
|
"Bash(bc:*)",
|
||||||
"Bash(DATABASE_URL=\"postgresql://postgres:password@localhost:5432/mining_db?schema=public\" npx prisma migrate diff:*)"
|
"Bash(DATABASE_URL=\"postgresql://postgres:password@localhost:5432/mining_db?schema=public\" npx prisma migrate diff:*)",
|
||||||
|
"Bash(git status:*)",
|
||||||
|
"Bash(xargs cat:*)"
|
||||||
],
|
],
|
||||||
"deny": [],
|
"deny": [],
|
||||||
"ask": []
|
"ask": []
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,11 @@ export class CdcSyncService implements OnModuleInit {
|
||||||
'SystemContributionUpdated',
|
'SystemContributionUpdated',
|
||||||
this.withIdempotency(this.handleSystemContributionUpdated.bind(this)),
|
this.withIdempotency(this.handleSystemContributionUpdated.bind(this)),
|
||||||
);
|
);
|
||||||
|
// SystemAccountSynced 事件 - 同步系统账户算力(来自 contribution-service)
|
||||||
|
this.cdcConsumer.registerServiceHandler(
|
||||||
|
'SystemAccountSynced',
|
||||||
|
this.withIdempotency(this.handleSystemAccountSynced.bind(this)),
|
||||||
|
);
|
||||||
// ReferralSynced 事件 - 同步推荐关系
|
// ReferralSynced 事件 - 同步推荐关系
|
||||||
this.cdcConsumer.registerServiceHandler(
|
this.cdcConsumer.registerServiceHandler(
|
||||||
'ReferralSynced',
|
'ReferralSynced',
|
||||||
|
|
@ -546,6 +551,27 @@ export class CdcSyncService implements OnModuleInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理 SystemAccountSynced 事件 - 同步系统账户算力
|
||||||
|
* 来自 contribution-service 的系统账户(运营、省、市、总部)算力同步
|
||||||
|
*/
|
||||||
|
private async handleSystemAccountSynced(event: ServiceEvent, tx: TransactionClient): Promise<void> {
|
||||||
|
const { payload } = event;
|
||||||
|
await tx.syncedSystemContribution.upsert({
|
||||||
|
where: { accountType: payload.accountType },
|
||||||
|
create: {
|
||||||
|
accountType: payload.accountType,
|
||||||
|
name: payload.name,
|
||||||
|
contributionBalance: payload.contributionBalance || 0,
|
||||||
|
contributionNeverExpires: true, // 系统账户算力永不过期
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
name: payload.name,
|
||||||
|
contributionBalance: payload.contributionBalance,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理 ReferralSynced 事件 - 同步推荐关系
|
* 处理 ReferralSynced 事件 - 同步推荐关系
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue