// 订单状态类型
export type OrderStatus = 'pending' | 'paid' | 'shipped' | 'completed' | 'cancelled' | 'refunded'

// 订单类型
export type OrderType = 'flower' | 'animal' | 'activity' | 'travel' | 'other'

// 支付方式类型
export type PaymentMethod = 'wechat' | 'alipay' | 'bank' | 'balance'

// 支付状态类型
export type PaymentStatus = 'pending' | 'paid' | 'failed' | 'refunded'

// 订单基本信息接口
export interface Order {
  id: number
  orderNo: string
  userId: number
  username: string
  merchantId: number
  shopName: string
  orderType: OrderType
  productName: string
  quantity: number
  unitPrice: number
  totalAmount: number
  status: OrderStatus
  createTime: string
  payTime?: string
  completeTime?: string
  cancelTime?: string
  // 支付信息
  paymentMethod?: PaymentMethod
  paymentStatus?: PaymentStatus
  transactionNo?: string
  // 收货信息
  recipientName: string
  recipientPhone: string
  deliveryAddress: string
  deliveryTime?: string
  // 附加信息
  message?: string
  remark?: string
  // 评价信息
  rating?: number
  review?: string
  reviewTime?: string
  // 退款信息
  refundAmount?: number
  refundReason?: string
  refundTime?: string
  // 物流信息
  trackingNo?: string
  shippingCompany?: string
}

// 订单查询参数接口
export interface OrderQueryParams {
  page: number
  pageSize: number
  keyword?: string
  status?: OrderStatus
  orderType?: OrderType
  merchantId?: number
  userId?: number
  startDate?: string
  endDate?: string
  sortField?: string
  sortOrder?: 'asc' | 'desc'
}

// 订单统计信息接口
export interface OrderStatistics {
  totalOrders: number
  pendingOrders: number
  completedOrders: number
  cancelledOrders: number
  totalRevenue: number
  averageOrderValue: number
  dailyOrderCount: number
  orderTypeDistribution: Record<OrderType, number>
  statusDistribution: Record<OrderStatus, number>
  monthlyGrowth: number
  topProducts: string[]
  revenueTrend: Array<{
    date: string
    revenue: number
    orderCount: number
  }>
}

// 订单收入统计接口
export interface OrderRevenueStats {
  date: string
  revenue: number
  orderCount: number
  averageOrderValue: number
  refundAmount: number
  netRevenue: number
}

// 订单类型统计接口
export interface OrderTypeStats {
  orderType: OrderType
  count: number
  totalRevenue: number
  averageOrderValue: number
  completionRate: number
}

// 订单状态统计接口
export interface OrderStatusStats {
  status: OrderStatus
  count: number
  percentage: number
}

// 订单支付统计接口
export interface OrderPaymentStats {
  paymentMethod: PaymentMethod
  count: number
  totalAmount: number
  successRate: number
}

// 订单退款统计接口
export interface OrderRefundStats {
  date: string
  refundCount: number
  refundAmount: number
  refundRate: number
  mainReasons: string[]
}

// 订单操作记录接口
export interface OrderOperationLog {
  id: number
  orderId: number
  orderNo: string
  operationType: string
  operationDetail: string
  operationTime: string
  operator: string
  result: 'success' | 'failure'
  remark?: string
}

// 订单导出参数接口
export interface OrderExportParams {
  format: 'csv' | 'excel'
  fields: string[]
  startDate?: string
  endDate?: string
  status?: OrderStatus
  orderType?: OrderType
  merchantId?: number
}

// 订单退款申请接口
export interface OrderRefundApplication {
  id: number
  orderId: number
  orderNo: string
  userId: number
  username: string
  refundAmount: number
  refundReason: string
  status: 'pending' | 'approved' | 'rejected' | 'completed'
  applyTime: string
  processTime?: string
  processRemark?: string
  processor?: string
}

// 订单评价接口
export interface OrderReview {
  id: number
  orderId: number
  userId: number
  username: string
  merchantId: number
  shopName: string
  rating: number
  review: string
  reviewTime: string
  isAnonymous: boolean
  reply?: string
  replyTime?: string
  helpfulCount: number
  reportCount: number
  status: 'normal' | 'hidden' | 'deleted'
}

// 订单物流信息接口
export interface OrderShippingInfo {
  id: number
  orderId: number
  orderNo: string
  trackingNo: string
  shippingCompany: string
  shippingTime: string
  estimatedDelivery: string
  actualDelivery?: string
  shippingStatus: 'pending' | 'shipped' | 'in_transit' | 'delivered' | 'failed'
  shippingCost: number
  recipientName: string
  recipientPhone: string
  deliveryAddress: string
  deliveryNotes?: string
}