import { axios } from '@/utils/request'

//  销售详情 删除
export const salesDetailDel = (params) => {
  return axios({
    url: `/sales/detail/delete`,
    data: params,
    method: 'post'
  })
}

// 批量删除
export const salesDetailBatchDel = (params) => {
  return axios({
    url: `/sales/detail/delete/batch`,
    data: params,
    method: 'post'
  })
}

// 一键发货
export const salesDetailDispatchByOneKey = (params) => {
  return axios({
    url: `/sales/detail/dispatchByOneKey/${params.salesBillSn}`,
    data: params,
    method: 'post'
  })
}

// 新增销售明细
export const salesDetailInsert = (params) => {
  return axios({
    url: '/sales/detail/insert',
    data: params,
    method: 'post'
  })
}

// 批量新增代发货信息
export const insertBatchOfWaitDispatch = (params) => {
  return axios({
    url: '/sales/detail/insertBatchOfWaitDispatch',
    data: params,
    method: 'post'
  })
}

// 销售详情列表分页
export const salesDetailList = (params) => {
  const url = `/sales/detail/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

// 销售详情列表不分页  不带库存
export const salesDetailAllList = (params) => {
  const url = `/sales/detail/query`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

// 销售详情列表不分页  带库存
export const salesDetailAllStockList = (params) => {
  const url = `/sales/detail/queryStock`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

// 缺货明细
export const salesStockoutDetail = (params) => {
  const url = `/sales/detail/queryPageStock`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

// 销售列表  分页  带库存
export const salesDetailStockList = (params) => {
  const url = `/sales/detail/queryPageStock/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
// 修改销售明细取消数量
export const salesDetailUpdateCancelQty = (params) => {
  return axios({
    url: '/sales/detail/updateBatchCancelQty',
    data: params,
    method: 'post'
  })
}

//  修改销售明细数量
export const salesDetailUpdateQty = (params) => {
  return axios({
    url: '/sales/detail/updateQty',
    data: params,
    method: 'post'
  })
}

//  销售详情 整单删除
export const salesDetailDelAll = (params) => {
  return axios({
    url: `/sales/detail/deleteAll`,
    data: params,
    method: 'post'
  })
}

// 获取产品适用活动的促销产品列表
export const getPromoGoodsList = (params) => {
  const url = `/sales/detail/getPromoGoodsList/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

// 批量添加促销品
export const addPromoGoods = (params) => {
  return axios({
    url: `/sales/detail/addPromoGoods`,
    data: params,
    method: 'post'
  })
}
// 促销产品统计  列表  分页
export const salesDetailPromoList = (params) => {
  const url = `/sales/detail/queryPageByPromo/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
// 促销产品统计  合计
export const salesDetailPromoCount = (params) => {
  return axios({
    url: `/sales/detail/queryCountByPromo`,
    data: params,
    method: 'post'
  })
}
// 促销产品统计  详情  列表  分页
export const salesDetailPromoProductList = (params) => {
  const url = `/sales/detail/queryPageOfPromoProduct/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
// 销售 下载模板
export const salesDownload = params => {
  return axios.request({
    url: `/sales/detail/downloadExcel`,
    method: 'post',
    responseType: 'blob'
  })
}
// 销售  解析导入的文件
export const salesParseProducts = params => {
  return axios({
    url: '/sales/detail/parseProducts',
    data: params,
    method: 'post'
  })
}
// 销售  批量插入
export const salesBatchInsert = params => {
  return axios({
    url: '/sales/detail/batchInsert',
    data: params,
    method: 'post'
  })
}
//  销售 导入产品 导出错误项
export const salesFailExcel = (params) => {
  const url = `/sales/detail/downloadFailExcel`
  return axios.request({
    url: url,
    method: 'post',
    data: params.list,
    responseType: 'blob'
  })
}

// 导出缺货明细
export const exportStockout = params => {
  const url = `/sales/detail/exportStockout`
  delete params.priceType
  return axios.request({
    url: url,
    data: params,
    method: 'post',
    responseType: 'blob'
  })
}
// 导出分组缺货明细
export const exportGroupStockout = params => {
  const url = `/sales/detail/exportGroupStockout`
  delete params.priceType
  return axios.request({
    url: url,
    data: params,
    method: 'post',
    responseType: 'blob'
  })
}
