import { request } from '/@/utils/service';
import { UserPageQuery } from '@fast-crud/fast-crud';

export const apiPrefix = '/api/sellers/product/trend/daily/';

export function getCardData(query: UserPageQuery) {
  return request({
    url: '/api/sellers/home/total/',//需要修改
    method: 'GET',
    params: query,
  });
}

export function getLineData(query: UserPageQuery) {
  query['dateRangeType'] = 'D';
  return request({
    url: apiPrefix,
    method: 'GET',
    params: query,
  });
}

export function getLineWeekData(query: UserPageQuery) {
  query['dateRangeType'] = 'W';
  return request({
    url: apiPrefix,
    method: 'GET',
    params: query,
  });
}

export function getLineMonthData(query: UserPageQuery) {
  query['dateRangeType'] = 'M';
  return request({
    url: apiPrefix,
    method: 'GET',
    params: query,
  });
}

// 任务列表
export function postCreateTask(body) {
  return request({
    url: '/api/report_manage/summary-tasks/',
    method: 'POST',
    data: body,
  });
}

export function getTasks(query) {
  return request({
    url: '/api/report_manage/summary-tasks/',
    method: 'GET',
    params: query,
  });
}

export function postDeleteTask(body) {
  return request({
    url: `/api/report_manage/summary-tasks/delete/`,
    method: 'POST',
    data: body,
  });
}

export function postUpdateTask(body) {
  return request({
    url: `/api/report_manage/summary-tasks/${body.id}/`,
    method: 'POST',
    data: body,
  });
}

export function getOperationSelect(query) {
  return request({
    url: '/api/system/user-select/',
    method: 'GET',
    params: query,
  });
}

// 日数据列表展示
export function getDayData(query) {
  return request({
    url: `/api/report_manage/data-day/`,
    method: 'GET',
    params: query,
  });
}

export function getWeekData(query) {
  return request({
    url: `/api/report_manage/data-week/`,
    method: 'GET',
    params: query,
  });
}

export function getMonthData(query) {
  return request({
    url: `/api/report_manage/data-month/`,
    method: 'GET',
    params: query,
  });
}


//日数据插入
export function postCreateDayData(body) {
  return request({
    url: `/api/report_manage/data-day/`,
    method: 'POST',
    data: body,
  });
}

export function postCreateWeekData(body) {
  return request({
    url: `/api/report_manage/data-week/`,
    method: 'POST',
    data: body,
  });
}

export function postCreateMonthData(body) {
  return request({
    url: `/api/report_manage/data-month/`,
    method: 'POST',
    data: body,
  });
}

// 日数据更新页面的数据展示
export function getDayTaskData(query) {
  return request({
    url: '/api/report_manage/summary-tasks/data/day/',
    method: 'GET',
    params: query,
  });
}

export function getWeekTaskData(query) {
  return request({
    url: '/api/report_manage/summary-tasks/data/week/',
    method: 'GET',
    params: query,
  });
}

export function getMonthTaskData(query) {
  return request({
    url: '/api/report_manage/summary-tasks/data/month/',
    method: 'GET',
    params: query,
  });
}

//日数据更新
export function postUpdateDayData(body) {
  return request({
    url: `/api/report_manage/data-day/${body.id}/`,
    method: 'POST',
    params: body,
  });
}

export function postUpdateWeekData(body) {
  return request({
    url: `/api/report_manage/data-week/${body.id}/`,
    method: 'POST',
    params: body,
  });
}
export function postUpdateMonthData(body) {
  return request({
    url: `/api/report_manage/data-month/${body.id}/`,
    method: 'POST',
    params: body,
  });
}

