/**
 * 格式化账户显示文本
 * @param account 账户信息
 * @param intl 国际化对象
 * @returns 格式化后的显示文本
 */
export function formatAccountDisplay(
	account?: BusinessAPI.CompanyPaymentAccountVO,
	intl?: { formatMessage: (args: { id: string }) => string },
): string | undefined {
	console.log('formatAccountDisplay', account);
	if (!account) return undefined;

	const {
		accountCategory,
		accountType,
		accountName,
		bankName,
		branchName,
		accountNumber,
	} = account;

	// 获取账户类型标签
	const getCategoryLabel = () => {
		if (accountCategory === 'COMPANY_ACCOUNT') {
			return intl?.formatMessage({
				id: 'companyPaymentAccount.column.accountCategory.enum.companyAccount',
			});
		}
		return intl?.formatMessage({
			id: 'companyPaymentAccount.column.accountCategory.enum.privateAccount',
		});
	};

	// 获取账户类型标签（微信/支付宝/银行卡）
	const getAccountTypeLabel = () => {
		if (accountType === 'BANK_CARD') {
			return intl?.formatMessage({
				id: 'companyPaymentAccount.column.accountType.enum.bankCard',
			});
		}
		if (accountType === 'ALIPAY') {
			return intl?.formatMessage({
				id: 'companyPaymentAccount.column.accountType.enum.alipay',
			});
		}
		if (accountType === 'WECHAT') {
			return intl?.formatMessage({
				id: 'companyPaymentAccount.column.accountType.enum.wechat',
			});
		}
		return '';
	};

	const categoryLabel = getCategoryLabel();
	const typeLabel = getAccountTypeLabel();

	// 对公账户：公司账户 + 账户名称 + 银行名称 + 账户号码
	if (accountCategory === 'COMPANY_ACCOUNT') {
		return `${categoryLabel} | ${accountName} | ${bankName || ''} | ${branchName || ''} | ${accountNumber || ''}`;
	}

	// 个人账户（银行）：私人账户 + 账户名称 + 银行名称 + 账户号码
	if (accountType === 'BANK_CARD') {
		return `${categoryLabel} | ${accountName} | ${bankName || ''} | ${accountNumber || ''}`;
	}

	// 个人账户（微信/支付宝）：私人账户 + 账户名称 + 账户类型 + 账户号码
	return `${categoryLabel} | ${accountName} | ${typeLabel} | ${accountNumber || ''}`;
}
