/** 我的收入假数据，接口就绪后替换 */

export const SERVICE_CATEGORIES = [
	{ id: 'all', name: '全部' },
	{ id: '1', name: '上门按摩' },
	{ id: '2', name: '爬山' },
	{ id: '3', name: '台球' },
]

export const SETTLE_STATUS_OPTIONS = [
	{ key: 'all', label: '全部' },
	{ key: 'settled', label: '已结算' },
	{ key: 'unsettled', label: '未结算' },
]

/**
 * 原型演示用默认日期：2025.01.01 至 2025.12.31
 * 接口对接后可改回 getDefaultDateRange()
 */
export const MOCK_DEFAULT_DATE_RANGE = {
	start: '2025.01.01',
	end: '2025.12.31',
	startTs: new Date('2025/01/01').getTime(),
	endTs: new Date('2025/12/31 23:59:59').getTime(),
}

/** 合计约 1,253.12 元，与原型一致 */
export const MOCK_INCOME_LIST = [
	{
		id: '1',
		categoryId: '1',
		categoryName: '上门按摩',
		categoryIcon: '',
		serviceName: '会所水疗+中式推拿',
		incomeAmount: 60.58,
		orderTotal: 268.0,
		completionTime: '2025-12-14 12:02:45',
		status: 'unsettled',
	},
	{
		id: '2',
		categoryId: '1',
		categoryName: '上门按摩',
		categoryIcon: '',
		serviceName: '会所水疗+中式推拿',
		incomeAmount: 60.58,
		orderTotal: 268.0,
		completionTime: '2025-12-13 15:20:30',
		status: 'unsettled',
	},
	{
		id: '3',
		categoryId: '2',
		categoryName: '爬山',
		categoryIcon: '',
		serviceName: '户外徒步向导',
		incomeAmount: 88.0,
		orderTotal: 150.0,
		completionTime: '2025-12-12 08:30:00',
		status: 'unsettled',
	},
	{
		id: '4',
		categoryId: '1',
		categoryName: '上门按摩',
		categoryIcon: '',
		serviceName: '会所水疗+中式推拿',
		incomeAmount: 60.58,
		orderTotal: 268.0,
		completionTime: '2025-12-10 18:45:12',
		status: 'unsettled',
	},
	{
		id: '5',
		categoryId: '1',
		categoryName: '上门按摩',
		categoryIcon: '',
		serviceName: '中式推拿-培元疏通',
		incomeAmount: 128.5,
		orderTotal: 200.0,
		completionTime: '2025-11-28 16:45:33',
		status: 'settled',
	},
	{
		id: '6',
		categoryId: '2',
		categoryName: '爬山',
		categoryIcon: '',
		serviceName: '山地越野陪同',
		incomeAmount: 95.0,
		orderTotal: 180.0,
		completionTime: '2025-11-15 07:00:00',
		status: 'settled',
	},
	{
		id: '7',
		categoryId: '1',
		categoryName: '上门按摩',
		categoryIcon: '',
		serviceName: '泰式SPA',
		incomeAmount: 72.3,
		orderTotal: 268.0,
		completionTime: '2025-10-20 20:10:08',
		status: 'settled',
	},
	{
		id: '8',
		categoryId: '3',
		categoryName: '台球',
		categoryIcon: '',
		serviceName: '中式8球教学',
		incomeAmount: 45.0,
		orderTotal: 128.0,
		completionTime: '2025-09-08 14:30:00',
		status: 'unsettled',
	},
	{
		id: '9',
		categoryId: '1',
		categoryName: '上门按摩',
		categoryIcon: '',
		serviceName: '会所水疗+中式推拿',
		incomeAmount: 60.58,
		orderTotal: 268.0,
		completionTime: '2025-08-05 11:22:18',
		status: 'settled',
	},
	{
		id: '10',
		categoryId: '1',
		categoryName: '上门按摩',
		categoryIcon: '',
		serviceName: '经络调理',
		incomeAmount: 156.0,
		orderTotal: 320.0,
		completionTime: '2025-06-18 19:00:00',
		status: 'settled',
	},
	{
		id: '11',
		categoryId: '2',
		categoryName: '爬山',
		categoryIcon: '',
		serviceName: '户外徒步向导',
		incomeAmount: 66.0,
		orderTotal: 150.0,
		completionTime: '2025-04-22 06:30:00',
		status: 'unsettled',
	},
	{
		id: '12',
		categoryId: '1',
		categoryName: '上门按摩',
		categoryIcon: '',
		serviceName: '会所水疗+中式推拿',
		incomeAmount: 60.58,
		orderTotal: 268.0,
		completionTime: '2025-02-01 12:00:46',
		status: 'settled',
	},
	{
		id: '13',
		categoryId: '3',
		categoryName: '台球',
		categoryIcon: '',
		serviceName: '斯诺克陪练',
		incomeAmount: 88.82,
		orderTotal: 200.0,
		completionTime: '2025-01-15 16:00:00',
		status: 'settled',
	},
	{
		id: '14',
		categoryId: '1',
		categoryName: '上门按摩',
		categoryIcon: '',
		serviceName: '深度理疗套餐',
		incomeAmount: 210.6,
		orderTotal: 498.0,
		completionTime: '2025-07-01 10:00:00',
		status: 'settled',
	},
]

export function formatIncomeTotal(amount) {
	const num = parseFloat(amount) || 0
	if (Math.floor(num) >= 10000) {
		const wan = Math.floor((num / 10000) * 100) / 100
		return `${wan.toFixed(2)}万`
	}
	const fixed = num.toFixed(2)
	const [intPart, decPart] = fixed.split('.')
	const withComma = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
	return decPart ? `${withComma}.${decPart}` : withComma
}

export function formatDateYmd(date) {
	const d = date instanceof Date ? date : new Date(date)
	const y = d.getFullYear()
	const m = String(d.getMonth() + 1).padStart(2, '0')
	const day = String(d.getDate()).padStart(2, '0')
	return `${y}.${m}.${day}`
}

export function getDefaultDateRange() {
	const now = new Date()
	const start = new Date(now.getFullYear(), now.getMonth(), 1)
	return {
		start: formatDateYmd(start),
		end: formatDateYmd(now),
		startTs: start.getTime(),
		endTs: now.getTime(),
	}
}

export function parseTimeStr(str) {
	return new Date(str.replace(/-/g, '/')).getTime()
}

/** 获取演示用初始日期范围 */
export function getMockDateRange() {
	return { ...MOCK_DEFAULT_DATE_RANGE }
}
