import service from '@/utils/request'

// 新增车主
export const addVehicle = (data) => {
  return service({
    url: '/vehicle/create',
    method: 'post',
    data
  })
}

// 更新车辆信息
export const editVehicle = (data) => {
  return service({
    url: '/vehicle/update',
    method: 'put',
    data
  })
}

export const queryAllVehicles = () => {
  return service({
    url: '/vehicle/all',
    method: 'get'
  })
}

// 根据ID获取车辆信息
export const obtainVehicleId = (id) => {
  return service({
    url: '/vehicle/get?id=' + id,
    method: 'get'
  })
}

// 根据车牌号获取车辆信息
export const obtainVehicleLicense = (number) => {
  return service({
    url: '/vehicle/get-by-plate?plate_number=' + number,
    method: 'get'
  })
}

// 获取车辆列表
export const obtainVehicleList = (params) => {
  return service({
    url: '/vehicle/list',
    method: 'get',
    params
  })
}

// 删除车辆
export const removeVehicleList = (params) => {
  return service({
    url: '/vehicle/delete',
    method: 'delete',
    params
  })
}

// 车辆入场
export const vehicleEntry = (data) => {
  return service({
    url: '/vehicle/entry',
    method: 'post',
    data
  })
}

// 车辆出场
export const vehicleAppear = (data) => {
  return service({
    url: '/vehicle/exit',
    method: 'post',
    data
  })
}

// 创建收费配置
export const createCharge = (data) => {
  return service({
    url: '/vehicle/fee-config/create',
    method: 'post',
    data
  })
}

// 更新收费配置
export const editCharge = (data) => {
  return service({
    url: '/vehicle/fee-config/update',
    method: 'put',
    data
  })
}

// 根据ID获取收费配置
export const obtainChargeId = (id) => {
  return service({
    url: '/vehicle/fee-config/get?id=' + id,
    method: 'get'
  })
}

// 获取收费配置列表
export const obtainChargeList = (id) => {
  return service({
    url: '/vehicle/fee-config/list',
    method: 'get'
  })
}

export const queryVehicleRecordList = (data) => {
  return service({
    url: '/vehicle/record/list',
    method: 'post',
    data
  })
}

// 创建车辆类型
export const createVehicleType = (data) => {
  return service({
    url: '/vehicle/type/create',
    method: 'post',
    data
  })
}

// 更新车辆类型
export const editVehicleType = (data) => {
  return service({
    url: '/vehicle/type/update',
    method: 'put',
    data
  })
}

// 根据ID获取车辆类型
export const obtainVehicleTypeId = (id) => {
  return service({
    url: '/vehicle/type/get?id=' + id,
    method: 'get'
  })
}

// 获取车辆类型列表
export const obtainVehicleTypeList = (data) => {
  return service({
    url: '/vehicle/type/list',
    method: 'post',
    data
  })
}

// 删除车辆类型
export const removeVehicleType = (id) => {
  return service({
    url: '/vehicle/type/delete?id=' + id,
    method: 'delete'
  })
}

// 获取所有车辆类型（下拉选择）
export const getAllVehicleTypes = () => {
  return service({
    url: '/vehicle/type/all',
    method: 'get'
  })
}

// 出场费用预览
export const exitPreview = (data) => {
  return service({
    url: '/vehicle/exit/preview',
    method: 'post',
    data
  })
}

// 确认出场并支付
export const exitConfirm = (data) => {
  return service({
    url: '/vehicle/exit/confirm',
    method: 'post',
    data
  })
}

// 在场车辆列表
export const getInParkVehicles = (params) => {
  return service({
    url: '/vehicle/in-park',
    method: 'get',
    params
  })
}

// 通道事件（RFID实时扫描）
export const getChannelEvents = (after) => {
  return service({
    url: '/channel/events?after=' + (after || 0),
    method: 'get'
  })
}
