import moment from 'moment';
import type { Request, Response } from 'express';
import type { AnalysisData, DataItem } from './data.d';

// mock data
const visitData: DataItem[] = [];
// const beginDay = new Date().getTime();

const fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5];
for (let i = 0; i < fakeY.length; i += 1) {
    visitData.push(fakeY[i])
//   visitData.push({
//     x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'),
//     y: fakeY[i],
//   });
}

const visitData2 = [];
const fakeY2 = [1, 6, 4, 8, 3, 7, 2];
for (let i = 0; i < fakeY2.length; i += 1) {
    visitData2.push(fakeY2[i])
 /*  visitData2.push({
    x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'),
    y: fakeY2[i],
  }); */
}

const salesData = [];
for (let i = 0; i < 12; i += 1) {
  salesData.push({
    x: `${i + 1}月`,
    y: Math.floor(Math.random() * 1000) + 200,
  });
}
const searchData = [];
for (let i = 0; i < 5; i += 1) {
   const arr= ['丰乐服务区', '肥东服务区', '太湖服务区', '文集服务区', '河口服务区', '八公山服务区', '大龙山服务区'];
   const status= ['繁忙', '良好', '良好', '空闲', '空闲'];
  searchData.push({
    index: i + 1,
    name: arr[i],
    status: status[i],
  });
}

const salesTypeData = [
  {
    x: '餐饮',
    y: 4544,
  },
  {
    x: '商超',
    y: 3321,
  },
  {
    x: '连锁品牌',
    y: 3113,
  },
  {
    x: '小吃',
    y: 2341,
  },
  {
    x: '水果饮品',
    y: 1231,
  },
  {
    x: '地方特产',
    y: 1231,
  },
];

const salesTypeDataOnline = [
  {
    x: '餐饮',
    y: 244,
  },
  {
    x: '商超',
    y: 321,
  },
  {
    x: '连锁品牌',
    y: 311,
  },
  {
    x: '小吃',
    y: 41,
  },
  {
    x: '水果饮品',
    y: 121,
  },
  {
    x: '地方特产',
    y: 111,
  },
];

const salesTypeDataOffline = [
  {
    x: '餐饮',
    y: 99,
  },
  {
    x: '商超',
    y: 188,
  },
  {
    x: '小吃',
    y: 344,
  },
  {
    x: '水果饮品',
    y: 255,
  },
  {
    x: '地方特产',
    y: 65,
  },
];

const offlineData = [];
for (let i = 0; i < 10; i += 1) {
  offlineData.push({
    name: `Stores ${i}`,
    cvr: Math.ceil(Math.random() * 9) / 10,
  });
}
const offlineChartData = [];
for (let i = 0; i < 20; i += 1) {
  const date = moment(new Date().getTime() + 1000 * 60 * 30 * i).format('HH:mm');
  offlineChartData.push({
    date,
    type: '客流量',
    value: Math.floor(Math.random() * 100) + 10,
  });
  offlineChartData.push({
    date,
    type: '支付笔数',
    value: Math.floor(Math.random() * 100) + 10,
  });
}

const radarData: any[] = [];


const getFakeChartData: AnalysisData = {
  visitData,
  visitData2,
  salesData,
  searchData,
  offlineData,
  offlineChartData,
  salesTypeData,
  salesTypeDataOnline,
  salesTypeDataOffline,
  radarData,
};

const fakeChartData = (_: Request, res: Response) => {
  return res.json({
    data: getFakeChartData,
  });
};


