import { IsString, IsNotEmpty, IsNumber, IsOptional, IsEnum, Matches } from 'class-validator';
import { Type } from 'class-transformer';

export class CreateOrderDto {
  @IsNumber()
  @Type(() => Number)
  roomId: number;

  @IsString()
  @IsNotEmpty()
  checkInDate: string;

  @IsString()
  @IsNotEmpty()
  checkOutDate: string;

  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  roomCount?: number;

  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  guestCount?: number;

  @IsString()
  @IsNotEmpty()
  contactName: string;

  @IsString()
  @IsNotEmpty()
  @Matches(/^1[3-9]\d{9}$/, { message: '手机号格式不正确' })
  contactPhone: string;

  @IsOptional()
  @IsString()
  contactIdCard?: string;

  @IsOptional()
  @IsString()
  remark?: string;

  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  couponId?: number;

  @IsOptional()
  @IsEnum(['wechat', 'alipay', 'balance'])
  paymentMethod?: 'wechat' | 'alipay' | 'balance';
}

export class QueryOrderDto {
  @IsOptional()
  @Type(() => Number)
  page?: number = 1;

  @IsOptional()
  @Type(() => Number)
  pageSize?: number = 10;

  @IsOptional()
  @IsString()
  status?: string;

  @IsOptional()
  @IsString()
  orderNo?: string;

  @IsOptional()
  @IsString()
  startDate?: string;

  @IsOptional()
  @IsString()
  endDate?: string;
}

export class PayOrderDto {
  @IsString()
  @IsNotEmpty()
  orderNo: string;

  @IsEnum(['wechat', 'alipay', 'balance'])
  paymentMethod: 'wechat' | 'alipay' | 'balance';
}
