fix(system-accounts): 修复省市系统账户自动创建的数据流问题
1. contribution-service: 修复 CITY 类型账户的 provinceCode 映射 - 之前 CITY 的 provinceCode 被错误设为 cityCode - 现在正确传递 provinceCode 用于创建省份 2. mining-wallet-service: 修复系统账户创建事件的 topic - 之前发布到 mining-wallet.system-account.created - 现在发布到 cdc.mining-wallet.outbox 供 mining-admin-service 同步 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
cded4b2134
commit
96da7518bf
|
|
@ -121,13 +121,14 @@ export class ContributionDistributionPublisherService {
|
||||||
return result.systemContributions.map((sys) => ({
|
return result.systemContributions.map((sys) => ({
|
||||||
accountType: sys.accountType,
|
accountType: sys.accountType,
|
||||||
amount: sys.amount.value.toString(),
|
amount: sys.amount.value.toString(),
|
||||||
// 直接使用 regionCode,没有就用传入的参数
|
// 省份代码:PROVINCE 用自己的 regionCode,CITY 需要传递省份代码用于创建省份
|
||||||
provinceCode:
|
provinceCode:
|
||||||
sys.accountType === 'PROVINCE'
|
sys.accountType === 'PROVINCE'
|
||||||
? sys.regionCode || provinceCode
|
? sys.regionCode || provinceCode
|
||||||
: sys.accountType === 'CITY'
|
: sys.accountType === 'CITY'
|
||||||
? sys.regionCode || cityCode
|
? provinceCode // CITY 需要省份代码来创建省份(如果省份不存在)
|
||||||
: undefined,
|
: undefined,
|
||||||
|
// 城市代码:只有 CITY 类型有
|
||||||
cityCode:
|
cityCode:
|
||||||
sys.accountType === 'CITY' ? sys.regionCode || cityCode : undefined,
|
sys.accountType === 'CITY' ? sys.regionCode || cityCode : undefined,
|
||||||
neverExpires: sys.accountType === 'OPERATION', // 运营账户永不过期
|
neverExpires: sys.accountType === 'OPERATION', // 运营账户永不过期
|
||||||
|
|
|
||||||
|
|
@ -396,13 +396,13 @@ export class ContributionWalletService {
|
||||||
});
|
});
|
||||||
this.logger.log(`Auto-created province system account: ${account.code}`);
|
this.logger.log(`Auto-created province system account: ${account.code}`);
|
||||||
|
|
||||||
// 发布系统账户创建事件到 Outbox
|
// 发布系统账户创建事件到 Outbox(用于 mining-admin-service 同步)
|
||||||
await tx.outboxEvent.create({
|
await tx.outboxEvent.create({
|
||||||
data: {
|
data: {
|
||||||
aggregateType: 'SystemAccount',
|
aggregateType: 'SystemAccount',
|
||||||
aggregateId: account.id,
|
aggregateId: account.id,
|
||||||
eventType: 'WalletSystemAccountCreated',
|
eventType: 'WalletSystemAccountCreated',
|
||||||
topic: 'mining-wallet.system-account.created',
|
topic: 'cdc.mining-wallet.outbox',
|
||||||
key: account.code,
|
key: account.code,
|
||||||
payload: {
|
payload: {
|
||||||
id: account.id,
|
id: account.id,
|
||||||
|
|
@ -481,13 +481,13 @@ export class ContributionWalletService {
|
||||||
});
|
});
|
||||||
this.logger.log(`Auto-created city system account: ${account.code}`);
|
this.logger.log(`Auto-created city system account: ${account.code}`);
|
||||||
|
|
||||||
// 发布系统账户创建事件到 Outbox
|
// 发布系统账户创建事件到 Outbox(用于 mining-admin-service 同步)
|
||||||
await tx.outboxEvent.create({
|
await tx.outboxEvent.create({
|
||||||
data: {
|
data: {
|
||||||
aggregateType: 'SystemAccount',
|
aggregateType: 'SystemAccount',
|
||||||
aggregateId: account.id,
|
aggregateId: account.id,
|
||||||
eventType: 'WalletSystemAccountCreated',
|
eventType: 'WalletSystemAccountCreated',
|
||||||
topic: 'mining-wallet.system-account.created',
|
topic: 'cdc.mining-wallet.outbox',
|
||||||
key: account.code,
|
key: account.code,
|
||||||
payload: {
|
payload: {
|
||||||
id: account.id,
|
id: account.id,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue