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',
    headers: {
      'module': encodeURIComponent('列表查询')
    }
  })
}
// 新增促销活动
export const dealerPromotionSave = params => {
  return axios({
    url: '/promotion/create',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('新增')
    }
  })
}
// 获取促销活动详情
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',
    headers: {
      'module': encodeURIComponent('编辑')
    }
  })
}

// 删除促销活动
export const dealerPromotionDel = params => {
  return axios({
    url: `/promotion/delete/${params.sn}`,
    data: {},
    method: 'get',
    headers: {
      'module': encodeURIComponent('删除')
    }
  })
}
// 规则设置页面  详情
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',
    headers: {
      'module': encodeURIComponent('明细列表查询')
    }
  })
}

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

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

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

// 参与客户   导出错误项 (经销商)
export const downDealerFail = (params) => {
  const url = `/promotion/dealer/downDealerFail`
  return axios.request({
    url: url,
    method: 'post',
    data: params,
    responseType: 'blob',
    headers: {
      'module': encodeURIComponent('导出参与客户 (经销商)错误项')
    }
  })
}

// 导出活动经销商列表
export const dealerExportAudit = (params) => {
  return axios({
    url: '/promotion/dealer/exportAudit',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出')
    }
  })
}

// 创建人   列表查询
export const queryCreatorList = (params) => {
  return axios({
    url: '/promotion/queryCreatorList',
    data: params,
    method: 'post'
  })
}

// 复制  经销商促销列表
export const handleCopyData = (params) => {
  return axios({
    url: '/promotion/copyData',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('复制')
    }
  })
}

// 经销商促销  已选参与客户  列表查询  分页
export const queryAuditPageList = (params) => {
  const url = `/promotion/dealer/queryAuditPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('已选参与客户列表查询')
    }
  })
}
// 经销商列表查询  分页  已选择的排在最上边
export const queryDealerPage = (params) => {
  const url = `/promotion/dealer/queryDealerPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('经销商列表查询')
    }
  })
}
// 参与客户 提交审核
export const midwaySubmit = (params) => {
  return axios({
    url: '/promotion/dealer/midwaySubmit',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('提交审核')
    }
  })
}
// 参与客户   更新列表
export const dealerMidwayUpdate = (params) => {
  return axios({
    url: '/promotion/dealer/midwayUpdate',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('添加经销商并更新列表显示状态')
    }
  })
}
// 参与客户 审核通过  审核不通过
export const dealerMidwayAudit = (params) => {
  return axios({
    url: '/promotion/dealer/midwayAudit',
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent(params.dealerAuditStatus == 'AUDIT_PASS' ? '审核通过' : '审核不通过')
    }
  })
}
// 获取所有经销商sn   全部客户回显
export const allDealerSnList = (params) => {
  return axios({
    url: '/promotion/dealer/allDealerSnList',
    data: params,
    method: 'post'
  })
}

// 获取所选经销商sn
export const updateDealerSnList = (params) => {
  return axios({
    url: '/promotion/dealer/updateDealerSnList',
    data: params,
    method: 'post'
  })
}
// 导出规则产品明细列表
export const excelProductExcel = (params) => {
  return axios({
    url: '/promotion/rule/excelProductExcel',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers: {
      'module': encodeURIComponent('导出')
    }
  })
}
