import request from '@/utils/request';

/**
 * 根据活动id查询分组数据统计
 * @param id 活动id
 */
export async function getGroupsStatistics(activityId) {
  const res = await request.get('/sylive/groupsStatistics', {
    params: { activityId }
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 获取漏头数据
 * @param params 查询条件
 */
export async function getGroupsStatisticsFunnel(params) {
  const res = await request.get('/sylive/groupsStatistics/funnel', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 获取分级数据
 * @param params 查询条件
 */
export async function getGroupsStatisticsLevel(params) {
  const res = await request.get('/sylive/groupsStatistics/level', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 获取门店数据
 * @param params 查询条件
 */
export async function getGroupsStatisticsBiz(params) {
  const res = await request.get('/sylive/groupsStatistics/biz', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 获取顾问数据
 * @param params 查询条件
 */
export async function getGroupsStatisticsConsultant(params) {
  const res = await request.get('/sylive/groupsStatistics/consultant', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 获取客户数据
 * @param params 查询条件
 */
export async function getGroupsStatisticsCustomer(params) {
  const res = await request.get('/sylive/groupsStatistics/customer', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 获取观看下单统计折线图数据
 * @param params 查询条件
 */
export async function getGroupsStatisticsWatchOrder(params) {
  const res = await request.get('/sylive/groupsStatistics/stacked_watchOrder', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 导出门店
 * @param params 查询条件
 */
export async function exportGroupsStatisticsBiz(params) {
  const res = await request.get('/sylive/groupsStatistics/biz_export', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 导出顾问
 * @param params 查询条件
 */
export async function exportGroupsStatisticsConsultant(params) {
  const res = await request.get('/sylive/groupsStatistics/consultant_export', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 导出客户
 * @param params 查询条件
 */
export async function exportGroupsStatisticsCustomer(params) {
  const res = await request.get('/sylive/groupsStatistics/customer_export', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
