66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
import { Controller, Post, Body, Logger } from '@nestjs/common';
|
|
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
|
|
import { RewardApplicationService } from '../../application/services/reward-application.service';
|
|
|
|
/**
|
|
* 批量查询月度收益请求 DTO
|
|
*/
|
|
class BatchMonthlyEarningsRequest {
|
|
accountSequences: string[];
|
|
month: string; // 格式: YYYY-MM
|
|
rightTypes?: string[]; // 可选,过滤权益类型
|
|
}
|
|
|
|
/**
|
|
* 月度收益响应项
|
|
*/
|
|
interface MonthlyEarningsItem {
|
|
accountSequence: string;
|
|
monthlySettleableUsdt: number;
|
|
monthlyShareUsdt: number; // 分享权益收益
|
|
monthlyProvinceTeamUsdt: number; // 省团队权益收益
|
|
monthlyCityTeamUsdt: number; // 市团队权益收益
|
|
monthlyTotalUsdt: number; // 月度总收益
|
|
}
|
|
|
|
/**
|
|
* 内部 API 控制器
|
|
* 用于服务间通信,不需要 JWT 认证
|
|
*/
|
|
@ApiTags('Internal')
|
|
@Controller('internal')
|
|
export class InternalController {
|
|
private readonly logger = new Logger(InternalController.name);
|
|
|
|
constructor(private readonly rewardService: RewardApplicationService) {}
|
|
|
|
@Post('monthly-earnings/batch')
|
|
@ApiOperation({ summary: '批量查询月度可结算收益(内部接口)' })
|
|
@ApiResponse({ status: 200, description: '成功' })
|
|
async batchGetMonthlyEarnings(
|
|
@Body() request: BatchMonthlyEarningsRequest,
|
|
): Promise<MonthlyEarningsItem[]> {
|
|
const { accountSequences, month, rightTypes } = request;
|
|
|
|
if (!accountSequences || accountSequences.length === 0) {
|
|
return [];
|
|
}
|
|
|
|
this.logger.debug(
|
|
`[batchGetMonthlyEarnings] 查询 ${accountSequences.length} 个账户的月度收益, month=${month}`,
|
|
);
|
|
|
|
const result = await this.rewardService.batchGetMonthlyEarnings(
|
|
accountSequences,
|
|
month,
|
|
rightTypes,
|
|
);
|
|
|
|
this.logger.debug(
|
|
`[batchGetMonthlyEarnings] 返回 ${result.length} 条记录`,
|
|
);
|
|
|
|
return result;
|
|
}
|
|
}
|