export type OrderItem = {
  Id: number
  OrderNo: string
  OrderType: number
  ProductId: number
  ProductName: string
  PackageName: string
  DayPrice: number
  ConnectCount: number
  AccountCount: number
  Accounts: string
  OrderAmount: number
  CouponAmount: number
  PaymentAmount: number
  CreateTime: string
  UpdateTime: string
}

export type OrderFilters = {
  orderType: string
  productId: string
  packageName: string
  keyword: string
  bTime: string
  eTime: string
}

export const DEFAULT_FILTERS: OrderFilters = {
  orderType: "0",
  productId: "0",
  packageName: "0",
  keyword: "",
  bTime: "",
  eTime: "",
}

export const ORDER_TYPE_LABELS: Record<number, string> = {
  1: "新开",
  2: "续费",
  3: "批量新开",
  4: "批量续费",
}

export const PACKAGE_OPTIONS = [
  "测试卡",
  "天卡",
  "周卡",
  "月卡",
  "月卡(活动)",
  "双月卡(活动)",
  "季卡",
  "季卡(活动)",
  "年卡",
]

export function formatOrderType(type: number): string {
  return ORDER_TYPE_LABELS[type] ?? String(type)
}

export function cutAccount(accounts: string, max = 15): string {
  if (accounts.length > max) return `${accounts.slice(0, max)}...`
  return accounts
}

export function totalConnections(item: OrderItem): number {
  return item.ConnectCount * item.AccountCount
}
