From 724fb08be40350f510bac268bb9a32750537a915 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 28 Feb 2026 11:35:55 -0800 Subject: [PATCH] =?UTF-8?q?fix(contribution):=20=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E8=BF=87=E6=9C=9F=E4=BB=BD=E9=A2=9D=E5=90=8C=E6=AD=A5=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=20+=20=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0/=E6=8C=96?= =?UTF-8?q?=E7=9F=BFapp=E7=8A=B6=E6=80=81=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - contribution-service: swapContributionForMerge 作废旧份额记录后, 立即发布 ContributionRecordSynced outbox 事件(isExpired=true), mining-admin-service 收到后 upsert syncedContributionRecord - mining-admin-web: 算力记录状态列改为绿色"有效"/红色"无效" - mining-app: 贡献值记录卡片始终显示有效/无效状态标签 Co-Authored-By: Claude Sonnet 4.6 --- .../pre-planting-contribution.service.ts | 33 +++++++++++++++++++ .../components/contribution-records-list.tsx | 4 +-- .../contribution_records_page.dart | 27 ++++++++------- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/backend/services/contribution-service/src/pre-planting/application/services/pre-planting-contribution.service.ts b/backend/services/contribution-service/src/pre-planting/application/services/pre-planting-contribution.service.ts index 3840f26d..b9fc959c 100644 --- a/backend/services/contribution-service/src/pre-planting/application/services/pre-planting-contribution.service.ts +++ b/backend/services/contribution-service/src/pre-planting/application/services/pre-planting-contribution.service.ts @@ -725,6 +725,39 @@ export class PrePlantingContributionService { `[PRE-PLANTING-MERGE] Expired ${expiredCount.count} portion records for merge ${mergeNo}`, ); + // 9b-sync: 查询已作废的记录并发布同步事件(mining-admin-service 需要更新 isExpired 状态) + if (expiredCount.count > 0) { + const expiredRecords = await tx.contributionRecord.findMany({ + where: { sourceAdoptionId: { in: portionSourceAdoptionIds }, isExpired: true }, + }); + const expiredEvents = expiredRecords.map((record) => { + const event = new ContributionRecordSyncedEvent( + record.id, + record.accountSequence, + record.sourceType, + record.sourceAdoptionId, + record.sourceAccountSequence, + record.treeCount, + record.baseContribution.toString(), + record.distributionRate.toString(), + record.levelDepth, + record.bonusTier, + record.amount.toString(), + record.effectiveDate, + record.expireDate, + true, + record.createdAt, + ); + return { + aggregateType: ContributionRecordSyncedEvent.AGGREGATE_TYPE, + aggregateId: record.id.toString(), + eventType: ContributionRecordSyncedEvent.EVENT_TYPE, + payload: event.toPayload(), + }; + }); + await this.outboxRepository.saveMany(expiredEvents); + } + // 9c: 从认种人账户扣减旧个人算力(personal_contribution - 和 effective_contribution -) if (parseFloat(expiredPersonalStr) > 0) { await tx.contributionAccount.updateMany({ diff --git a/frontend/mining-admin-web/src/features/users/components/contribution-records-list.tsx b/frontend/mining-admin-web/src/features/users/components/contribution-records-list.tsx index c4b33050..78e2bf66 100644 --- a/frontend/mining-admin-web/src/features/users/components/contribution-records-list.tsx +++ b/frontend/mining-admin-web/src/features/users/components/contribution-records-list.tsx @@ -164,9 +164,9 @@ export function ContributionRecordsList({ accountSequence }: ContributionRecords {formatDate(record.effectiveDate)} {record.isExpired ? ( - 已过期 + 无效 ) : ( - 有效 + 有效 )} diff --git a/frontend/mining-app/lib/presentation/pages/contribution/contribution_records_page.dart b/frontend/mining-app/lib/presentation/pages/contribution/contribution_records_page.dart index 8e5257a2..051a0ea2 100644 --- a/frontend/mining-app/lib/presentation/pages/contribution/contribution_records_page.dart +++ b/frontend/mining-app/lib/presentation/pages/contribution/contribution_records_page.dart @@ -354,20 +354,23 @@ class _ContributionRecordsListPageState extends ConsumerState