import type sellerImportOrderTaskListQuery from './ImportQuery'
import type sellerImportOrderTaskListType from '~/domain/Shop'
import {type sellerImportOrderListQuery} from './ImportQuery'
import type { ServerList, ServerRes, ServerListData } from '~/service/index'
import httpRequest from "~/service/index";

export function useShopImport() {
  const apiRoot = '/seller/sellerOrder'

  // 批量导入订单（Excel）
  async function createImportTask(formData: FormData) {
    return await httpRequest.post<any>(`${apiRoot}/createImportTask`, formData)
  }

  //查询批量导入任务列表
  async function sellerImportOrderTaskList(query: sellerImportOrderTaskListQuery) {
    return await httpRequest.post<ServerList<sellerImportOrderTaskListType>>(`/seller/sellerImportOrderTask/list`, query)
  }

  //下载批量导入失败文件
  async function downloadFailResult(query: {taskId:string}) {
    return await httpRequest.post<any>(`/seller/sellerImportOrder/downloadFailResult`, query)
  }

  //查询批量导入任务详情
  async function sellerImportOrderList(query: sellerImportOrderListQuery) {
    return await httpRequest.post<any>(`/seller/sellerImportOrder/list`, query)
  }

  //批量导入提交下单支付
  async function submitImportTask(query: {taskId:number}) {
    return await httpRequest.post<any>(`${apiRoot}/submitImportTask`, query)
  }

  return {
    createImportTask,sellerImportOrderTaskList,
    downloadFailResult,sellerImportOrderList,submitImportTask
  }
}
