import type { AdminPagination } from './common'

export interface AdminKuaishouIndustryOpenApiResult {
  success: boolean
  response: Record<string, unknown> | null
  error: string
  request: Record<string, unknown> | null
  durationMs: number
  httpStatus: number
  skippedReason: string
  voucher?: AdminKuaishouIndustryVoucher | null
}

export interface AdminKuaishouIndustryVoucher {
  id: number
  voucherCode: string
  oid: string
  orderId: number | null
  taskId: number | null
  /** 关联履约任务号（列表 join 可选） */
  taskNo?: string
  unitIndex: number
  sellerId: string
  /** 来自行业店铺配置的展示名（customShopName 优先） */
  shopName: string
  /** 关联订单商品编码（列表 join） */
  skuCode?: string
  /** 关联订单商品名称（列表 join） */
  skuName?: string
  tokenMasked: string
  /** 快手电子凭证类型，如 GAME_OPEN_TICKET_CONSUME */
  eticketType: string
  status: string
  validStartTime: number
  validEndTime: number
  consumeSerialNum: string
  consumeDetails: Array<Record<string, unknown>>
  consumedAt: string | null
  destroyedAt: string | null
  sendCallbackStatus: string
  sendCallbackAttemptCount: number
  sendCallbackLastError: string
  sendCallbackSentAt: string | null
  rawPayload: Record<string, unknown>
  createdAt: string
  updatedAt: string
}

export interface AdminKuaishouIndustryVoucherListResult {
  items: AdminKuaishouIndustryVoucher[]
  pagination: AdminPagination
}

/** 电子凭证页筛选用的轻量店铺选项（无 token 等敏感字段） */
export interface AdminKuaishouIndustryShopOption {
  sellerId: string
  shopId: string
  shopName: string
  enabled: boolean
}

export interface AdminKuaishouIndustryShopListResult {
  shops: AdminKuaishouIndustryShopOption[]
}

export interface AdminKuaishouIndustryVoucherConsumeResult {
  success: boolean
  voucher: AdminKuaishouIndustryVoucher
  task: null | {
    taskId: number
    taskNo: string
    status: string
    deliveryStatus: string
  }
}

export interface AdminKuaishouIndustryVoucherDestroyResult {
  success: boolean
  alreadyDestroyed: boolean
  reason: string
  voucher: AdminKuaishouIndustryVoucher
  task: null | {
    taskId: number
    taskNo: string
    status: string
    deliveryStatus: string
  }
}

export interface AdminKuaishouIndustryVoucherResendResult {
  success: boolean
  response: Record<string, unknown> | null
  error: string
  voucher: AdminKuaishouIndustryVoucher | null
}

export interface AdminKuaishouIndustryRefundListPayload {
  sellerId?: string
  beginTime?: number | string
  endTime?: number | string
  type?: number | string
  pageSize?: number | string
  currentPage?: number | string
  sort?: number | string
  queryType?: number | string
  negotiateStatus?: number | string
  pcursor?: string
  status?: number | string
  orderId?: string
}

export interface AdminKuaishouIndustryRefundApprovePayload {
  sellerId?: string
  orderId?: string
  refundId?: number | string
  desc?: string
  refundAmount?: number | string
  status?: number | string
  negotiateStatus?: number | string
  refundHandingWay?: number | string
}

export interface AdminKuaishouIndustryRefundDisagreePayload {
  sellerId?: string
  orderId?: string
  refundId?: number | string
  sellerDisagreeReason?: number | string
  sellerDisagreeDesc?: string
  sellerDisagreeImages?: string[]
  status?: number | string
  negotiateStatus?: number | string
}

export interface AdminKuaishouIndustryVoucherToolPayload {
  sellerId?: string
  buyerId?: string
  orderId?: string
  oid?: string
  taskId?: number | string
  voucherCode?: string
  eticketType?: string
  consumeType?: string
  serialNum?: string
  reason?: string
  token?: string
  storeName?: string
  storeAddress?: string
  expressCode?: string
  expressNo?: string
  etickets?: Array<{ id?: string; code?: string; num?: number | string }>
}
