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

//  销售退货 审核
export const salesReturnAudit = (params) => {
  return axios({
    url: `/salesReturn/audit`,
    data: params,
    method: 'post'
  })
}
//  销售退货 品检
export const salesReturnCheck = (params) => {
  return axios({
    url: `/salesReturn/check`,
    data: params,
    method: 'post'
  })
}

//  销售退货 删除
export const salesReturnDel = (params) => {
  return axios({
    url: `/salesReturn/delete/${params.salesReturnBillSn}`,
    method: 'get'
  })
}

// 再次编辑
export const updateAgain = (params) => {
  return axios({
    url: `/salesReturn/updateAgain/${params.salesReturnBillSn}`,
    method: 'get'
  })
}

// 根据SN查询销售退货单
export const salesReturnDetail = (params) => {
  return axios({
    url: `/salesReturn/findBySn/${params.sn}`,
    method: 'get'
  })
}

// 新建销售退货单
export const salesReturnInsert = (params) => {
  return axios({
    url: '/salesReturn/insert',
    data: params,
    method: 'post'
  })
}

// 销售退货单付款
export const salesReturnPay = (params) => {
  return axios({
    url: '/salesReturn/pay',
    data: params,
    method: 'post'
  })
}

//  销售退货 打印预览
export const salesReturnPrint = (params) => {
  return axios.request({
    url: `/salesReturn/print/${params.priceType}`,
    data: params,
    method: 'post',
    responseType: 'blob'
  })
}

//  销售退货 导出
export const salesReturnExport = (params) => {
  return axios.request({
    url: `/salesReturn/export/${params.salesReturnBillSn}/${params.priceType}`,
    method: 'get',
    responseType: 'blob'
  })
}

//  销售退货 分页查询产品
export const salesReturnList = (params) => {
  const url = `/salesReturn/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
// 销售退货 统计
export const salesReturnQueryCount = (params) => {
  const url = `/salesReturn/queryCount`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

// 销售退货 操作记录
export const salesReturnChangeLogList = (params) => {
  const url = `/salesReturn/changeLog/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

//  销售退货 提交
export const salesReturnSubmit = (params) => {
  return axios({
    url: `/salesReturn/submit`,
    data: params,
    method: 'post'
  })
}

// 抓单列表
export const salesQueryByReturn = (params) => {
  const url = `/sales/detail/queryByReturn/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

// 退货确认  列表  分页
export const salesReturnFinancialList = (params) => {
  const url = `/salesReturn/queryPageByFinancial/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
// 退货确认  详情  列表  分页
export const salesReturnFinancialDetailList = (params) => {
  const url = `/salesReturn/detail/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

//销售退货 客服确认
export const customerServiceConfirm = (params) => {
  return axios({
    url: `/salesReturn/customerServiceConfirm/${params.salesReturnBillSn}`,
    method: 'get'
  })
}
// 收货提交审核
export const salesReturnReceive = (params) => {
  return axios({
    url: `/salesReturn/receive/${params.salesReturnBillSn}`,
    method: 'get'
  })
}

// 退货确认 退货确认
export const salesReturnFinancial = (params) => {
  return axios({
    url: '/salesReturn/financial',
    data: params,
    method: 'post'
  })
}
// 退货确认 下载模板
export const salesReturnDownload = params => {
  return axios.request({
    url: `/salesReturn/detail/downloadExcel`,
    method: 'post',
    responseType: 'blob'
  })
}
// 退货确认  解析导入的文件
export const salesReturnParseProducts = params => {
  return axios({
    url: '/salesReturn/detail/parseProducts',
    data: params,
    method: 'post'
  })
}
// 退货确认  批量插入
export const salesReturnBatchInsert = params => {
  return axios({
    url: '/salesReturn/detail/batchInsert',
    data: params,
    method: 'post'
  })
}
//  销售退货 导入产品 导出错误项
export const salesReturnFailExcel = (params) => {
  const url = `/salesReturn/detail/downloadFailExcel/${params.grabFlag}`
  delete params.grabFlag
  return axios.request({
    url: url,
    method: 'post',
    data: params.list,
    responseType: 'blob'
  })
}
