// ===================== 用户相关 =====================

export enum UserStatus {
  ACTIVE = 'active',
  FROZEN = 'frozen',
  DELETED = 'deleted',
}

export interface IUser {
  id: number;
  phone: string;
  nickname: string;
  avatar: string;
  gender: number;
  realName?: string;
  status: UserStatus;
  createdAt: Date;
  updatedAt: Date;
}

// ===================== 商家账户相关 =====================

export enum SellerStatus {
  ACTIVE = 'active',
  FROZEN = 'frozen',
  DELETED = 'deleted',
}

export interface ISeller {
  id: number;
  phone: string;
  contactName: string;
  email?: string;
  status: SellerStatus;
  lastLoginAt?: Date;
  createdAt: Date;
  updatedAt: Date;
}

// ===================== 商家店铺相关 =====================

export enum MerchantStatus {
  PENDING = 'pending',
  APPROVED = 'approved',
  REJECTED = 'rejected',
  FROZEN = 'frozen',
}

export interface IMerchant {
  id: number;
  sellerId: number;
  shopName: string;
  logo: string;
  description?: string;
  phone: string;
  province: string;
  city: string;
  district: string;
  address: string;
  longitude?: number;
  latitude?: number;
  businessLicense: string;
  licenseNo: string;
  legalPerson: string;
  status: MerchantStatus;
  rejectReason?: string;
  deposit: number;
  rating: number;
  reviewCount: number;
  autoConfirm: boolean;
  createdAt: Date;
  updatedAt: Date;
}

// 申请创建店铺参数
export interface IApplyMerchantParams {
  shopName: string;
  phone: string;
  province?: string;
  city?: string;
  district?: string;
  address?: string;
  businessLicense: string;
  licenseNo?: string;
  legalPerson?: string;
  description?: string;
}

// ===================== 房源相关 =====================

export enum RoomStatus {
  ON_SALE = 'on_sale',
  OFF_SALE = 'off_sale',
}

export interface IRoom {
  id: number;
  merchantId: number;
  name: string;
  type: string;
  area: number;
  bedType: string;
  maxGuests: number;
  price: number;
  facilities: string;
  images: string;
  status: RoomStatus;
  rating: number;
  createdAt: Date;
  updatedAt: Date;
}

// ===================== 订单相关 =====================

export enum OrderStatus {
  PENDING_PAY = 'pending_pay',
  PENDING_CONFIRM = 'pending_confirm',
  PENDING_CHECKIN = 'pending_checkin',
  CHECKED_IN = 'checked_in',
  COMPLETED = 'completed',
  CANCELLED = 'cancelled',
  REFUNDING = 'refunding',
}

export enum PaymentMethod {
  WECHAT = 'wechat',
  ALIPAY = 'alipay',
  BALANCE = 'balance',
}

export interface IOrder {
  id: number;
  orderNo: string;
  userId: number;
  merchantId: number;
  roomId: number;
  checkInDate: string;
  checkOutDate: string;
  nights: number;
  roomPrice: number;
  couponDiscount: number;
  totalAmount: number;
  payAmount: number;
  paymentMethod: PaymentMethod | null;
  status: OrderStatus;
  contactName: string;
  contactPhone: string;
  remark: string;
  createdAt: Date;
  updatedAt: Date;
}

// ===================== 评价相关 =====================

export interface IReview {
  id: number;
  orderId: number;
  userId: number;
  merchantId: number;
  roomId: number;
  rating: number;
  content: string;
  images: string;
  merchantReply: string;
  createdAt: Date;
}

// ===================== 优惠券相关 =====================

export enum CouponType {
  FIXED = 'fixed',
  PERCENT = 'percent',
}

export enum CouponStatus {
  AVAILABLE = 'available',
  USED = 'used',
  EXPIRED = 'expired',
}

export interface ICoupon {
  id: number;
  name: string;
  type: CouponType;
  value: number;
  minAmount: number;
  startDate: string;
  endDate: string;
  totalCount: number;
  usedCount: number;
  status: CouponStatus;
}

export interface IUserCoupon {
  id: number;
  userId: number;
  couponId: number;
  status: CouponStatus;
  usedAt: Date | null;
}

// ===================== 促销活动相关 =====================

export enum PromotionType {
  FULL_REDUCTION = 'full_reduction',
  DISCOUNT = 'discount',
  PACKAGE = 'package',
}

export enum PromotionStatus {
  PENDING = 'pending',
  ACTIVE = 'active',
  PAUSED = 'paused',
  ENDED = 'ended',
}

export interface IPromotion {
  id: number;
  merchantId: number;
  name: string;
  type: PromotionType;
  rules: string;
  startDate: string;
  endDate: string;
  status: PromotionStatus;
  createdAt: Date;
}

// ===================== 财务相关 =====================

export enum WithdrawStatus {
  PENDING = 'pending',
  APPROVED = 'approved',
  REJECTED = 'rejected',
  PAID = 'paid',
}

export interface IWithdraw {
  id: number;
  merchantId: number;
  amount: number;
  status: WithdrawStatus;
  bankAccount: string;
  bankName: string;
  reviewedAt: Date | null;
  paidAt: Date | null;
  createdAt: Date;
}

// ===================== 通用分页 =====================

export interface IPaginationQuery {
  page: number;
  pageSize: number;
}

export interface IPaginatedResult<T> {
  list: T[];
  total: number;
  page: number;
  pageSize: number;
  totalPages: number;
}

// ===================== API 响应 =====================

export interface IApiResponse<T = any> {
  code: number;
  message: string;
  data: T;
}

export interface ILoginResult {
  accessToken: string;
  refreshToken: string;
  userInfo: IUser;
}

// ===================== 商家登录结果 =====================

export interface ISellerLoginResult {
  accessToken: string;
  refreshToken: string;
  sellerInfo: ISellerInfo;
}

export interface ISellerInfo {
  id: number;
  phone: string;
  contactName: string;
  email?: string;
  status: SellerStatus;
  merchantId?: number;
  merchantStatus?: MerchantStatus;
}

// ===================== 导出财务相关模块 =====================

export * from './finance';
export * from './finance-constants';
