import axios from './axios'
import type { BasePaginationData, BaseRespData } from '@/types/api'
import type {
  BatchManageData,
  FactoryOrderNewListData,
  LogListData,
  PickCompleteData,
  PickFailData,
  ProductListData,
  RestockData,
  SearchForm,
  StatusTreeNode,
} from '@/types/api/factoryOrderNew'
export function getPodOrderStateGroupListApi() {
  return axios.get<never, BaseRespData<StatusTreeNode[]>>(
    'factory/podOrder/findStateGroupList',
  )
}

export function getFactoryOrderNewListApi(
  data: SearchForm,
  currentPage: number,
  pageSize: number,
  status?: string,
) {
  return axios.post<never, BasePaginationData<FactoryOrderNewListData>>(
    'factory/podOrder/list_page',
    {
      ...data,
      currentPage,
      pageSize,
      status,
    },
  )
}

export function getFactoryOrderNewDetailApi(id: number | string) {
  return axios.get<never, BaseRespData<ProductListData[]>>(
    'factory/podOrder/get',
    {
      params: { id },
    },
  )
}

export function getFactoryOrderNewLogApi(id: number | string) {
  return axios.get<never, BaseRespData<LogListData[]>>(
    'factory/podOrder/getLog',
    {
      params: { id },
    },
  )
}

export function confirmOrderApi(ids: (number | string)[]) {
  return axios.post<never, BaseRespData<void>>(
    'factory/orderNew/confirm',
    { ids },
  )
}

export function cancelOrderApi(ids: (number | string)[]) {
  return axios.post<never, BaseRespData<void>>(
    'factory/orderNew/cancel',
    { ids },
  )
}

export function refreshProductInfoApi(ids: (number | string)[]) {
  return axios.post<never, BaseRespData<void>>(
    'factory/orderNew/refreshProductInfo',
    { ids },
  )
}

export function transferOldFlowApi(ids: (number | string)[]) {
  return axios.post<never, BaseRespData<void>>(
    'factory/orderNew/transferOldFlow',
    { ids },
  )
}

export function confirmOrderWithWarehouseApi(
  ids: (number | string)[],
  warehouseId: number | string,
) {
  return axios.post<never, BaseRespData<void>>(
    'factory/podOrder/ordersAccepted',
    { ids, warehouseId },
  )
}

export function cancelOrderWithReasonApi(
  ids: (number | string)[],
  reason: string,
) {
  return axios.post<never, BaseRespData<void>>('factory/podOrder/cancelOrders', {
    podOrderIds:ids,
    reason,
  })
}

export function suspendOrderApi(
  ids: (number | string)[],
  reason: string,
  needCustomerHandle: string,
) {
  return axios.post<never, BaseRespData<void>>('factory/orderNew/suspend', {
    ids,
    reason,
    needCustomerHandle,
  })
}

export function cancelSuspendApi(ids: (number | string)[]) {
  return axios.post<never, BaseRespData<void>>(
    'factory/orderNew/cancelSuspend',
    { ids },
  )
}

export function archiveOrderApi(ids: (number | string)[]) {
  return axios.post<never, BaseRespData<void>>('factory/orderNew/archive', {
    ids,
  })
}

export function printPickOrderApi(ids: (number | string)[]) {
  return axios.post<never, BaseRespData<void>>(
    'factory/orderNew/printPickOrder',
    { ids },
  )
}

export function applyReplenishApi(ids: (number | string)[]) {
  return axios.post<never, BaseRespData<void>>(
    'factory/orderNew/applyReplenish',
    { ids },
  )
}

export function batchDeleteApi(ids: (number | string)[]) {
  return axios.post<never, BaseRespData<void>>(
    'factory/orderNew/batchDelete',
    { ids },
  )
}

export function restockCheckApi(id: number | string) {
  return axios.post<never, BaseRespData<void>>(
    'factory/orderNew/restockCheck',
    { id },
  )
}

export function pickCompleteApi(ids: (number | string)[]) {
  return axios.post<never, BaseRespData<PickCompleteData[]>>(
    'factory/orderNew/pickComplete',
    { ids },
  )
}

export function pickFailApi(ids: (number | string)[]) {
  return axios.post<never, BaseRespData<PickFailData[]>>(
    'factory/orderNew/pickFail',
    { ids },
  )
}

export function getCardLayoutListApi(
  data: Record<string, unknown>,
  currentPage: number,
  pageSize: number,
) {
  return axios.post<never, BasePaginationData<FactoryOrderNewListData>>(
    'factory/podOrderOperation/list_page',
    { ...data, currentPage, pageSize },
  )
}

export function getSuspendListApi(
  data: SearchForm,
  currentPage: number,
  pageSize: number,
  statusCode?: string,
) {
  return axios.post<never, BasePaginationData<FactoryOrderNewListData>>(
    'factory/podOrderPauseControl/list_page',
    { ...data, currentPage, pageSize, statusCode },
  )
}

export function getSuspendDetailApi(id: number | string) {
  return axios.get<never, BaseRespData<ProductListData[]>>(
    'factory/podOrderPauseControl/get',
    { params: { id } },
  )
}

export function getSuspendLogApi(id: number | string) {
  return axios.get<never, BaseRespData<LogListData[]>>(
    'factory/podOrderPauseControl/getLog',
    { params: { id } },
  )
}

export function getRestockListApi(
  data: Record<string, unknown>,
  currentPage: number,
  pageSize: number,
) {
  return axios.post<never, BasePaginationData<RestockData>>(
    'factory/podOrderBatchDownload/list_page1',
    { ...data, currentPage, pageSize },
  )
}

export function getBatchManageListApi(
  data: Record<string, unknown>,
  currentPage: number,
  pageSize: number,
) {
  return axios.post<never, BasePaginationData<BatchManageData>>(
    'factory/podOrderBatchDownload/list_page',
    { ...data, currentPage, pageSize },
  )
}

export function createOutboundOrderApi(ids: (number | string)[]) {
  return axios.post<never, BaseRespData<void>>(
    'factory/orderNew/createOutboundOrder',
    { ids },
  )
}

