From 1f15daa6c5043b1e376475c532279ccb34f3e3ff Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 15 Jan 2026 00:12:07 -0800 Subject: [PATCH] fix(planting-records): filter only MINING_ENABLED records and fix UI overflow - Backend: Add status filter to getPlantingLedger and getPlantingSummary - Frontend: Change Row to Wrap for info items to prevent width overflow Co-Authored-By: Claude Opus 4.5 --- .../repositories/synced-data.repository.ts | 16 ++++++++-------- .../pages/profile/planting_records_page.dart | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/backend/services/contribution-service/src/infrastructure/persistence/repositories/synced-data.repository.ts b/backend/services/contribution-service/src/infrastructure/persistence/repositories/synced-data.repository.ts index c6da9dfb..c7c4c15e 100644 --- a/backend/services/contribution-service/src/infrastructure/persistence/repositories/synced-data.repository.ts +++ b/backend/services/contribution-service/src/infrastructure/persistence/repositories/synced-data.repository.ts @@ -373,16 +373,18 @@ export class SyncedDataRepository implements ISyncedDataRepository { totalPages: number; }> { const skip = (page - 1) * pageSize; + // 只返回 MINING_ENABLED 状态的认种记录 + const whereClause = { accountSequence, status: 'MINING_ENABLED' }; const [items, total] = await Promise.all([ this.client.syncedAdoption.findMany({ - where: { accountSequence }, + where: whereClause, orderBy: { adoptionDate: 'desc' }, skip, take: pageSize, }), this.client.syncedAdoption.count({ - where: { accountSequence }, + where: whereClause, }), ]); @@ -403,8 +405,9 @@ export class SyncedDataRepository implements ISyncedDataRepository { firstPlantingAt: Date | null; lastPlantingAt: Date | null; }> { + // 只统计 MINING_ENABLED 状态的认种记录 const adoptions = await this.client.syncedAdoption.findMany({ - where: { accountSequence }, + where: { accountSequence, status: 'MINING_ENABLED' }, orderBy: { adoptionDate: 'asc' }, }); @@ -421,11 +424,8 @@ export class SyncedDataRepository implements ISyncedDataRepository { const totalOrders = adoptions.length; const totalTreeCount = adoptions.reduce((sum, a) => sum + a.treeCount, 0); - const effectiveTreeCount = adoptions - .filter((a) => a.status === 'MINING_ENABLED') - .reduce((sum, a) => sum + a.treeCount, 0); - // 计算总金额:treeCount * contributionPerTree (假设每棵树价格等于算力值) + // 计算总金额:treeCount * contributionPerTree let totalAmount = new Decimal(0); for (const adoption of adoptions) { const amount = new Decimal(adoption.contributionPerTree).mul(adoption.treeCount); @@ -436,7 +436,7 @@ export class SyncedDataRepository implements ISyncedDataRepository { totalOrders, totalTreeCount, totalAmount: totalAmount.toString(), - effectiveTreeCount, + effectiveTreeCount: totalTreeCount, // 全部都是有效的 MINING_ENABLED firstPlantingAt: adoptions[0]?.adoptionDate || null, lastPlantingAt: adoptions[adoptions.length - 1]?.adoptionDate || null, }; 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 47581f28..ac5fba64 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 @@ -342,12 +342,12 @@ class _PlantingRecordsPageState extends ConsumerState { const SizedBox(height: 12), // 第二行:认种数量 + 单棵算力 + 总算力 - Row( + Wrap( + spacing: 12, + runSpacing: 8, children: [ _buildInfoItem('认种数量', '${record.treeCount}棵'), - const SizedBox(width: 16), _buildInfoItem('单棵算力', formatAmount(record.contributionPerTree)), - const SizedBox(width: 16), _buildInfoItem('总算力', formatAmount(record.totalContribution), isHighlight: true), ], ),