diff --git a/backend/services/mining-wallet-service/prisma/seed.ts b/backend/services/mining-wallet-service/prisma/seed.ts index d160e008..77674e60 100644 --- a/backend/services/mining-wallet-service/prisma/seed.ts +++ b/backend/services/mining-wallet-service/prisma/seed.ts @@ -19,7 +19,7 @@ async function main() { }); if (!existing) { - await prisma.systemAccount.create({ + const created = await prisma.systemAccount.create({ data: { accountType: account.accountType as any, name: account.name, @@ -27,6 +27,35 @@ async function main() { isActive: true, }, }); + + // 发布系统账户创建事件到 Outbox + await prisma.outboxEvent.create({ + data: { + aggregateType: 'SystemAccount', + aggregateId: created.id, + eventType: 'WalletSystemAccountCreated', + topic: 'mining-wallet.system-account.created', + key: created.code, + payload: { + id: created.id, + accountType: created.accountType, + name: created.name, + code: created.code, + provinceId: null, + cityId: null, + shareBalance: 0, + usdtBalance: 0, + greenPointBalance: 0, + frozenShare: 0, + frozenUsdt: 0, + totalInflow: 0, + totalOutflow: 0, + blockchainAddress: null, + isActive: created.isActive, + }, + }, + }); + console.log(`Created system account: ${account.code}`); } else { console.log(`System account already exists: ${account.code}`); @@ -62,7 +91,7 @@ async function main() { }); if (!existing) { - await prisma.poolAccount.create({ + const created = await prisma.poolAccount.create({ data: { poolType: pool.poolType as any, name: pool.name, @@ -73,6 +102,29 @@ async function main() { isActive: true, }, }); + + // 发布池账户创建事件到 Outbox + await prisma.outboxEvent.create({ + data: { + aggregateType: 'PoolAccount', + aggregateId: created.id, + eventType: 'WalletPoolAccountCreated', + topic: 'mining-wallet.pool-account.created', + key: created.poolType, + payload: { + id: created.id, + poolType: created.poolType, + name: created.name, + balance: created.balance.toString(), + totalInflow: 0, + totalOutflow: 0, + targetBurn: created.targetBurn?.toString() || null, + remainingBurn: created.remainingBurn?.toString() || null, + isActive: created.isActive, + }, + }, + }); + console.log(`Created pool account: ${pool.poolType}`); } else { console.log(`Pool account already exists: ${pool.poolType}`); diff --git a/backend/services/mining-wallet-service/src/application/services/contribution-wallet.service.ts b/backend/services/mining-wallet-service/src/application/services/contribution-wallet.service.ts index cb2f0c0b..9cd8fa00 100644 --- a/backend/services/mining-wallet-service/src/application/services/contribution-wallet.service.ts +++ b/backend/services/mining-wallet-service/src/application/services/contribution-wallet.service.ts @@ -331,6 +331,35 @@ export class ContributionWalletService { }, }); this.logger.log(`Auto-created province system account: ${account.code}`); + + // 发布系统账户创建事件到 Outbox + await tx.outboxEvent.create({ + data: { + aggregateType: 'SystemAccount', + aggregateId: account.id, + eventType: 'WalletSystemAccountCreated', + topic: 'mining-wallet.system-account.created', + key: account.code, + payload: { + id: account.id, + accountType: account.accountType, + name: account.name, + code: account.code, + provinceId: account.provinceId, + cityId: null, + shareBalance: 0, + usdtBalance: 0, + greenPointBalance: 0, + frozenShare: 0, + frozenUsdt: 0, + totalInflow: 0, + totalOutflow: 0, + blockchainAddress: null, + isActive: account.isActive, + }, + }, + }); + return account; } @@ -387,6 +416,35 @@ export class ContributionWalletService { }, }); this.logger.log(`Auto-created city system account: ${account.code}`); + + // 发布系统账户创建事件到 Outbox + await tx.outboxEvent.create({ + data: { + aggregateType: 'SystemAccount', + aggregateId: account.id, + eventType: 'WalletSystemAccountCreated', + topic: 'mining-wallet.system-account.created', + key: account.code, + payload: { + id: account.id, + accountType: account.accountType, + name: account.name, + code: account.code, + provinceId: account.provinceId, + cityId: account.cityId, + shareBalance: 0, + usdtBalance: 0, + greenPointBalance: 0, + frozenShare: 0, + frozenUsdt: 0, + totalInflow: 0, + totalOutflow: 0, + blockchainAddress: null, + isActive: account.isActive, + }, + }, + }); + return account; }