import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RefundRecordVO, RefundRecordForm, RefundRecordQuery } from '@/api/finance/refundRecord/types';

/**
 * 查询退费记录列表
 * @param query
 * @returns {*}
 */

export const listRefundRecord = (query?: RefundRecordQuery): AxiosPromise<{records:RefundRecordVO[]}> => {
  return request({
    url: '/finance/refund/list_page',
    method: 'post',
    data: query
  });
};

/**
 * 查询退费记录详细
 * @param id
 */
export const getRefundRecord = (id: string | number): AxiosPromise<RefundRecordVO> => {
  return request({
    url: '/finance/refund/get_detial',
    method: 'post',
      data: {id:id}
  });
};

/**
 * 新增退费记录
 * @param data
 */
export const addRefundRecord = (data: RefundRecordForm) => {
  return request({
    url: '/finance/refund/save',
    method: 'post',
    data: data
  });
};

/**
 * 修改退费记录
 * @param data
 */
export const updateRefundRecord = (data: RefundRecordForm) => {
  return request({
    url: '/finance/refund/save',
    method: 'post',
    data: data
  });
};

/**
 * 删除退费记录
 * @param id
 */
export const delRefundRecord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/finance/refund/delete',
    method: 'post',
      data: {id:id}
  });
};

/**
 * 删除退费记录
 * @param id
 */
export const approveRefundRecord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/finance/refund/approve',
    method: 'post',
      data: {id:id}
  });
};
