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

// 销售 统计查询
export const salesCount = (params) => {
    return axios({
      url: `/salesn/queryCount`,
      data: params,
      method: 'post'
    })
  }
//  销售 列表  有分页
export const salesList = (params) => {
    const url = `/salesn/queryPage/${params.pageNo}/${params.pageSize}`
    delete params.pageNo
    delete params.pageSize
    return axios({
        url: url,
        data: params,
        method: 'post'
    })
}
//  销售 新增
export const salesSave = (params) => {
    return axios({
      url: '/salesn/insert',
      data: params,
      method: 'post'
    })
}
// 销售 编辑
export const salesModify = (params) => {
    return axios({
      url: '/salesn/modifyWarehouse',
      data: params,
      method: 'post'
    })
  }
//  销售 详情bysn
export const salesDetailBySn = (params) => {
    return axios({
      url: `/salesn/findBySn/${params.salesBillSn}`,
      method: 'get'
    })
  }
// 查询客户名称
export const salesDetailByNo = (params) => {
    return axios({
      url: `/salesn/findBySaleBillNo/${params.salesBillNo}`,
      method: 'get'
    })
  }
//  销售 删除
export const salesDel = (params) => {
    return axios({
      url: `/salesn/delete/${params.salesBillSn}`,
      method: 'get'
    })
  }
//  销售 取消
export const salesCancle = (params) => {
    return axios({
      url: `/salesn/cancle/${params.salesBillSn}`,
      method: 'get'
    })
  }

// 根据销售单sn查询参加的活动
export const salesPromoQueryList = (params) => {
    return axios({
        url: `/salesPromo/queryExtList`,
        data: params,
        method: 'post'
    })
}
// 更换促销，可更换活动列表
export const salesPromoMatchProduct = (params) => {
  return axios({
      url: `/salesPromo/queryMatchProduct`,
      data: params,
      method: 'post'
  })
}
// 判断是否有新的活动
export const salesQueryUnPartPromo = (params) => {
  return axios({
      url: `/salesPromo/queryUnPartPromo/${params.salesBillSn}`,
      data: params,
      method: 'post'
  })
}
// 活动优惠明细接口
export const salesPromoQueryCount = (params) => {
  return axios({
      url: `/salesPromo/queryCount`,
      data: params,
      method: 'post'
  })
}

// 更换促销活动
export const queryMatchPromoProduct = (params) => {
  return axios({
      url: `/promotion/queryMatchProduct`,
      data: params,
      method: 'post'
  })
}

// 提交时活动规则校验
export const salesPromoValidaSubmit = (params) => {
  return axios({
      url: `/salesPromo/validationSubmit/${params.salesBillSn}`,
      data: params,
      method: 'post'
  })
}

//  销售 审核通过
export const salesWriteAuditPass = (params) => {
  return axios({
    url: '/salesn/auditPass',
    data: params,
    method: 'post'
  })
}
//  销售 审核驳回
export const salesWriteAuditReject = (params) => {
  return axios({
    url: '/salesn/auditReject',
    data: params,
    method: 'post'
  })
}
//  销售 一键审核下推
export const salesWriteAuditPush = (params) => {
  return axios({
    url: '/salesn/auditPush',
    data: params,
    method: 'post'
  })
}
//  销售 提交
export const salesWriteSubmit = (params) => {
  return axios({
    url: '/salesn/submit',
    data: params,
    method: 'post'
  })
}

// 是否更新价格判断
export const submitCheck = (params) => {
  return axios({
    url: '/salesn/submitCheck',
    method: 'post',
    data: params
  })
}
// 当前价格  提交
export const updateBatch = (params) => {
  return axios({
    url: '/salesn/detail/updateBatch',
    method: 'post',
    data: params
  })
}

// 查询可生成的费用报销单
export const queryCreateBySalesBillSn = (params) => {
  return axios({
    url: `/expenseAccount/queryCreateBySalesBillSn/${params.salesBillSn}`,
    data: params,
    method: 'post'
  })
}
// 保存费用报销单
export const expenseAccountSave = (params) => {
  return axios({
    url: `/expenseAccount/saveCreate`,
    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 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 queryPageForWarehouse = (params) => {
  const url = `/salesn/queryPageForWarehouse/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
// 获取按仓库查询销售单数量
export const queryCountForWarehouse = (params) => {
  return axios({
    url: '/salesn/queryCountForWarehouse',
    method: 'post',
    data: params
  })
}
// 按仓库查询销售明细 列表
export const queryPageForWarehouseDetail = (params) => {
  const url = `/salesn/detail/queryPageForWarehouse/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}

// 获取按仓库查询销售单明细数量
export const queryCountForWarehouseDetail = (params) => {
  return axios({
    url: '/salesn/detail/queryCountForWarehouse',
    method: 'post',
    data: params
  })
}
// 按仓库导出销售单
export const exportForWarehouse = params => {
  const url = `/salesn/exportForWarehouse`
  return axios.request({
    url: url,
    data: params,
    method: 'post',
    responseType: 'blob'
  })
}