import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SalesProcessQuery, SalesProcessVO } from './types';

/**
 * 销售预测分析-分析接口
 * @param query
 * @returns {*}
 */

export const getSalesProcessTotal = (query) => {
    return request({
        url: '/process/analysis/get_predictive_analytics_total',
        method: 'post',
        data: query
    });
};

/**
 * 销售预测分析-报表接口
 * @param query
 * @returns {*}
 */

export const listSalesProcess = (query?: SalesProcessQuery & PageQuery): AxiosPromise<{ records: SalesProcessVO[] }> => {
    return request({
        url: '/process/analysis/get_predictive_analytics_report',
        method: 'post',
        data: query
    });
};

/**
 * 销售漏斗分析-分析接口
 * @param query
 * @returns {*}
 */

export const getSalesFunnelTotal = (query) => {
    return request({
        url: '/process/analysis/get_analyze_sales_funnel',
        method: 'post',
        data: query
    });
};

/**
 * 销售漏斗分析-报表接口
 * @param query
 * @returns {*}
 */

export const listSalesFunnel = (query?: SalesProcessQuery & PageQuery): AxiosPromise<{ records: SalesProcessVO[] }> => {
    return request({
        url: '/process/analysis/get_analyze_sales_funnel_report',
        method: 'post',
        data: query
    });
};

/**
 * 业务新增汇总接口
 * @param query
 * @returns {*}
 */

export const getNewBusinessCountTotal = (query) => {
    return request({
        url: '/process/analysis/get_summarize_new_business',
        method: 'post',
        data: query
    });
};

/**
 * 跟进记录汇总 跟进对象汇总接口
 * @param query
 * @returns {*}
 */

export const getFlowUpCountTypeTotal = (query) => {
    return request({
        url: '/process/analysis/get_follow_type_total',
        method: 'post',
        data: query
    });
};

/**
 * 跟进记录汇总 跟进对象表格接口
 * @param query
 * @returns {*}
 */

export const listFlowUpCountType = (query?: SalesProcessQuery & PageQuery): AxiosPromise<{ records: SalesProcessVO[] }> => {
    return request({
        url: '/process/analysis/get_follow_type_report',
        method: 'post',
        data: query
    });
};

/**
 * 跟进记录汇总 跟进类型汇总接口
 * @param query
 * @returns {*}
 */

export const getFlowUpCountModeTotal = (query) => {
    return request({
        url: '/process/analysis/get_follow_mode_total',
        method: 'post',
        data: query
    });
};

/**
 * 跟进记录汇总 跟进类型表格接口
 * @param query
 * @returns {*}
 */

export const listFlowUpCountMode = (query?: SalesProcessQuery & PageQuery): AxiosPromise<{ records: SalesProcessVO[] }> => {
    return request({
        url: '/process/analysis/get_follow_mode_report',
        method: 'post',
        data: query
    });
};

/**
 * 业务综合统计接口
 * @param query
 * @returns {*}
 */

export const getAllBusinessCountTotal = (query) => {
    return request({
        url: '/process/analysis/generate_comprehensive_business_statistics',
        method: 'post',
        data: query
    });
};

/**
 * 业务增长统计接口
 * @param query
 * @returns {*}
 */

export const getBusAddCountTotal = (query) => {
    return request({
        url: '/process/analysis/get_calculate_business_growth_statistics',
        method: 'post',
        data: query
    });
};

/**
 * 业务新增排名接口
 * @param query
 * @returns {*}
 */

export const getNewBusinessRanking = (query) => {
    return request({
        url: '/Summary/business-rankings',
        method: 'post',
        data: query
    });
};

/**
 * 成交数据排名接口
 * @param query
 * @returns {*}
 */

export const getDealDataRanking = (query) => {
    return request({
        url: '/Summary/transaction-ranking',
        method: 'post',
        data: query
    });
};

/**
 * 转化率排名接口
 * @param query
 * @returns {*}
 */

export const getConversionRateRanking = (query) => {
    return request({
        url: '/Summary/conversion-rate-ranking',
        method: 'post',
        data: query
    });
};

/**
 * 跟进拜访排名接口
 * @param query
 * @returns {*}
 */

export const getFollowUpVistRanking = (query) => {
    return request({
        url: '/Summary/follow-up-ranking',
        method: 'post',
        data: query
    });
};
