diff --git a/backend/services/admin-service/src/infrastructure/persistence/repositories/user-detail-query.repository.impl.ts b/backend/services/admin-service/src/infrastructure/persistence/repositories/user-detail-query.repository.impl.ts index e1476b97..16a3f90f 100644 --- a/backend/services/admin-service/src/infrastructure/persistence/repositories/user-detail-query.repository.impl.ts +++ b/backend/services/admin-service/src/infrastructure/persistence/repositories/user-detail-query.repository.impl.ts @@ -244,10 +244,13 @@ export class UserDetailQueryRepositoryImpl implements IUserDetailQueryRepository this.logger.log(`[getPlantingSummary] 持仓查询结果: ${position ? `effectiveTreeCount=${position.effectiveTreeCount}` : 'null'}`); - // 获取订单统计 - 使用 accountSequence + // 已支付及之后的状态(不包括 CREATED, PROVINCE_CITY_CONFIRMED, CANCELLED) + const paidStatuses = ['PAID', 'FUND_ALLOCATED', 'POOL_SCHEDULED', 'POOL_INJECTED', 'MINING_ENABLED']; + + // 获取订单统计 - 只统计已支付的订单 const [orderStats, firstOrder, lastOrder] = await Promise.all([ this.prisma.plantingOrderQueryView.aggregate({ - where: { accountSequence }, + where: { accountSequence, status: { in: paidStatuses } }, _count: true, _sum: { treeCount: true, @@ -286,7 +289,10 @@ export class UserDetailQueryRepositoryImpl implements IUserDetailQueryRepository startDate?: Date, endDate?: Date, ): Promise { - const where: any = { accountSequence }; + // 已支付及之后的状态(不包括 CREATED, PROVINCE_CITY_CONFIRMED, CANCELLED) + const paidStatuses = ['PAID', 'FUND_ALLOCATED', 'POOL_SCHEDULED', 'POOL_INJECTED', 'MINING_ENABLED']; + + const where: any = { accountSequence, status: { in: paidStatuses } }; if (startDate || endDate) { where.createdAt = {};