import http from '@/utils/request'

// 获取
export function getTravelAgencyUser (params) {
  // eslint-disable-next-line prefer-const
  let { pageNum = 1, pageSize = 10, status = ['inactive', 'active'], name } = params
  status = status.map(val => {
    return `status=${val}`
  }).join('&')
  return http.get(`/travelagencyuser?pageNum=${pageNum}&pageSize=${pageSize}&${status}${name ? '&name=' + name : ''}`)
}

// 新增
export function addTravelAgencyUser (params) {
  return http.post('/travelagencyuser', params)
}

// 编辑
export function setTravelAgencyUserById (id, params) {
  return http.put(`/travelagencyuser/${id}`, params)
}

// 删除
export function deleteTravelAgencyUserById (id) {
  return http.delete(`/travelagencyuser/${id}`)
}

// 修改挂账额度
export function setTravelAgencyUserAmount ({ id, amount }) {
  return http.put(`/travelagencyuser/${id}/accountableamount`, { amount })
}

// 激活
export function activeTravelAgencyUser ({ id, active }) {
  return http.post(`/travelagencyuser/${id}/active`, { active })
}

// 扣费
export function deductTravelAgencyUser ({ id, amount, remark }) {
  return http.put(`/travelagencyuser/${id}/deduct`, { amount, remark })
}

// 充值
export function rechargeTravelAgencyUser ({ id, amount, remark }) {
  return http.put(`/travelagencyuser/${id}/recharge`, { amount, remark })
}

// 获取票种
export function getTravelAgencyUserTickets (id) {
  return http.get(`/travelagencyuser/${id}/tickets?pageNum=1&pageSize=999`)
}

// 获取景点
export function getTravelAgencyUserPerforms (id) {
  return http.get(`/travelagencyuser/${id}/performs?pageNum=1&pageSize=999`)
}

// 设置票种
export function setTravelAgencyUserTickets (id, tickets) {
  return http.post(`/travelagencyuser/${id}/tickets`, { tickets })
}

// 设置景点
export function setTravelAgencyUserPerforms (id, performs) {
  return http.post(`/travelagencyuser/${id}/performs`, { performs })
}
// 获取交易记录
export function getTravelAgencyUserTransactionRecord ({ pageNum = 1, start = '', end = '', type = '', user = '' }) {
  return http.get(`/travelagencyuser/transactionrecord?start=${start}&end=${end}&pageNum=${pageNum}&type=${type}&user=${user}`)
}

// 批量设置票种
export function batchSetTravelAgencyUserTickets (userIds, tickets) {
  return http.post(`/travelagencyuser/batch/tickets`, { userIds, tickets })
}

// 批量设置节目
export function batchSetTravelAgencyUserPerforms (userIds, performs) {
  return http.post(`/travelagencyuser/batch/performs`, { userIds, performs })
}
