import http from '@/utils/request'

// 获取自助机设备
export function getTermManager (params) {
  return http.get(`termmanager/?pageSize=${params.pageSize !== undefined ? params.pageSize : 10}&pageNum=${params.pageNum}&status=${params.status}&nickname=${params.nickname}&mac=${params.mac}`)
}

export function getOrderStatisticsByTerm (params, group) {
  return http.post('orderstatistics/termOrderPickupTicketStatistics', {
    fields: ['term_pickup_ticket_num'],
    filter: params,
    groupby: group
  })
}
export function exportOrderStatisticsByTerm (params, group) {
  return http.post('orderstatistics/termOrderPickupTicketStatistics', {
    export: {
      'fileprefix': '自助机取票统计',
      'type': '自助机取票统计'
    },
    fields: ['term_pickup_ticket_num'],
    filter: params,
    groupby: group
  })
}

export function activeTerm (id, value) {
  return http.post(`termmanager/${id}/active`, { active: value })
}
export function deleteTerm (id) {
  return http.delete(`termmanager/${id}`)
}
export function blockTerm (id) {
  return http.post(`termmanager/${id}/block`, {
    'block': true
  })
}
export function recoverTerm (id) {
  return http.post(`termmanager/${id}/block`, {
    'block': false
  })
}
export function getBlackList () {
  return http.get('termmanager/?pageNum=1&pageSize=1000&status=blocked')
}

export function updateTermById (id, params) {
  return http.put(`termmanager/${id}`, params)
}

// 获取景点自助机
export function getTermScenics (id) {
  return http.get(`termmanager/${id}/scenics/?pageNum=0`)
}

// 获取景点自助机
export function setTermScenics (id, scenics) {
  return http.post(`termmanager/${id}/scenics`, {
    scenics
  })
}
