import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OrderReceiveRecordVO, OrderReceiveRecordForm, OrderReceiveRecordQuery } from '@/api/finance/orderReceiveRecord/types';

/**
 * 查询回款记录列表
 * @param query
 * @returns {*}
 */

export const listOrderReceiveRecord = (query?: OrderReceiveRecordQuery): AxiosPromise<{records:OrderReceiveRecordVO[]}> => {
  return request({
    url: '/finance/receive/list_page',
    method: 'post',
    data: query
  });
};

/**
 * 查询回款记录详细
 * @param id
 */
export const getOrderReceiveRecord = (id: string | number): AxiosPromise<OrderReceiveRecordVO> => {
  return request({
    url: '/finance/orderReceiveRecord/' + id,
    method: 'get'
  });
};

/**
 * 新增回款记录
 * @param data
 */
export const addOrderReceiveRecord = (data: OrderReceiveRecordForm) => {
  return request({
    url: '/finance/orderReceiveRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改回款记录
 * @param data
 */
export const updateOrderReceiveRecord = (data: OrderReceiveRecordForm) => {
  return request({
    url: '/finance/orderReceiveRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除回款记录
 * @param id
 */
export const delOrderReceiveRecord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/finance/orderReceiveRecord/' + id,
    method: 'delete'
  });
};
