/**
 * Web-zdx
 * moduleName: 优惠券相关
 */

import { request } from '../index'

// 我的优惠券
const myCoupon = (data) => {
  return request({
    url: 'coupons/user/coupons',
    method: 'get',
    data: data
  })
}

// 优惠券分组列表
const getCouponsListById = (id,data) => {
  return request({
    url: 'coupons/user/coupons/'+id+'/list',
	data:data
  })
}

// 根据优惠券id获取优惠券的详情信息
const getCouponsInfoById = (id) => {
  return request({
    url: 'coupons/user/coupons/'+id,
  })
}


// 根据企业id获取企业首页的轮播图列表
const couponsByCompanyId = (data) => {
  return request({
    url: 'coupons/all',
    method: 'get',
    data: data
  })
}

// 领取优惠券
const couponsGrant = (id) => {
  return request({
    url: 'coupons/'+id+'/grant',
    method: 'POST'
  })
}
// 获取优惠券可使用商品
const getGoodsByGrantId = (data) => {
  return request({
    url: 'user/coupons/goods',
    data: data
  })
}

// 使用提货券兑换商品
const exchangeGoods = (data) => {
  return request({
    url: 'user/coupons/exchange',
    method: 'POST',
    data: data
  })
}

// 获取核销二维码
const getQrcodeByGrantId = (data) => {
  return request({
    url: 'coupons/user/coupons/qrcode',
    data: data
  })
}

export {
  myCoupon,
  couponsByCompanyId,
  couponsGrant,
  getGoodsByGrantId,
  exchangeGoods,
  getCouponsListById,
  getCouponsInfoById,
  getQrcodeByGrantId
}
