goodsCouponApi.js 3.31 KB
import { other_http } from '@/main'
const url = 'rop-scrm-coupon/router'
const defaultPath = 'scrm.api.coupon.'

/**商品分页查询*/
const getCouponsList = params => {
  params.method = `${defaultPath}equity.list.merchant`
  return other_http({
    url,
    data: params
  })
}

const createCoupons = params => {
  params.method = `${defaultPath}equity.batch.create`
  return other_http({
    url,
    data: params
  })
}

const getExportApi = params => {
  params.method = `${defaultPath}equity.list.merchant.export`
  return other_http({
    url,
    data: params,
    sign: true
  })
}

//领取记录列表
const getListReceiveRecordApi = params => {
  params.method = `${defaultPath}listReceiveRecordByCouponId`
  return other_http({
    url,
    method: 'GET',
    data: params,
    sign: true
  })
}

//查看优惠券
const getCouponDetailApi = params => {
  params.method = `${defaultPath}detail`
  return other_http({
    url,
    method: 'GET',
    data: params,
    sign: true
  })
}

//删除
const deleteCouponApi = params => {
  params.method = `${defaultPath}delete`
  return other_http({
    url,
    method: 'POST',
    data: params,
    sign: true,
    returnAll: true
  })
}

// 优惠券-作废
const couponUserCancelApi = params => {
  params.method = `${defaultPath}user.cancel`
  return other_http({
    url,
    method: 'POST',
    data: params,
    sign: true,
    returnAll: true
  })
}

const detailExportApi = params => {
  params.method = `${defaultPath}equity.exportReceiveRecord`
  return other_http({
    url,
    data: params,
    sign: true
  })
}

//生效/失效
const effectiveCouponApi = params => {
  params.method = `${defaultPath}effective`
  return other_http({
    url,
    method: 'POST',
    data: params,
    sign: true,
    returnAll: true
  })
}

// 获取模板配置
const getTemplateList = params => {
  params.method = `${defaultPath}template.page`
  return other_http({
    url,
    method: 'POST',
    data: params,
    sign: true
  })
}

// 获取模板配置
const saveTemplate = params => {
  params.method = `${defaultPath}template.save`
  return other_http({
    url,
    method: 'POST',
    data: params,
    sign: true
  })
}

// 保存模板下的优惠券
const saveCouponInfo = params => {
  params.method = `${defaultPath}template.details.save`
  return other_http({
    url,
    method: 'POST',
    data: params,
    sign: true
  })
}

// 获取模板下的优惠券列表
const getCouponById = params => {
  if(!params.templateId) {
    return new Promise((resolve, reject)=>{
      reject()
    })
  };
  params.method = `${defaultPath}template.details.page`
  return other_http({
    url,
    method: 'POST',
    data: params,
    sign: true
  })
}

const delCouponById = params => {
  params.method = `${defaultPath}template.details.delete`
  return other_http({
    url,
    method: 'POST',
    data: params,
    sign: true
  })
}

const delTemplateById = params => {
  params.method = `${defaultPath}template.delete`
  return other_http({
    url,
    method: 'POST',
    data: params,
    sign: true
  })
}

export default {
  getCouponsList,
  createCoupons,
  getExportApi,
  getListReceiveRecordApi,
  getCouponDetailApi,
  deleteCouponApi,
  couponUserCancelApi,
  detailExportApi,
  effectiveCouponApi,
  getTemplateList,
  saveTemplate,
  saveCouponInfo,
  getCouponById,
  delCouponById,
  delTemplateById
}