import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { XfDiscountVO, XfDiscountForm, XfDiscountQuery } from '@/api/consumption/xfDiscount/types';

/**
 * 查询折扣管理列表
 * @param query
 * @returns {*}
 */
export const listXfDiscount = (query?: XfDiscountQuery): AxiosPromise<XfDiscountVO[]> => {
  return request({
    url: '/backstage/consumption/xfDiscount/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询折扣管理详细
 * @param discountId
 */
export const getXfDiscount = (discountId: string | number): AxiosPromise<XfDiscountVO> => {
  return request({
    url: '/backstage/consumption/xfDiscount/' + discountId,
    method: 'get'
  });
};

/**
 * 新增折扣管理
 * @param data
 */
export const addXfDiscount = (data: XfDiscountForm) => {
  return request({
    url: '/backstage/consumption/xfDiscount',
    method: 'post',
    data: data
  });
};

/**
 * 修改折扣管理
 * @param data
 */
export const updateXfDiscount = (data: XfDiscountForm) => {
  return request({
    url: '/backstage/consumption/xfDiscount',
    method: 'put',
    data: data
  });
};

/**
 * 删除折扣管理
 * @param discountId
 */
export const delXfDiscount = (discountId: string | number | Array<string | number>) => {
  return request({
    url: '/backstage/consumption/xfDiscount/' + discountId,
    method: 'delete'
  });
};
