import { queryStr } from '@/utils/query';
import { request } from 'umi';
import {api} from '../api'
export type Fans = {
  beginDate?: string,
  endDate?: string,
  mpId?: string,
  type?: 1 | 2 | 3 | 4,//时间类型 1 按小时；2 按天 3 按周 4 按月
}
/**总览统计 */
export async function getStatistics(params:{ userId: number }) {
  return request(api+`/system/statistics${queryStr(params)}`);
}
/**指定公众号的统计数据 */
export async function getStatisticsMpId(mpId:string) {
  return request(`${api}/system/statistics/${mpId}`);
}
/**图文分析 */
export async function getArticleSummary(params: Fans) {
  return request(`${api}/system/statistics/articleSummary${queryStr(params)}`);
}
/**粉丝增长 */
export async function getFanGrowth(params: Fans) {
  return request(`${api}/system/statistics/fanGrowth${queryStr(params)}`);
}
/**粉丝属性 */
export async function getFansAttribute(params: Fans) {
  return request(`${api}/system/statistics/fansAttribute${queryStr(params)}`);
}
/**统计指定公众号粉丝的活跃数据 */
export async function getFansActive(params: { mpId: string, timeDto: any }) {
  let { mpId, timeDto } = params
  return request(`${api}/system/statistics/fansActive/${mpId}`, {
    method: 'POST',
    data: timeDto
  });
}
/**统计指定公众号粉丝的互动数据 */
export async function getFansInteractive(params: { mpId: string, timeDto: any }) {
  let { mpId, timeDto } = params
  return request(`${api}/system/statistics/fansInteractive/${mpId}`, {
    method: 'POST',
    data: timeDto
  });
}
/**统计指定公众号粉丝的忠诚度 */
export async function getFansKeep(params: { mpId: string, statisticsKeepDto: any }) {
  let { mpId, statisticsKeepDto } = params
  return request(`${api}/system/statistics/fansKeep/${mpId}`, {
    method: 'POST',
    data: statisticsKeepDto
  });
}