fix(contribution): 认种记录总贡献值显示用户实际有效算力
后端: - 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 <noreply@anthropic.com>
This commit is contained in:
parent
613fb33ff9
commit
e8f3c34723
|
|
@ -1,5 +1,6 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { SyncedDataRepository } from '../../infrastructure/persistence/repositories/synced-data.repository';
|
import { SyncedDataRepository } from '../../infrastructure/persistence/repositories/synced-data.repository';
|
||||||
|
import { ContributionAccountRepository } from '../../infrastructure/persistence/repositories/contribution-account.repository';
|
||||||
|
|
||||||
export interface PlantingRecordDto {
|
export interface PlantingRecordDto {
|
||||||
orderId: string;
|
orderId: string;
|
||||||
|
|
@ -18,6 +19,8 @@ export interface PlantingSummaryDto {
|
||||||
totalTreeCount: number;
|
totalTreeCount: number;
|
||||||
totalAmount: string;
|
totalAmount: string;
|
||||||
effectiveTreeCount: number;
|
effectiveTreeCount: number;
|
||||||
|
/** 用户实际的有效贡献值(个人算力) */
|
||||||
|
effectiveContribution: string;
|
||||||
firstPlantingAt: string | null;
|
firstPlantingAt: string | null;
|
||||||
lastPlantingAt: string | null;
|
lastPlantingAt: string | null;
|
||||||
}
|
}
|
||||||
|
|
@ -33,24 +36,32 @@ export interface PlantingLedgerDto {
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class GetPlantingLedgerQuery {
|
export class GetPlantingLedgerQuery {
|
||||||
constructor(private readonly syncedDataRepository: SyncedDataRepository) {}
|
constructor(
|
||||||
|
private readonly syncedDataRepository: SyncedDataRepository,
|
||||||
|
private readonly contributionAccountRepository: ContributionAccountRepository,
|
||||||
|
) {}
|
||||||
|
|
||||||
async execute(
|
async execute(
|
||||||
accountSequence: string,
|
accountSequence: string,
|
||||||
page: number = 1,
|
page: number = 1,
|
||||||
pageSize: number = 20,
|
pageSize: number = 20,
|
||||||
): Promise<PlantingLedgerDto> {
|
): Promise<PlantingLedgerDto> {
|
||||||
const [summary, ledger] = await Promise.all([
|
const [summary, ledger, contributionAccount] = await Promise.all([
|
||||||
this.syncedDataRepository.getPlantingSummary(accountSequence),
|
this.syncedDataRepository.getPlantingSummary(accountSequence),
|
||||||
this.syncedDataRepository.getPlantingLedger(accountSequence, page, pageSize),
|
this.syncedDataRepository.getPlantingLedger(accountSequence, page, pageSize),
|
||||||
|
this.contributionAccountRepository.findByAccountSequence(accountSequence),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// 获取用户实际的有效贡献值(个人算力)
|
||||||
|
const effectiveContribution = contributionAccount?.personalContribution.toString() || '0';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
summary: {
|
summary: {
|
||||||
totalOrders: summary.totalOrders,
|
totalOrders: summary.totalOrders,
|
||||||
totalTreeCount: summary.totalTreeCount,
|
totalTreeCount: summary.totalTreeCount,
|
||||||
totalAmount: summary.totalAmount,
|
totalAmount: summary.totalAmount,
|
||||||
effectiveTreeCount: summary.effectiveTreeCount,
|
effectiveTreeCount: summary.effectiveTreeCount,
|
||||||
|
effectiveContribution,
|
||||||
firstPlantingAt: summary.firstPlantingAt?.toISOString() || null,
|
firstPlantingAt: summary.firstPlantingAt?.toISOString() || null,
|
||||||
lastPlantingAt: summary.lastPlantingAt?.toISOString() || null,
|
lastPlantingAt: summary.lastPlantingAt?.toISOString() || null,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ class PlantingSummaryModel extends PlantingSummary {
|
||||||
required super.totalTreeCount,
|
required super.totalTreeCount,
|
||||||
required super.totalAmount,
|
required super.totalAmount,
|
||||||
required super.effectiveTreeCount,
|
required super.effectiveTreeCount,
|
||||||
|
required super.effectiveContribution,
|
||||||
super.firstPlantingAt,
|
super.firstPlantingAt,
|
||||||
super.lastPlantingAt,
|
super.lastPlantingAt,
|
||||||
});
|
});
|
||||||
|
|
@ -67,6 +68,7 @@ class PlantingSummaryModel extends PlantingSummary {
|
||||||
totalTreeCount: json['totalTreeCount'] ?? 0,
|
totalTreeCount: json['totalTreeCount'] ?? 0,
|
||||||
totalAmount: json['totalAmount']?.toString() ?? '0',
|
totalAmount: json['totalAmount']?.toString() ?? '0',
|
||||||
effectiveTreeCount: json['effectiveTreeCount'] ?? 0,
|
effectiveTreeCount: json['effectiveTreeCount'] ?? 0,
|
||||||
|
effectiveContribution: json['effectiveContribution']?.toString() ?? '0',
|
||||||
firstPlantingAt: json['firstPlantingAt'] != null
|
firstPlantingAt: json['firstPlantingAt'] != null
|
||||||
? DateTime.tryParse(json['firstPlantingAt'])
|
? DateTime.tryParse(json['firstPlantingAt'])
|
||||||
: null,
|
: null,
|
||||||
|
|
|
||||||
|
|
@ -80,10 +80,12 @@ class PlantingSummary extends Equatable {
|
||||||
final int totalOrders;
|
final int totalOrders;
|
||||||
/// 总认种量
|
/// 总认种量
|
||||||
final int totalTreeCount;
|
final int totalTreeCount;
|
||||||
/// 总金额
|
/// 总金额(理论贡献值)
|
||||||
final String totalAmount;
|
final String totalAmount;
|
||||||
/// 有效认种量
|
/// 有效认种量
|
||||||
final int effectiveTreeCount;
|
final int effectiveTreeCount;
|
||||||
|
/// 有效贡献值(实际个人算力)
|
||||||
|
final String effectiveContribution;
|
||||||
/// 首次认种时间
|
/// 首次认种时间
|
||||||
final DateTime? firstPlantingAt;
|
final DateTime? firstPlantingAt;
|
||||||
/// 最近认种时间
|
/// 最近认种时间
|
||||||
|
|
@ -94,6 +96,7 @@ class PlantingSummary extends Equatable {
|
||||||
required this.totalTreeCount,
|
required this.totalTreeCount,
|
||||||
required this.totalAmount,
|
required this.totalAmount,
|
||||||
required this.effectiveTreeCount,
|
required this.effectiveTreeCount,
|
||||||
|
required this.effectiveContribution,
|
||||||
this.firstPlantingAt,
|
this.firstPlantingAt,
|
||||||
this.lastPlantingAt,
|
this.lastPlantingAt,
|
||||||
});
|
});
|
||||||
|
|
@ -104,6 +107,7 @@ class PlantingSummary extends Equatable {
|
||||||
totalTreeCount,
|
totalTreeCount,
|
||||||
totalAmount,
|
totalAmount,
|
||||||
effectiveTreeCount,
|
effectiveTreeCount,
|
||||||
|
effectiveContribution,
|
||||||
firstPlantingAt,
|
firstPlantingAt,
|
||||||
lastPlantingAt,
|
lastPlantingAt,
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ class _PlantingRecordsPageState extends ConsumerState<PlantingRecordsPage> {
|
||||||
children: [
|
children: [
|
||||||
_buildSummaryItem('总订单数', summary.totalOrders.toString()),
|
_buildSummaryItem('总订单数', summary.totalOrders.toString()),
|
||||||
_buildSummaryItem('总认种量', summary.totalTreeCount.toString(), color: _green),
|
_buildSummaryItem('总认种量', summary.totalTreeCount.toString(), color: _green),
|
||||||
_buildSummaryItem('总贡献值', formatAmount(summary.totalAmount), color: _orange),
|
_buildSummaryItem('总贡献值', formatAmount(summary.effectiveContribution), color: _orange),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue