import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AuditMatchQuery, MatchQuery, MatchVO } from '@/api/bls/match/matchtypes';
import { ReceivablesQuery, ReceivablesVO } from '@/api/bls/receivables/types';

/**
 * 收费查询
 * @param query
 * @returns {*}
 */

export const listReceivables = (query?: ReceivablesQuery): AxiosPromise<ReceivablesVO[]> => {
  return request({
    url: '/bls/receivables/receivableslist',
    method: 'get',
    params: query
  });
};

/**
 * 单笔收费
 */
export const singleReceive = (data) => {
  return request({
    url: '/bls/receivables/singleReceive',
    method: 'get',
    params: data
  });
};

/**
 * 异步导出相似客户认定列表
 * @param query 查询条件
 * @returns {Promise} 返回任务ID
 */
export const exportReceivablesAsync = (query?: ReceivablesQuery): AxiosPromise<string> => {
  return request({
    url: '/bls/receivables/export/async',
    method: 'post',
    data: query
  });
};

/**
 * 查询导出任务进度
 * @param taskId 任务ID
 * @returns {Promise} 返回任务信息
 */
export const getExportProgress = (taskId: string): AxiosPromise<any> => {
  return request({
    url: '/bls/receivables/export/progress/' + taskId,
    method: 'get'
  });
};

/**
 * 取消下载
 */
export const cancelExportTask = (taskId: string): AxiosPromise<void> => {
  return request({
    url: `/bls/receivables/export/cancel/${taskId}`,
    method: 'post'
  });
};

/**
 * 查询当前用户最近的未完成的导出任务
 */
export const getLatestRunningTask = (): AxiosPromise<any> => {
  return request({
    url: '/bls/receivables/export/latest',
    method: 'get'
  });
};
