import request from '@/utils/request'

// 商户查询设备列表
export function mchListDevice(query) {
  return request({
    url: '/app/device/list',
    method: 'get',
    params: query
  })
}

// 查询设备详细
export function mchGetDevice(deviceId) {
  return request({
    url: '/app/device/' + deviceId,
    method: 'get'
  })
}

// 商户解绑设备
export function mchUnbindDevice(deviceId) {
  return request({
    url: `/app/device/mch/unbind/${deviceId}`,
    method: 'delete'
  })
}

// 商户修改设备
export function mchUpdateDevice(data) {
  return request({
    url: `/app/device`,
    method: 'put',
    data
  })
}

// 商户刷新物联网设备信息
export function mchRefreshIot(deviceId) {
  return request({
    url: `/app/device/${deviceId}/refreshIot`,
    method: 'get'
  })
}

// 商户增加时长
export function mchAddTime(deviceId, amount) {
  return request({
    url: `/app/device/addTime/${deviceId}?amount=${amount}`,
    method: 'put'
  })
}

// 商户时长归零
export function mchResetDevice(deviceId) {
  return request({
    url: `/app/device/${deviceId}/reset`,
    method: 'put'
  })
}

// 商户设备开关
export function mchSwitchDevice(deviceId, status) {
  return request({
    url: `/app/device/${deviceId}/changePower?status=${status}`,
    method: 'put'
  })
}

// 商户通过ids查询设备列表
export function mchListDeviceByIds(ids) {
  return request({
    url: `/mch/device/listByIds/${ids}`,
    method: 'get',
  })
}
