rwadurian/backend/services/reporting-service/src/api/controllers/system-account-report.contr...

102 lines
4.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 系统账户报表控制器
* [2026-01-04] 新增提供系统账户报表相关API
* 回滚方式:删除此文件,并从 api.module.ts 中移除注册
*/
import { Controller, Get, Query, Logger } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiQuery } from '@nestjs/swagger';
import { SystemAccountReportApplicationService } from '../../application/services/system-account-report-application.service';
@ApiTags('System Account Reports')
@Controller('system-account-reports')
export class SystemAccountReportController {
private readonly logger = new Logger(SystemAccountReportController.name);
constructor(
private readonly systemAccountReportService: SystemAccountReportApplicationService,
) {}
@Get()
@ApiOperation({ summary: '获取完整系统账户报表' })
@ApiQuery({ name: 'startDate', required: false, description: '开始日期 (YYYY-MM-DD)' })
@ApiQuery({ name: 'endDate', required: false, description: '结束日期 (YYYY-MM-DD)' })
@ApiResponse({ status: 200, description: '系统账户报表数据' })
async getFullReport(
@Query('startDate') startDate?: string,
@Query('endDate') endDate?: string,
) {
this.logger.log(`[getFullReport] 请求系统账户报表, startDate=${startDate}, endDate=${endDate}`);
return this.systemAccountReportService.getFullReport({ startDate, endDate });
}
@Get('fixed-accounts')
@ApiOperation({ summary: '获取固定系统账户列表(带余额)' })
@ApiResponse({ status: 200, description: '固定系统账户列表' })
async getFixedAccounts() {
this.logger.log('[getFixedAccounts] 请求固定系统账户列表');
return this.systemAccountReportService.getFixedAccountsWithBalances();
}
@Get('province-summary')
@ApiOperation({ summary: '获取省区域账户汇总' })
@ApiResponse({ status: 200, description: '省区域账户汇总' })
async getProvinceSummary() {
this.logger.log('[getProvinceSummary] 请求省区域账户汇总');
return this.systemAccountReportService.getProvinceAccountsSummary();
}
@Get('city-summary')
@ApiOperation({ summary: '获取市区域账户汇总' })
@ApiResponse({ status: 200, description: '市区域账户汇总' })
async getCitySummary() {
this.logger.log('[getCitySummary] 请求市区域账户汇总');
return this.systemAccountReportService.getCityAccountsSummary();
}
@Get('offline-settlement')
@ApiOperation({ summary: '获取面对面结算统计' })
@ApiQuery({ name: 'startDate', required: false, description: '开始日期 (YYYY-MM-DD)' })
@ApiQuery({ name: 'endDate', required: false, description: '结束日期 (YYYY-MM-DD)' })
@ApiResponse({ status: 200, description: '面对面结算统计' })
async getOfflineSettlement(
@Query('startDate') startDate?: string,
@Query('endDate') endDate?: string,
) {
this.logger.log(`[getOfflineSettlement] 请求面对面结算统计, startDate=${startDate}, endDate=${endDate}`);
return this.systemAccountReportService.getOfflineSettlementSummary({ startDate, endDate });
}
@Get('expired-rewards')
@ApiOperation({ summary: '获取过期收益统计' })
@ApiQuery({ name: 'startDate', required: false, description: '开始日期 (YYYY-MM-DD)' })
@ApiQuery({ name: 'endDate', required: false, description: '结束日期 (YYYY-MM-DD)' })
@ApiResponse({ status: 200, description: '过期收益统计' })
async getExpiredRewards(
@Query('startDate') startDate?: string,
@Query('endDate') endDate?: string,
) {
this.logger.log(`[getExpiredRewards] 请求过期收益统计, startDate=${startDate}, endDate=${endDate}`);
return this.systemAccountReportService.getExpiredRewardsSummary({ startDate, endDate });
}
// [2026-01-05] 新增:所有系统账户分类账明细
@Get('all-ledger')
@ApiOperation({ summary: '获取所有系统账户的分类账明细' })
@ApiQuery({ name: 'pageSize', required: false, description: '每个账户显示的条数默认50' })
@ApiQuery({ name: 'startDate', required: false, description: '开始日期 (YYYY-MM-DD)' })
@ApiQuery({ name: 'endDate', required: false, description: '结束日期 (YYYY-MM-DD)' })
@ApiResponse({ status: 200, description: '所有系统账户的分类账明细' })
async getAllSystemAccountsLedger(
@Query('pageSize') pageSize?: string,
@Query('startDate') startDate?: string,
@Query('endDate') endDate?: string,
) {
this.logger.log(`[getAllSystemAccountsLedger] 请求所有系统账户分类账, pageSize=${pageSize}, startDate=${startDate}, endDate=${endDate}`);
return this.systemAccountReportService.getAllSystemAccountsLedger({
pageSize: pageSize ? parseInt(pageSize, 10) : undefined,
startDate,
endDate,
});
}
}