import { apiGet, apiPost } from '@/lib/http'
import type {
  AdminKuaishouIndustryOpenApiResult,
  AdminKuaishouIndustryRefundApprovePayload,
  AdminKuaishouIndustryRefundDisagreePayload,
  AdminKuaishouIndustryRefundListPayload,
  AdminKuaishouIndustryShopListResult,
  AdminKuaishouIndustryVoucherConsumeResult,
  AdminKuaishouIndustryVoucherDestroyResult,
  AdminKuaishouIndustryVoucherListResult,
  AdminKuaishouIndustryVoucherResendResult,
  AdminKuaishouIndustryVoucherToolPayload,
} from '@/types/admin'

export function fetchAdminKuaishouIndustryVouchers(params?: Record<string, unknown>) {
  return apiGet<AdminKuaishouIndustryVoucherListResult>(
    '/api/v1/admin/kuaishou-industry/vouchers',
    params,
  )
}

export function fetchAdminKuaishouIndustryShops() {
  return apiGet<AdminKuaishouIndustryShopListResult>('/api/v1/admin/kuaishou-industry/shops')
}

export function listAdminKuaishouIndustryRefunds(payload: AdminKuaishouIndustryRefundListPayload) {
  return apiPost<AdminKuaishouIndustryOpenApiResult>(
    '/api/v1/admin/kuaishou-industry/refunds/list',
    payload,
  )
}

export function approveAdminKuaishouIndustryRefund(
  payload: AdminKuaishouIndustryRefundApprovePayload,
) {
  return apiPost<AdminKuaishouIndustryOpenApiResult>(
    '/api/v1/admin/kuaishou-industry/refunds/approve',
    payload,
  )
}

export function disagreeAdminKuaishouIndustryRefund(
  payload: AdminKuaishouIndustryRefundDisagreePayload,
) {
  return apiPost<AdminKuaishouIndustryOpenApiResult>(
    '/api/v1/admin/kuaishou-industry/refunds/disagree',
    payload,
  )
}

export function checkAdminKuaishouIndustryVoucherAvailable(
  payload: AdminKuaishouIndustryVoucherToolPayload,
) {
  return apiPost<AdminKuaishouIndustryOpenApiResult>(
    '/api/v1/admin/kuaishou-industry/vouchers/check-available',
    payload,
  )
}

export function reverseAdminKuaishouIndustryVoucher(
  payload: AdminKuaishouIndustryVoucherToolPayload,
) {
  return apiPost<AdminKuaishouIndustryOpenApiResult>(
    '/api/v1/admin/kuaishou-industry/vouchers/reverse',
    payload,
  )
}

export function consumeAdminKuaishouIndustryVoucher(
  payload: AdminKuaishouIndustryVoucherToolPayload,
) {
  return apiPost<AdminKuaishouIndustryVoucherConsumeResult>(
    '/api/v1/admin/kuaishou-industry/vouchers/consume',
    payload,
  )
}

export function resendAdminKuaishouIndustryVoucherCode(
  payload: AdminKuaishouIndustryVoucherToolPayload,
) {
  return apiPost<AdminKuaishouIndustryVoucherResendResult>(
    '/api/v1/admin/kuaishou-industry/vouchers/resend-code',
    payload,
  )
}

export function destroyAdminKuaishouIndustryVoucher(
  payload: AdminKuaishouIndustryVoucherToolPayload,
) {
  return apiPost<AdminKuaishouIndustryVoucherDestroyResult>(
    '/api/v1/admin/kuaishou-industry/vouchers/destroy',
    payload,
  )
}
