import request from '@/utils/request'
// 上传文件并分析销售数据

export function uploadAndAnalyzeSales(file) {
  const formData = new FormData()
  formData.append('file', file)

  return request({
    baseURL: process.env.VUE_APP_PYTHON_API,
    url: '/api/sale-effect/upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    timeout: 300000 // 5分钟超时，因为分析可能需要较长时间
  })
}

// 获取销售分析结果
export function getSalesResults() {
  return request({
    baseURL: process.env.VUE_APP_PYTHON_API,
    url: '/api/sale-effect/results',
    method: 'get'
  })
}

// 获取销售分析总览数据
export function getSalesOverview(params) {
  return request({
    baseURL: process.env.VUE_APP_PYTHON_API,
    url: '/api/sale-effect/overview',
    method: 'get',
    params: params
  })
}

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