From e8f3c34723f92ed29e053ea21c46725ea2d6d262 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 17 Jan 2026 08:29:14 -0800 Subject: [PATCH] =?UTF-8?q?fix(contribution):=20=E8=AE=A4=E7=A7=8D?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=80=BB=E8=B4=A1=E7=8C=AE=E5=80=BC=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=94=A8=E6=88=B7=E5=AE=9E=E9=99=85=E6=9C=89=E6=95=88?= =?UTF-8?q?=E7=AE=97=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 后端: - get-planting-ledger.query.ts: 添加effectiveContribution字段 - 从contributionAccount获取用户实际的个人算力(personalContribution) 前端: - planting_record.dart: PlantingSummary添加effectiveContribution字段 - planting_record_model.dart: 解析effectiveContribution字段 - planting_records_page.dart: 总贡献值显示effectiveContribution而非totalAmount Co-Authored-By: Claude Opus 4.5 --- .../queries/get-planting-ledger.query.ts | 15 +++++++++++++-- .../lib/data/models/planting_record_model.dart | 2 ++ .../lib/domain/entities/planting_record.dart | 6 +++++- .../pages/profile/planting_records_page.dart | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/backend/services/contribution-service/src/application/queries/get-planting-ledger.query.ts b/backend/services/contribution-service/src/application/queries/get-planting-ledger.query.ts index 850c5f9b..991f168e 100644 --- a/backend/services/contribution-service/src/application/queries/get-planting-ledger.query.ts +++ b/backend/services/contribution-service/src/application/queries/get-planting-ledger.query.ts @@ -1,5 +1,6 @@ import { Injectable } from '@nestjs/common'; import { SyncedDataRepository } from '../../infrastructure/persistence/repositories/synced-data.repository'; +import { ContributionAccountRepository } from '../../infrastructure/persistence/repositories/contribution-account.repository'; export interface PlantingRecordDto { orderId: string; @@ -18,6 +19,8 @@ export interface PlantingSummaryDto { totalTreeCount: number; totalAmount: string; effectiveTreeCount: number; + /** 用户实际的有效贡献值(个人算力) */ + effectiveContribution: string; firstPlantingAt: string | null; lastPlantingAt: string | null; } @@ -33,24 +36,32 @@ export interface PlantingLedgerDto { @Injectable() export class GetPlantingLedgerQuery { - constructor(private readonly syncedDataRepository: SyncedDataRepository) {} + constructor( + private readonly syncedDataRepository: SyncedDataRepository, + private readonly contributionAccountRepository: ContributionAccountRepository, + ) {} async execute( accountSequence: string, page: number = 1, pageSize: number = 20, ): Promise { - const [summary, ledger] = await Promise.all([ + const [summary, ledger, contributionAccount] = await Promise.all([ this.syncedDataRepository.getPlantingSummary(accountSequence), this.syncedDataRepository.getPlantingLedger(accountSequence, page, pageSize), + this.contributionAccountRepository.findByAccountSequence(accountSequence), ]); + // 获取用户实际的有效贡献值(个人算力) + const effectiveContribution = contributionAccount?.personalContribution.toString() || '0'; + return { summary: { totalOrders: summary.totalOrders, totalTreeCount: summary.totalTreeCount, totalAmount: summary.totalAmount, effectiveTreeCount: summary.effectiveTreeCount, + effectiveContribution, firstPlantingAt: summary.firstPlantingAt?.toISOString() || null, lastPlantingAt: summary.lastPlantingAt?.toISOString() || null, }, diff --git a/frontend/mining-app/lib/data/models/planting_record_model.dart b/frontend/mining-app/lib/data/models/planting_record_model.dart index ef4221bd..14320128 100644 --- a/frontend/mining-app/lib/data/models/planting_record_model.dart +++ b/frontend/mining-app/lib/data/models/planting_record_model.dart @@ -57,6 +57,7 @@ class PlantingSummaryModel extends PlantingSummary { required super.totalTreeCount, required super.totalAmount, required super.effectiveTreeCount, + required super.effectiveContribution, super.firstPlantingAt, super.lastPlantingAt, }); @@ -67,6 +68,7 @@ class PlantingSummaryModel extends PlantingSummary { totalTreeCount: json['totalTreeCount'] ?? 0, totalAmount: json['totalAmount']?.toString() ?? '0', effectiveTreeCount: json['effectiveTreeCount'] ?? 0, + effectiveContribution: json['effectiveContribution']?.toString() ?? '0', firstPlantingAt: json['firstPlantingAt'] != null ? DateTime.tryParse(json['firstPlantingAt']) : null, diff --git a/frontend/mining-app/lib/domain/entities/planting_record.dart b/frontend/mining-app/lib/domain/entities/planting_record.dart index f86a3266..44649a73 100644 --- a/frontend/mining-app/lib/domain/entities/planting_record.dart +++ b/frontend/mining-app/lib/domain/entities/planting_record.dart @@ -80,10 +80,12 @@ class PlantingSummary extends Equatable { final int totalOrders; /// 总认种量 final int totalTreeCount; - /// 总金额 + /// 总金额(理论贡献值) final String totalAmount; /// 有效认种量 final int effectiveTreeCount; + /// 有效贡献值(实际个人算力) + final String effectiveContribution; /// 首次认种时间 final DateTime? firstPlantingAt; /// 最近认种时间 @@ -94,6 +96,7 @@ class PlantingSummary extends Equatable { required this.totalTreeCount, required this.totalAmount, required this.effectiveTreeCount, + required this.effectiveContribution, this.firstPlantingAt, this.lastPlantingAt, }); @@ -104,6 +107,7 @@ class PlantingSummary extends Equatable { totalTreeCount, totalAmount, effectiveTreeCount, + effectiveContribution, firstPlantingAt, lastPlantingAt, ]; diff --git a/frontend/mining-app/lib/presentation/pages/profile/planting_records_page.dart b/frontend/mining-app/lib/presentation/pages/profile/planting_records_page.dart index ac2e5384..58d45005 100644 --- a/frontend/mining-app/lib/presentation/pages/profile/planting_records_page.dart +++ b/frontend/mining-app/lib/presentation/pages/profile/planting_records_page.dart @@ -257,7 +257,7 @@ class _PlantingRecordsPageState extends ConsumerState { children: [ _buildSummaryItem('总订单数', summary.totalOrders.toString()), _buildSummaryItem('总认种量', summary.totalTreeCount.toString(), color: _green), - _buildSummaryItem('总贡献值', formatAmount(summary.totalAmount), color: _orange), + _buildSummaryItem('总贡献值', formatAmount(summary.effectiveContribution), color: _orange), ], ), const SizedBox(height: 16),