import request from '@/utils/request';
import { wrapTreeNode } from '@/utils/format';


// 获取销售同环比
export async function handleGetGetRevenueQOQ(params: any) {
    const data = await request('/Revenue/GetRevenueQOQ', {
        method: 'GET',
        params
    })

    if (data.Result_Code !== 100) {
        return {
            data: [],
            otherData: '',
            current: 1,
            pageSize: 20,
            total: 0,
            success: true,
        };
    }

    const treeTable = wrapTreeNode(data.Result_Data.List);
    return treeTable
}
// 获取销售同环比每日
export async function handleGetRevenueQOQByDate(params: any) {
  const data = await request('/Revenue/GetRevenueQOQByDate', {
    method: 'GET',
    params
  })

  if (data.Result_Code !== 100) {
    return {
      data: [],
      otherData: '',
      current: 1,
      pageSize: 20,
      total: 0,
      success: true,
    };
  }

  const treeTable = wrapTreeNode(data.Result_Data.List);
  return treeTable
}


// 获取销售同环比每天的
export async function handleGetRevenueYOYQOQByDate(params: any) {
  const data = await request('/Revenue/GetRevenueYOYQOQByDate', {
    method: 'GET',
    params
  })

  if (data.Result_Code !== 100) {
    return {
      data: [],
      otherData: '',
      current: 1,
      pageSize: 20,
      total: 0,
      success: true,
    };
  }

  const treeTable = wrapTreeNode(data.Result_Data.List);
  return treeTable
}


// 获取月度营收分析
export async function handleGetBusinessItemSummary(params: any) {
    const data = await request('/Revenue/GetBusinessItemSummary', {
        method: 'GET',
        params
    })

    if (data.Result_Code !== 100) {
        return {
            data: [],
            otherData: '',
            current: 1,
            pageSize: 20,
            total: 0,
            success: true,
        };
    }

    const treeTable = wrapTreeNode(data.Result_Data.List);
    return treeTable
}
