import { http } from '../http';

export const dashboardApi = {
  getDashboardData: async (params: {
    shop: string;
    startDate?: string;
    endDate?: string;
    export?: boolean;
  }) => {
    try {
      // 实际项目中，这里应该调用真实的API
      // const response = await http.get('/dashboard/data', { params });
      // return response.data;
      
      // 模拟数据
      return {
        kpiData: [
          {
            title: '总销售额',
            value: '¥128,500',
            change: 12.5,
            status: 'up',
          },
          {
            title: '订单数',
            value: '2,850',
            change: 8.2,
            status: 'up',
          },
          {
            title: '转化率',
            value: '4.8%',
            change: -1.2,
            status: 'down',
          },
          {
            title: '平均订单价值',
            value: '¥45.1',
            change: 3.5,
            status: 'up',
          },
        ],
        trendData: [
          { date: '2024-01-01', sales: 12000, orders: 200 },
          { date: '2024-01-02', sales: 15000, orders: 250 },
          { date: '2024-01-03', sales: 18000, orders: 300 },
          { date: '2024-01-04', sales: 16000, orders: 280 },
          { date: '2024-01-05', sales: 20000, orders: 320 },
          { date: '2024-01-06', sales: 22000, orders: 350 },
          { date: '2024-01-07', sales: 19000, orders: 310 },
        ],
      };
    } catch (error) {
      console.error('Error fetching dashboard data:', error);
      throw error;
    }
  },
};