import { IsOptional, IsInt, Min, IsEnum, IsDateString } from 'class-validator';
import { Type } from 'class-transformer';
import { ApiPropertyOptional } from '@nestjs/swagger';

export class QuerySettlementDto {
  @ApiPropertyOptional({ description: '页码', example: 1 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  page?: number = 1;

  @ApiPropertyOptional({ description: '每页数量', example: 20 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  pageSize?: number = 20;

  @ApiPropertyOptional({ description: '状态', enum: ['pending', 'settled', 'failed'] })
  @IsOptional()
  @IsEnum(['pending', 'settled', 'failed'])
  status?: string;

  @ApiPropertyOptional({ description: '开始日期', example: '2026-01-01' })
  @IsOptional()
  @IsDateString()
  startDate?: string;

  @ApiPropertyOptional({ description: '结束日期', example: '2026-12-31' })
  @IsOptional()
  @IsDateString()
  endDate?: string;
}

export class QueryMerchantSettlementDto extends QuerySettlementDto {
  @ApiPropertyOptional({ description: '商家ID' })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  merchantId?: number;
}

export class ManualSettlementDto {
  @ApiPropertyOptional({ description: '商家ID' })
  @Type(() => Number)
  @IsInt()
  merchantId: number;

  @ApiPropertyOptional({ description: '周期开始日期', example: '2026-05-06' })
  @IsDateString()
  periodStart: string;

  @ApiPropertyOptional({ description: '周期结束日期', example: '2026-05-12' })
  @IsDateString()
  periodEnd: string;
}

export class ApproveSettlementDto {
  // 预留字段，暂时不需要参数
}

export class RejectSettlementDto {
  @ApiPropertyOptional({ description: '拒绝原因' })
  @IsOptional()
  remark?: string;
}
