// 自己 后端 request
import request from '@/utils/aRequestCF';
import requestB from '@/utils/bRequestEa';

/**
 * 创建活动
 */
export function createActive(params) {
  return request({
    url: `activity/add`,
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params
  })
}

/**
 * 删除活动
 * @param {*} id 活动id 
 */
export function deleteActive(id) {
  return request({
    url: `activity/delete?id=${id}`,
    method: 'delete'
  })
}

/**
 * 获取活动列表
 */
export function getActiveList(params) {
  return request({
    url: `activity/list`,
    method: 'post',
    data: params
  })
}

/**
 * 判断是否会员
 */
export function isMember(params) {
  return request({
    url: `activity/isMember`,
    method: 'get',
    params
  })
}

/**
 * 获取活动详情
 * @param {*} id 
 */
export function getActiveDetailById(id) {
  return request({
    url: `activity/getById?id=${id}`,
    method: 'get'
  })
}

/**
 * 抽奖
 */
export function play(params) {
  return request({
    url: `activity/play`,
    method: 'post',
    data: params
  })
}

/**
 * 获取优惠券
 * @param {*} id 
 */
export function getAllCouponsByOyStallCode(id) {
  return request({
    url: `admin/auth/coupon/getAllCouponsByOyStallCode?deptId=${id}`,
    method: 'get'
  })
}

/**
 * 现有开展活动
 */
export function getCurrentActive() {
  return request({
    url: `activity/underway`,
    method: 'get'
  })
}

/**
 * 顾客领取优惠券
 */
export function collectMyCoupon(params) {
  return request({
    url: `admin/auth/coupon/collectMyCoupon`,
    method: `get`,
    params
  })
}

/**
 * 保存模板
 */
export function saveTemplate(params) {
  return request({
    url: 'template/save',
    method: 'post',
    data: params
  })
}

/**
 * 获取模板
 * @param {*} params 
 */
export function getTemplate(params) {
  return request({
    url: `template/list`,
    method: 'post',
    params
  })
}

/**
 * 获取模板详情
 */
export function getTemplateData(id) {
  return request({
    url: `template/getTemplate?templateId=${id}`,
    method: 'post'
  })
}

/**
 * 删除模板
 * @param {} id 模板id 
 */
export function deleteTemplate(id) {
  return request({
    url: `template/delete?id=${id}`,
    method: 'delete'
  })
}