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

// 经销商促销列表  分页
export const dealerPromotionList = (params) => {
  const url = `/promotion/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
// 新增促销活动
export const dealerPromotionSave = params => {
  return axios({
    url: '/promotion/create',
    data: params,
    method: 'post'
  })
}
// 获取促销活动详情
export const dealerPromotionInfo = params => {
  return axios({
    url: `/promotion/findBySn/${params.sn}`,
    data: {},
    method: 'get'
  })
}
// 修改促销活动
export const dealerPromotionEdit = params => {
  return axios({
    url: '/promotion/modify',
    data: params,
    method: 'post'
  })
}

// 删除促销活动
export const dealerPromotionDel = params => {
  return axios({
    url: `/promotion/delete/${params.sn}`,
    data: {},
    method: 'get'
  })
}
// 规则设置页面  详情
export const getRuleDetail = (params) => {
  return axios({
    url: `/promotion/rule/findBySn/${params.sn}`,
    data: {},
    method: 'get'
  })
}
// 规则设置 列表
export const getRuleQueryList = (params) => {
  return axios({
    url: '/promotion/rule/queryList',
    data: params,
    method: 'post'
  })
}

// 新增一行
export const getNewScopeSn = (params) => {
  return axios({
    url: '/promotion/rule/getNewScopeSn',
    data: params,
    method: 'get'
  })
}
// 规则保存/修改
export const promotionSave = (params) => {
  return axios({
    url: '/promotion/rule/save',
    data: params,
    method: 'post'
  })
}
// 删除规则列表
export const promotionRulesDel = (params) => {
  return axios({
    url: '/promotion/rule/delete',
    data: params,
    method: 'post'
  })
}
// 提交
export const promotionSubmit = (params) => {
  return axios({
    url: `/promotion/submit/${params.sn}`,
    data: {},
    method: 'get'
  })
}

// 改变发布状态
export const modifyEnabledFlag = (params) => {
  return axios({
    url: '/promotion/modifyEnabledFlag',
    data: params,
    method: 'post'
  })
}
// 审核
export const promotionAudit = (params) => {
  return axios({
    url: '/promotion/audit',
    data: params,
    method: 'post'
  })
}
// 变更促销时间
export const promotionDateModify = (params) => {
  return axios({
    url: '/promotion/promotionDateModify',
    data: params,
    method: 'post'
  })
}
// 中止
export const promotionIsOver = (params) => {
  return axios({
    url: `/promotion/isOver/${params.sn}`,
    data: {},
    method: 'get'
  })
}

// 导出门槛产品错误项
export const downNormalFail = (params) => {
  const url = `/promotion/downNormalFail`
  return axios.request({
    url: url,
    method: 'post',
    data: params,
    responseType: 'blob'
  })
}
// 导出促销产品错误项
export const downSpecialFail = (params) => {
  const url = `/promotion/downSpecialFail`
  return axios.request({
    url: url,
    method: 'post',
    data: params,
    responseType: 'blob'
  })
}
