import http from '@/utils/request'

// 获取票种列表
export const getTicketTypeList = (params) => {
  return http.post('/tenant/otaTicketType', { data: params })
}

// 新增门票
export function addTicketType (params) {
  return http.post('/tenant/tickettype/addTicketType', { data: params })
}

// 更新门票
export function updateTicketType (params) {
  return http.post('/tenant/tickettype/updateTicketType', { data: params })
}

// 删除门票
export function deleteTicketType (params) {
  return http.post('/tenant/tickettype/deleteTicketType', { data: params })
}

// 获取景点列表
export function getScenic () {
  return http.post('scenic/getScenic')
}

// 获取景点列表
export function updateScenic (form, pdata) {
  let params = {
    id: form.id,
    name: form.name,
    is_open: form.is_open,
    open_starttime: form.open_starttime,
    open_endtime: form.open_endtime,
    day_check_limit: form.day_check_limit,
    parent_id: pdata.id,
    parent_ids: pdata.parent_ids
  }

  return http.post('/tenant/scenic/updateScenic', { data: params })
}

// 新建景点
export function createScenic (form, pdata) {
  // console.log(pdata)
  let params = {
    name: form.name,
    is_open: form.is_open,
    open_starttime: form.open_starttime,
    open_endtime: form.open_endtime,
    day_check_limit: form.day_check_limit,
    parent_id: pdata.id,
    parent_ids: `${pdata.parent_ids},${pdata.id}`
  }
  return http.post('/tenant/scenic/createScenic', { data: params })
}

// 删除景点
export function delScenic (data) {
  let params = {
    id: data.data.id,
    parent_id: data.data.parent_id,
    parent_ids: data.data.parent_id + ''
  }
  return http.post('/tenant/scenic/delScenic', { data: params })
}
