/**
 * 飞鹅打印相关类型定义
 */

/**
 * 打印机状态枚举
 */
export enum PrinterStatus {
  ACTIVE = 'ACTIVE',
  INACTIVE = 'INACTIVE',
  ERROR = 'ERROR'
}

/**
 * 打印机类型枚举
 */
export enum PrinterType {
  TYPE_58MM = '58mm',
  TYPE_80MM = '80mm'
}

/**
 * 打印机实体
 */
export interface FeiePrinter {
  id: number;
  tenantId: number;
  printerSn: string;
  printerKey: string;
  printerName?: string;
  printerType: PrinterType;
  printerStatus: PrinterStatus;
  isDefault: boolean;
  createdAt: string;
  updatedAt: string;
}

/**
 * 创建打印机请求
 */
export interface CreatePrinterRequest {
  printerSn: string;
  printerKey: string;
  printerName?: string;
  printerType?: PrinterType;
  isDefault?: boolean;
}

/**
 * 更新打印机请求
 */
export interface UpdatePrinterRequest {
  printerName?: string;
  printerType?: PrinterType;
  printerStatus?: PrinterStatus;
  isDefault?: boolean;
}

/**
 * 打印机列表响应
 */
export interface PrinterListResponse {
  data: FeiePrinter[];
  total: number;
  page: number;
  pageSize: number;
}

/**
 * 打印机查询参数
 */
export interface PrinterQueryParams {
  page?: number;
  pageSize?: number;
  search?: string;
  status?: PrinterStatus;
  printerType?: PrinterType;
}

/**
 * 打印任务状态枚举
 */
export enum PrintTaskStatus {
  PENDING = 'PENDING',
  DELAYED = 'DELAYED',
  PRINTING = 'PRINTING',
  SUCCESS = 'SUCCESS',
  FAILED = 'FAILED',
  CANCELLED = 'CANCELLED'
}

/**
 * 打印任务取消原因枚举
 */
export enum CancelReason {
  REFUND = 'REFUND',
  MANUAL = 'MANUAL',
  TIMEOUT = 'TIMEOUT'
}

/**
 * 打印任务实体
 */
export interface FeiePrintTask {
  id: number;
  tenantId: number;
  taskId: string;
  orderId?: number;
  printerSn: string;
  content: string;
  printType: string;
  printStatus: PrintTaskStatus;
  errorMessage?: string;
  retryCount: number;
  maxRetries: number;
  scheduledAt?: string;
  printedAt?: string;
  cancelledAt?: string;
  cancelReason?: CancelReason;
  createdAt: string;
  updatedAt: string;
}

/**
 * 打印任务查询参数
 */
export interface PrintTaskQueryParams {
  page?: number;
  pageSize?: number;
  orderId?: number;
  taskId?: string;
  printerSn?: string;
  status?: PrintTaskStatus;
  startDate?: string;
  endDate?: string;
  search?: string;
}

/**
 * 打印任务列表响应
 */
export interface PrintTaskListResponse {
  data: FeiePrintTask[];
  total: number;
  page: number;
  pageSize: number;
}

/**
 * 打印配置键枚举
 */
export enum ConfigKey {
  ANTI_REFUND_DELAY = 'feie.anti_refund_delay',
  AUTO_PRINT_ON_PAYMENT = 'feie.auto_print_on_payment',
  AUTO_PRINT_ON_SHIPPING = 'feie.auto_print_on_shipping',
  MAX_RETRY_COUNT = 'feie.max_retry_count',
  RETRY_INTERVAL = 'feie.retry_interval',
  TASK_TIMEOUT = 'feie.task_timeout',
  RECEIPT_TEMPLATE = 'feie.receipt_template',
  SHIPPING_TEMPLATE = 'feie.shipping_template'
}

/**
 * 配置类型枚举
 */
export enum ConfigType {
  STRING = 'STRING',
  JSON = 'JSON',
  BOOLEAN = 'BOOLEAN',
  NUMBER = 'NUMBER'
}

/**
 * 打印配置实体
 */
export interface FeieConfig {
  id: number;
  tenantId: number;
  configKey: ConfigKey;
  configValue: string;
  configType: ConfigType;
  description?: string;
  createdAt: string;
  updatedAt: string;
}

/**
 * 打印配置列表响应
 */
export interface ConfigListResponse {
  data: FeieConfig[];
}

/**
 * 更新配置请求
 */
export interface UpdateConfigRequest {
  configValue: string;
}

/**
 * 提交打印任务请求
 */
export interface SubmitPrintTaskRequest {
  printerSn: string;
  content: string;
  printType: string;
  orderId?: number;
  delaySeconds?: number;
}

/**
 * 提交打印任务响应
 */
export interface SubmitPrintTaskResponse {
  taskId: string;
  status: PrintTaskStatus;
  scheduledAt?: string;
}

/**
 * 重试打印任务请求
 */
export interface RetryPrintTaskRequest {
  taskId: string;
}

/**
 * 取消打印任务请求
 */
export interface CancelPrintTaskRequest {
  taskId: string;
  reason: CancelReason;
}

/**
 * API响应包装器
 */
export interface ApiResponse<T> {
  success: boolean;
  data?: T;
  message?: string;
  error?: string;
}