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 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-15 00:12:07 -08:00
parent 8ae9e217ff
commit 1f15daa6c5
2 changed files with 11 additions and 11 deletions

View File

@ -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,
};

View File

@ -342,12 +342,12 @@ class _PlantingRecordsPageState extends ConsumerState<PlantingRecordsPage> {
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),
],
),