fix(admin-service): 认种汇总和分类账只显示已支付订单

过滤掉 CREATED、PROVINCE_CITY_CONFIRMED、CANCELLED 状态的订单,
只统计已支付及之后的订单(PAID, FUND_ALLOCATED, POOL_SCHEDULED, POOL_INJECTED, MINING_ENABLED)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-08 09:37:28 -08:00
parent 2553d05902
commit 1676e82cc6
1 changed files with 9 additions and 3 deletions

View File

@ -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<PlantingLedgerResult> {
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 = {};