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.id !== 'undefined') {
		data.append('hotelTownship', forData.id)
	}
	if (typeof forData.amount1 !== 'undefined') {
		data.append('minTotalPrice', forData.amount1)
	}
	if (typeof forData.amount2 !== 'undefined') {
		data.append('maxTotalPrice', forData.amount2)
	}
	if (forData.search_datatime !== undefined && forData.search_datatime !== null) {
		data.append('payStartTime', forData.search_datatime[0])
		data.append('payEndTime', forData.search_datatime[1])
	}
	if (typeof forData.qz_id !== 'undefined') {
		data.append('saccountState', forData.qz_id)
	}
	if (typeof forData.keyword !== 'undefined') {
		data.append('ledgerParam', forData.keyword)
	}
	
	return request({
		url: '/mhotel/bookquearyLedgerPage.action',
		method: 'post',
		data
	})
}


// 获取乡镇配置列表
export function getTowns() {
	let query = '?code=10'

	return request({
		url: '/mhotel/hotelqueryList.action' + query,
		method: 'get'
	});
};

// 下载
export function downloadExcel(forData) {
	let data = new FormData()
	if (typeof forData.id !== 'undefined') {
		data.append('hotelTownship', forData.id)
	}
	if (typeof forData.amount1 !== 'undefined') {
		data.append('minTotalPrice', forData.amount1)
	}
	if (typeof forData.amount2 !== 'undefined') {
		data.append('maxTotalPrice', forData.amount2)
	}
	if (forData.search_datatime !== undefined && forData.search_datatime !== null) {
		data.append('payStartTime', forData.search_datatime[0])
		data.append('payEndTime', forData.search_datatime[1])
	}
	if (typeof forData.keyword !== 'undefined') {
		data.append('ledgerParam', forData.keyword)
	}
	
	return request({
		url: '/mhotel/booktoLedgerAdmimnExcel.action',
		method: 'post',
		data
	})
}

// 清账/取消清账
export function bookmodifyAaccountStatus(forData) {
	const data = {
	  saccountState: forData.saccountState,
	  hotelConfigList: forData.hotelConfigList
	};
	
	return request({
		url: '/mhotel/bookmodifyAaccountStatus.action',
		method: 'post',
		data
	})
}

// 台账统计查询
export function bookqueryLedgerTj(forData) {
	let data = new FormData()

	if (typeof forData.id !== 'undefined') {
		data.append('hotelTownship', forData.id)
	}
	if (typeof forData.amount1 !== 'undefined') {
		data.append('minTotalPrice', forData.amount1)
	}
	if (typeof forData.amount2 !== 'undefined') {
		data.append('maxTotalPrice', forData.amount2)
	}
	if (forData.search_datatime !== undefined && forData.search_datatime !== null) {
		data.append('payStartTime', forData.search_datatime[0])
		data.append('payEndTime', forData.search_datatime[1])
	}
	if (typeof forData.qz_id !== 'undefined') {
		data.append('saccountState', forData.qz_id)
	}
	if (typeof forData.keyword !== 'undefined') {
		data.append('ledgerParam', forData.keyword)
	}
	
	return request({
		url: '/mhotel/bookqueryLedgerTj.action',
		method: 'post',
		data
	})
}