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';
import { PayablesQuery, PayablesVO } from '@/api/bls/payables/types';

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

export const listPayables = (query) => {
  return request({
    url: '/bls/payables/payableslist',
    method: 'get',
    params: query
  });
};

/**
 * 付费审核
 */
export const auditPayables = (data) => {
  return request({
    url: '/bls/payables/audit',
    method: 'post',
    data: data
  });
};

/**
 * 单笔支付
 */
export const singlePay = (data) => {
  return request({
    url: '/bls/payables/singlePay',
    method: 'post',
    data: data
  });
};

/**
 * 查询付费信息详情
 */
export const getPayAduitDetail = (data) => {
  return request({
    url: '/bls/payables/payAduitDetail',
    method: 'post',
    data: data
  });
};
export const savePayAduitDetail = (data) => {
  return request({
    url: '/bls/payables/savePayAduitDetail',
    method: 'post',
    data: data
  });
};
/**
 * 异步导出相似客户认定列表
 * @param query 查询条件
 * @returns {Promise} 返回任务ID
 */
export const exportPayablesAsync = (query?: PayablesQuery): AxiosPromise<string> => {
  return request({
    url: '/bls/payables/export/async',
    method: 'post',
    data: query
  });
};

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

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

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