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

// 促销活动  有分页
export const shopPromoActiveList = (params) => {
  const url = `/shopPromo/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('列表查询')
    }
  })
}

// 促销活动 详情
export const shopPromoDetail = params => {
  return axios({
    url: `/shopPromo/findBySn/${params.sn}`,
    data: {},
    method: 'get',
    headers: {
      'module': encodeURIComponent('详情')
    }
  })
}

// 促销活动  删除
export const shopPromoDel = (params) => {
  return axios({
    url: '/shopPromo/delete',
    data: params,
    method: 'post'
  })
}

// 促销活动  发布
export const shopPromoRelease = (params) => {
  return axios({
    url: '/shopPromo/release',
    data: params,
    method: 'post'
  })
}

// 促销活动  废弃
export const shopPromoDiscard = (params) => {
  return axios({
    url: '/shopPromo/discard',
    data: params,
    method: 'post'
  })
}

// 促销活动 修改商城轮播图
export const updateShopBanner = (params) => {
  return axios({
    url: '/shopPromo/updateShopBanner',
    data: params,
    method: 'post'
  })
}

//  促销活动  保存
export const saveShopPromo = (params) => {
  return axios({
    url: '/shopPromo/save',
    data: params,
    method: 'post'
  })
}

// 选择产品 获取已选产品列表  有分页
export const chooseProductList = (params) => {
  const url = `/shopPromoProduct/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('列表查询')
    }
  })
}

// 选择产品 获取选择产品列表 有分页
export const shopPromoProductList = (params) => {
  const url = `/shopPromoProduct/queryWaitSelectPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers: {
      'module': encodeURIComponent('列表查询')
    }
  })
}

// 选择产品 批量添加产品
export const saveChooseProduct = (params) => {
  return axios({
    url: '/shopPromoProduct/createBatch',
    data: params,
    method: 'post'
  })
}

// 选择产品  批量修改产品
export const modifyChooseProduct = (params) => {
  return axios({
    url: '/shopPromoProduct/modifyBatch',
    data: params,
    method: 'post'
  })
}

//  选择产品  删除
export const delChooseProduct = (params) => {
  return axios({
    url: '/shopPromoProduct/modifyDelete',
    data: params,
    method: 'post'
  })
}

// 产品选择 清空已选产品
export const clearProductByPromoSn = (params) => {
  return axios({
    url: '/shopPromoProduct/clearByPromoSn',
    data: params,
    method: 'post'
  })
}
