export const QUOTA_PER_POINT = 5000; export function pointsToQuota(points: unknown): number { const value = Number(points); if (!Number.isSafeInteger(value) || value < 0) { throw new Error("积分必须是非负安全整数"); } const quota = value * QUOTA_PER_POINT; if (!Number.isSafeInteger(quota)) { throw new Error("积分换算后的 quota 超出安全整数范围"); } return quota; } export function quotaToPoints(quota: unknown): number { const value = Number(quota ?? 0); if (!Number.isFinite(value)) return 0; return Math.ceil(value / QUOTA_PER_POINT); }