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

//  销售 审核
export const salesWriteAudit = (params) => {
  return axios({
    url: '/sales/audit',
    data: params,
    method: 'post'
  })
}

//  销售 一键审核
export const salesWriteAuditPush = (params) => {
  return axios({
    url: '/sales/auditPush',
    data: params,
    method: 'post'
  })
}

//  销售 删除
export const salesDel = (params) => {
  return axios({
    url: `/sales/delete/${params.salesBillSn}`,
    method: 'get'
  })
}

//  销售 详情bysn
export const salesDetailBySn = (params) => {
  return axios({
    url: `/sales/findBySn/${params.salesBillSn}`,
    method: 'get'
  })
}
// 查询客户名称
export const salesDetailByNo = (params) => {
  return axios({
    url: `/sales/findBySaleBillNo/${params.salesBillNo}`,
    method: 'get'
  })
}
//  销售 新增或编辑
export const salesSave = (params) => {
  return axios({
    url: '/sales/insert',
    data: params,
    method: 'post'
  })
}

//  销售 打印
export const salesPrint = (params) => {
  return axios({
    url: '/sales/print',
    data: params,
    method: 'post'
  })
}

//  销售 打印预览
export const salesPrintPreview = (params) => {
  return axios({
    url: '/sales/printPreview',
    data: params,
    method: 'post'
  })
}

// 销售 统计查询
export const salesCount = (params) => {
  return axios({
    url: `/sales/queryCount`,
    data: params,
    method: 'post'
  })
}

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

//  销售 提交
export const salesWriteSubmit = (params) => {
  return axios({
    url: `/sales/submit/${params.salesBillSn}`,
    data: params,
    method: 'get'
  })
}
//  财务收款 列表 分页
export const salesReceiptList = (params) => {
  const url = `/sales/queryPageByReceipt/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
//  财务收款
export const salesReceipt = (params) => {
  return axios({
    url: `/sales/receipt/${params.sn}`,
    data: params,
    method: 'get'
  })
}

// 获取促销活动
export const getPromoacActiveList = (params) => {
  return axios({
    url: `/sales/getPromoacActiveList/${params.salesBillSn}`,
    data: params,
    method: 'get'
  })
}
//  促销订单统计 列表  有分页
export const salesPromoList = (params) => {
  const url = `/sales/queryPageByPromo/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
//  促销订单统计 合计
export const salesPromoCount = (params) => {
  return axios({
    url: '/sales/queryCountByPromo',
    data: params,
    method: 'post'
  })
}
// 销售  详情  该销售单的产品二级分类
export const salesDetailProductType = (params) => {
  return axios({
    url: `/sales/detail/queryProductType/${params.sn}`,
    method: 'get'
  })
}
// 销售 详情  打印
export const salesDetailPrint = params => {
  const url = `/sales/print/${params.priceType}`
  delete params.priceType
  return axios.request({
    url: url,
    data: params,
    method: 'post',
    responseType: 'blob'
  })
}
// 销售 详情  导出
export const salesDetailExcel = params => {
  const url = `/sales/excel/${params.priceType}`
  delete params.priceType
  return axios.request({
    url: url,
    data: params,
    method: 'post',
    responseType: 'blob'
  })
}
// 销售 详情  分类导出
export const salesDetailTypeExcel = params => {
  const url = `/sales/detail/typeExcel`
  return axios.request({
    url: url,
    data: params,
    method: 'post',
    responseType: 'blob'
  })
}
// 删除全部已选产品
export const deleteAll = (params) => {
  return axios({
    url: `/sales/detail/delete/all `,
    method: 'post',
    data: params
  })
}
// 车架号
export const supperCodeByVin = (params) => {
  return axios({
    url: `/vinIdentify/queryPartCodeByVin/${params.vin}`,
    method: 'get'
  })
}
// 车架号  识别图片内容
export const vinCodeParse = params => {
  return axios.request({
    url: `/vinIdentify/ocr`,
    method: 'post',
    data: params,
    responseType: 'blob'
  })
}
