import request from '@/utils/request'

// 查询门店统计列表
export function listStatistics(query) {
  return request({
    url: '/mapi/settlement/store/statistics/list',
    method: 'get',
    params: query
  })
}

export function listStatisticsByStore(query) {
  return request({
    url: '/mapi/settlement/store/statistics/list/bystore',
    method: 'get',
    params: query
  })
}

/**
 * 当日订单统计同步
 * @param query
 * @returns {*}
 */
export function orderStaticsSync() {
  return request({
    url: '/mapi/settlement/store/statistics/sync',
    method: 'get'
  })
}


// 查询门店统计详细
export function getStatistics(id) {
  return request({
    url: '/mapi/settlement/store/statistics/' + id,
    method: 'get'
  })
}

// 导出门店统计
export function exportStatistics(query) {
  return request({
    url: '/mapi/settlement/store/statistics/export',
    method: 'get',
    params: query
  })
}

// 查询充值统计列表
export function listChargeStatistics(query) {
  return request({
    url: '/mapi/settlement/store/statistics/charge/list',
    method: 'get',
    params: query
  })
}

// 导出门店充值统计
export function exportChargeStatistics(query) {
  return request({
    url: '/mapi/settlement/store/statistics/charge/export',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}


// 查询充值统计列表
export function listChargeStatisticsByStore(query) {
  return request({
    url: '/mapi/settlement/store/statistics/charge/bystore',
    method: 'get',
    params: query
  })
}

export function listFactoryStatisticsByStore(query) {
  return request({
    url: '/mapi/settlement/factory/statistics/list/bystore',
    method: 'get',
    params: query
  })
}


// 查询工厂按日期统计列表
export function listStatisticsByDate(query) {
  return request({
    url: '/mapi/settlement/factory/statistics/list/bydate',
    method: 'get',
    params: query
  })
}

// 获取工厂总统计数据
export function getTotalStatistics(query) {
  return request({
    url: '/mapi/settlement/factory/statistics/total',
    method: 'get',
    params: query
  })
}

// 导出工厂按日期统计数据
export function exportStatisticsByDate(query) {
  return request({
    url: '/mapi/settlement/factory/statistics/export/bydate',
    method: 'post',
    params: query,
    responseType: 'blob'
  })
}

// 导出工厂按门店统计数据
export function exportStatisticsByStore(query) {
  this.downloadJson(
    '/mapi/settlement/factory/statistics/export/bystore',
    {
        ...query
    },
    `门店统计_${new Date().getTime()}.xlsx`
  )
}

//工厂端首页dashboard
export function factoryDashborad() {
  return request({
    url: '/mapi/settlement/factory/statistics/dashborad',
    method: 'get'
  })
}

/**
 * 当日订单统计同步
 * @param query
 * @returns {*}
 */
export function factoryStaticsSync() {
  return request({
    url: '/mapi/settlement/factory/statistics/sync',
    method: 'get'
  })
}

//工厂端首页dashboard
export function platformDashborad() {
  return request({
    url: '/mapi/platform/statistics/dashborad',
    method: 'get'
  })
}

// 获取工厂总统计数据
export function getplatformDayTrend(query) {
  return request({
    url: '/mapi/platform/statistics/trend',
    method: 'get',
    params: query
  })
}

// 查询工厂按日期统计列表
export function listplatformStatisticsByDate(query) {
  return request({
    url: '/mapi/platform/statistics/order/list',
    method: 'get',
    params: query
  })
}

export function listplatformStatisticsByStore(query) {
  return request({
    url: '/mapi/platform/statistics/order/bystore',
    method: 'get',
    params: query
  })
}

export function listplatformStatisticsByDay(query) {
  return request({
    url: '/mapi/platform/statistics/order/byday',
    method: 'get',
    params: query
  })
}

export function listplatformStatisticsByFactory(query) {
  return request({
    url: '/mapi/platform/statistics/order/byfactory',
    method: 'get',
    params: query
  })
}
