import request from '@/axios'
import { REQUEST_BASE } from '@/constants'
/**
* 获取优惠券模板列表
* @param 
* @returns 
*/
export const getCouponList = (params: any): Promise<IResponse> => {
  return request.get({ url: `${REQUEST_BASE}/coupon`, params })
}

export const addCoupon = (data: any): Promise<IResponse> => {
  return request.post({ url: `${REQUEST_BASE}/coupon`, data })
}

export const editCoupon = (data: any): Promise<IResponse> => {
  return request.put({ url: `${REQUEST_BASE}/coupon/${data.id}`, data })
}

// change_field
export const changeCouponField = (data: any): Promise<IResponse> => {
  return request.post({ url: `${REQUEST_BASE}/coupon_issue/setstatus/${data.id}`, data })
}

export const delCoupon = (id: number): Promise<IResponse> => {
  return request.delete({ url: `${REQUEST_BASE}/coupon/${id}` })
}

export const getCouponDetail = (id: number): Promise<IResponse> => {
  return request.get({ url: `${REQUEST_BASE}/coupon/${id}` })
}

export const releaseCoupon = (data: any): Promise<IResponse> => {
  return request.post({ url: `${REQUEST_BASE}/coupon_issue`,data })

}

export const couponList = (params: any): Promise<IResponse> => {
  return request.get({ url: `${REQUEST_BASE}/coupon_issue`,params })
}

export const couponDel = (id: number): Promise<IResponse> => {
  return request.delete({ url: `${REQUEST_BASE}/coupon_issue/${id}` })
}

export const giveUserCoupon = (data: any): Promise<IResponse> => {
  return request.post({ url: `${REQUEST_BASE}/coupon/ff`,data })
}

export const couponGetList = (params: any): Promise<IResponse> => {
  return request.get({ url: `${REQUEST_BASE}/coupon_user`,params })
}

export const getREchange = (params: any): Promise<IResponse> => {
  return request.get({ url: `${REQUEST_BASE}/system_recharge`,params })
}

export const addRechange = (data:object): Promise<IResponse> => {
  return request.post({ url: `${REQUEST_BASE}/system_recharge`, data })
}

export const delRechange = (id:number): Promise<IResponse> => {
  return request.delete({ url: `${REQUEST_BASE}/system_recharge/${id}` })
}

export const editRechange = (data:{[key:string]:any}): Promise<IResponse> => {
  return request.put({ url: `${REQUEST_BASE}/system_recharge/${data.id}`, data })
}