import request from '@/utils/request'

// 获取充值记录,表格数据
export function getTableData(forData) {
	let data = new FormData()
	data.append('page', forData.page)
	data.append('rows', forData.rows)
	
	if (typeof forData.key != 'undefined') {
		data.append('key', forData.key)
	}
	if (typeof forData.h_type != 'undefined') {
		data.append('h_type', forData.h_type)
	}
	if (typeof forData.live_time != 'undefined') {
		data.append('live_time', forData.live_time)
	}
	if (typeof forData.end_time != 'undefined') {
		data.append('end_time', forData.end_time)
	}
	if (typeof forData.pay_time != 'undefined') {
		data.append('pay_time', forData.pay_time)
	}
	if (typeof forData.hx_time != 'undefined') {
		data.append('hx_time', forData.hx_time)
	}
	if (typeof forData.cancel_time != 'undefined') {
		data.append('cancel_time', forData.cancel_time)
	}
	if (typeof forData.refund_time != 'undefined') {
		data.append('refund_time', forData.refund_time)
	}
	if (typeof forData.tf_time != 'undefined') {
		data.append('tf_time', forData.tf_time)
	}
	if (typeof forData.create_time != 'undefined') {
		data.append('create_time', forData.create_time)
	}
	if (typeof forData.status != 'undefined') {
		data.append('status', forData.status)
	}
	
	return request({
		url: '/booklist.action',
		method: 'post',
		data
	})
}

// 核销
export function collate(forData) {
	let data = new FormData()
	data.append('id', forData.id)
	data.append('status', forData.status)
	return request({
		url: '/bookoperate_live.action',
		method: 'post',
		data,
		headers: {
			'admin_name': 'admin'
		}
	})
}

// 退款
export function refund(forData) {
	let data = new FormData()
	data.append('id', forData.id)
	data.append('status', forData.status)
	return request({
		url: '/bookrefund_money.action',
		method: 'post',
		data,
		headers: {
			'admin_name': 'admin'
		}
	})
}

// 退房
export function checkout(forData) {
	let data = new FormData()
	data.append('id', forData.id)
	data.append('status', forData.status)
	return request({
		url: '/bookrefund_room.action',
		method: 'post',
		data,
		headers: {
			'admin_name': 'admin'
		}
	})
}

// 统计
export function tongji(forData) {
	let data = new FormData()
	if (typeof forData.h_type != 'undefined') {
		data.append('h_type', forData.h_type)
	}
	data.append('date', forData.date)
	
	return request({
		url: '/houseday_tj.action',
		method: 'post',
		data
	})
}

// 下载
export function downloadExcel(forData) {
	let data = new FormData()
	
	if (typeof forData.key != 'undefined') {
		data.append('key', forData.key)
	}
	if (typeof forData.h_type != 'undefined') {
		data.append('h_type', forData.h_type)
	}
	if (typeof forData.live_time != 'undefined') {
		data.append('live_time', forData.live_time)
	}
	if (typeof forData.end_time != 'undefined') {
		data.append('end_time', forData.end_time)
	}
	if (typeof forData.pay_time != 'undefined') {
		data.append('pay_time', forData.pay_time)
	}
	if (typeof forData.hx_time != 'undefined') {
		data.append('hx_time', forData.hx_time)
	}
	if (typeof forData.cancel_time != 'undefined') {
		data.append('cancel_time', forData.cancel_time)
	}
	if (typeof forData.refund_time != 'undefined') {
		data.append('refund_time', forData.refund_time)
	}
	if (typeof forData.tf_time != 'undefined') {
		data.append('tf_time', forData.tf_time)
	}
	if (typeof forData.create_time != 'undefined') {
		data.append('create_time', forData.create_time)
	}
	if (typeof forData.status != 'undefined') {
		data.append('status', forData.status)
	}
	// console.log(forData);
	return request({
		url: '/bookto_excel.action',
		method: 'post',
		data
	})
}