import request from '@/utils/request'

// 查询充值记录列表
export function listBill(query) {
  return request({
    url: '/system/bill/list',
    method: 'get',
    params: query
  })
}

// 查询充值记录详细
export function getBill(billId) {
  return request({
    url: '/system/bill/' + billId,
    method: 'get'
  })
}

// 新增充值记录
export function addBill(data) {
  return request({
    url: '/system/bill',
    method: 'post',
    data: data
  })
}

// 修改充值记录
export function updateBill(data) {
  return request({
    url: '/system/bill',
    method: 'put',
    data: data
  })
}

// 删除充值记录
export function delBill(billId) {
  return request({
    url: '/system/bill/' + billId,
    method: 'delete'
  })
}

// 查询充值记录统计
export function countBill(query) {
  return request({
    url: '/system/bill/count',
    method: 'get',
    params: query
  })
}

// 查询充值记录统计
export function refreshPayResult(ids) {
  return request({
    url: `/system/bill/refreshPayResult/${ids}`,
    method: 'get',
  })
}

// 手动设备充值
export function rechargeDevice(id) {
  return request({
    url: `/system/bill/rechargeDevice/${id}`,
    method: 'get',
  })
}

// 订单退款
export function refundBill(billId, refundAmount) {
  return request({
    url: '/system/bill/refund',
    method: 'put',
    data: {
      billId,
      refundAmount
    }
  })
}

// 关闭订单
export function closeBill(data) {
  return request({
    url: `/system/bill/close`,
    method: 'put',
    data
  })
}

// 修复订单
export function fixBill(billId) {
  return request({
    url: `/system/bill/${billId}/fix`,
    method: 'put'
  })
}
