import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CustomerInfoVO, CustomerInfoForm, CustomerInfoQuery, CusCustomerQueryBo } from '@/api/customer/cus/types';

/**
 * 客户信息变更轨迹查询
 * @param customerNo
 */
export const queryCustomerInfoChangeTrack = (customerNo: string | number) => {
  return request({
    url: '/customer/cus/queryCustomerInfoChangeTrack?customerNo=' + customerNo,
    method: 'get'
  });
};
/**
 * 当前客户的相似客户合并/拆分轨迹查询
 * @param customerNo
 */
export const queryCusCustomerMergeSplitInfo = (customerNo: string | number) => {
  return request({
    url: '/customer/cus/queryCusCustomerMergeSplitInfo?customerNo=' + customerNo,
    method: 'get'
  });
};
/**
 * 客户保单信息信息
 * @param customerNo
 * @param contType
 */
export const queryCustomerCont = (customerNo: string | number, system: string | number) => {
  return request({
    url: '/customer/cus/queryCustomerCont?system=' + system + '&customerNo=' + customerNo,
    method: 'get'
  });
};
/**
 * 客户银行信息信息
 * @param customerNo
 */
export const queryCustomerBank = (customerNo: string | number) => {
  return request({
    url: '/customer/cus/queryCustomerBank?customerNo=' + customerNo,
    method: 'get'
  });
};
/**
 * 客户工作单位信息
 * @param customerNo
 */
export const queryCustomerEmployment = (customerNo: string | number) => {
  return request({
    url: '/customer/cus/queryCustomerEmployment?customerNo=' + customerNo,
    method: 'get'
  });
};
/**
 * 客户联系地址信息
 * @param customerNo
 */
export const queryCustomerAddress = (customerNo: string | number) => {
  return request({
    url: '/customer/cus/queryCustomerAddress?customerNo=' + customerNo,
    method: 'get'
  });
};
/**
 * 客户联系方式信息
 * @param customerNo
 */
export const queryCustomerContact = (customerNo: string | number) => {
  return request({
    url: '/customer/cus/queryCustomerContact?customerNo=' + customerNo,
    method: 'get'
  });
};
/**
 * 客户标签信息
 * @param customerNo
 */
export const queryCustomerTagInfo = (customerNo: string | number) => {
  return request({
    url: '/customer/cus/queryCustomerTagInfo?customerNo=' + customerNo,
    method: 'get'
  });
};
/**
 * 客户子客户信息
 * @param customerNo
 */
export const queryCustomerSubIds = (customerNo: string | number) => {
  return request({
    url: '/customer/cus/queryCustomerSubIds?customerNo=' + customerNo,
    method: 'get'
  });
};

/**
 * 客户证件信息
 * @param customerNo
 */
export const queryCustomerIdentification = (customerNo: string | number) => {
  return request({
    url: '/customer/cus/queryCustomerIdentification?customerNo=' + customerNo,
    method: 'get'
  });
};
/**
 * 客户基本信息查询
 * @param customerNo
 */
export const queryCustomerInfo = (customerNo: string | number) => {
  return request({
    url: '/customer/cus/queryCustomerInfo?customerNo=' + customerNo,
    method: 'get'
  });
};

/**
 * 根据条件查询客户信息方法
 * @param query
 */
export const queryCustomerInfoPageList = (cusCustomerQueryBo?: CusCustomerQueryBo) => {
  return request({
    url: '/customer/cus/queryPageList',
    method: 'get',
    params: cusCustomerQueryBo
  });
};
/**
 * 查询客户信息列表
 * @param query
 * @returns {*}
 */

export const listCustomerInfo = (query?: CustomerInfoQuery): AxiosPromise<CustomerInfoVO[]> => {
  return request({
    url: '/customer/customerInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询客户信息详细
 * @param customerNo
 */
export const getCustomerInfo = (customerNo: string | number): AxiosPromise<CustomerInfoVO> => {
  return request({
    url: '/customer/customerInfo/' + customerNo,
    method: 'get'
  });
};
/**
 * 异步导出相似客户认定列表
 * @param query 查询条件
 * @returns {Promise} 返回任务ID
 */
export const exportCustomerInfoAsync = (query?: CusCustomerQueryBo): AxiosPromise<string> => {
  return request({
    url: '/customer/cus/exportCustomerInfo/async',
    method: 'post',
    data: query
  });
};

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

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

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