import $http from '@/common/request.js';

export {
  // 会议室详情接口（图片，基本信息，设备列表）
  getMeetingroomDetail,
  // 我的预约列表
  getMyReserveList,
  // 预约详情
  getReserveDetail,
  // 取消预约
  cancelReserve,
  // 会议室列表
  getMeetingList,
  // 预约会议室
  reserveMeetingroom,
  // 更新会议室成员
  updateRerverMember,
  // 根据部门id 获取部门用户
  getUserByDept,
  // 获取指定时间已预约的会议室
  getFiterTimeRerveRoomList,
  // 获取指定时间推荐的会议室
  getFiterTimeRecommandRoomList,
  // 获取收藏会议室列表
  getCollectRoomList,
  // 收藏会议室
  collectRoom,
  // 取消收藏会议室
  cancelCollectRoom,
  // 获取推荐会议参与人员
  getRecommandAttendees,
  // 结束会议室预约
  endMeetingReserve,
  // 更改会议标题
  updateMeetingTitle,
  // 支付会议室预约订单
  payMeetingReserve,
  // 预约会议室的收费列表
  getRerveRoomChargeList,
  // -会议室订单详情发起结束会议
  meetingBookingEndFromOrder,
  // -会议室订单详情发起取消会议
  meetingBookingCancelFromOrder,
  // 获取会议室运营时间
  getMeetingRoomServerTime
};

function meetingBookingCancelFromOrder(orderId) {
  return $http({
    url: `/meetingBooking/cancelFromOrder/${orderId}`,
    method: 'PUT'
  });
}

function meetingBookingEndFromOrder(orderId) {
  return $http({
    url: `/meetingBooking/endFromOrder/${orderId}`,
    method: 'PUT'
  });
}

function getMeetingroomDetail(id) {
  return $http({
    url: `/meeting/user/${id}`,
    method: 'GET'
  });
}

function getMyReserveList() {
  return $http({
    url: '/meetingBooking/user',
    method: 'GET'
  });
}

function getReserveDetail(id) {
  return $http({
    url: `/meetingBooking/${id}`,
    method: 'GET'
  });
}

function cancelReserve(id) {
  return $http({
    url: `/meetingBooking/cancel/${id}`,
    method: 'PUT'
  });
}

function getMeetingList() {
  return $http({
    url: `/meeting/v2/all`,
    method: 'GET'
  });
}

function reserveMeetingroom(id, params) {
  return $http({
    url: `/meetingBooking`,
    method: 'POST',
    headers: {
      'content-type': 'application/json'
    },
    data: JSON.stringify({ ...params, meetingId: id }),
    isNotShowErrorToast: true
  });
}

function updateRerverMember(params) {
  return $http({
    url: `/meetingBooking/updateMember`,
    method: 'POST',
    headers: {
      'content-type': 'application/json'
    },
    data: JSON.stringify({ ...params })
  });
}
function updateMeetingTitle(id, params) {
  return $http({
    url: `/meetingBooking/${id}`,
    method: 'PUT',
    headers: {
      'content-type': 'application/json'
    },
    data: JSON.stringify({ ...params })
  });
}
function getUserByDept(ids) {
  return $http({
    url: '/dingding/userByDept',
    method: 'POST',
    headers: {
      'content-type': 'application/json'
    },
    data: JSON.stringify(ids)
  });
}

function getFiterTimeRerveRoomList(params) {
  return $http({
    url: '/meetingBooking/user/booking',
    method: 'GET',
    data: { ...params }
  });
}

function getFiterTimeRecommandRoomList(params) {
  return $http({
    url: '/meeting/recommend',
    method: 'GET',
    data: { ...params }
  });
}

function getCollectRoomList() {
  return $http({
    url: '/meetingFavorite',
    method: 'GET'
  });
}

function collectRoom(meetingId) {
  return $http({
    url: `/meetingFavorite?meetingId=${meetingId}`,
    method: 'POST',
    headers: {
      'content-type': 'application/json'
    }
  });
}

function cancelCollectRoom(meetingId) {
  return $http({
    url: `/meetingFavorite?meetingId=${meetingId}`,
    method: 'DELETE',
    headers: {
      'content-type': 'application/json'
    }
  });
}

function getRecommandAttendees() {
  return $http({
    url: '/persagy/meeting/attendees',
    method: 'GET'
  });
}

function endMeetingReserve(reserveId) {
  return $http({
    url: `/meetingBooking/end/${reserveId}`,
    method: 'PUT'
  });
}

function payMeetingReserve(orderId) {
  return $http({
    url: `/user/order/meetingOrderPay`,
    method: 'GET',
    data: { id: orderId }
  });
}

function getRerveRoomChargeList(id, params) {
  return $http({
    url: `/meetingBooking/meetingBookBudget`,
    method: 'POST',
    headers: {
      'content-type': 'application/json'
    },
    data: JSON.stringify({ ...params, meetingId: id }),
    isNotShowErrorToast: true
  });
}

function getMeetingRoomServerTime(data) {
  return $http({
    url: `/meeting/queryMeetingUsableTime`,
    method: 'GET',
    data: { ...data }
  });
}
