import request from '@/utils/request'

// 上传文件并分析销售数据
export function uploadAndAnalyzeSales(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/statistics/sales/upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    timeout: 300000 // 5分钟超时，因为分析可能需要较长时间
  })
}

// 获取销售分析结果
export function getSalesResults() {
  return request({
    url: '/statistics/sales/results',
    method: 'get'
  })
}

// 获取销售分析总览数据
export function getSalesOverview(params) {
  return request({
    url: '/statistics/sales/overview',
    method: 'get',
    params: params
  })
}

// 预测销量趋势
export function predictSalesTrend(params) {
  return request({
    url: 'http://localhost:8085/api/sales/predict',
    method: 'post',
    data: params,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}