You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/** 报价有效期3 分钟 */
export const QUOTE_VALIDITY_MS = 3 * 60 * 1_000;
/** processing 超时阈值RPA job 360s + sweeper 60s 宽限期,避免误杀 active job */
export const RPA_QUOTE_PROCESSING_MS = 360 * 1_000;
/** sweeper 宽限:须晚于 RPA_JOB_TIMEOUT_MS + lock再标记 failed */
export const QUOTE_SWEEPER_GRACE_MS = 60 * 1_000;
export const QUOTE_TIMEOUT_MS =
RPA_QUOTE_PROCESSING_MS + QUOTE_SWEEPER_GRACE_MS;
/** 超时扫描间隔10 秒 */
export const SWEEPER_INTERVAL_MS = 10 * 1_000;
/** 幂等记录 TTL24 小时 */
export const IDEMPOTENCY_TTL_MS = 24 * 60 * 60 * 1_000;
/** quote_id 前缀 */
export const QUOTE_ID_PREFIX = "QTE";
/** 核心四档 service_level × rate_option 组合(最低验收) */
export const REQUIRED_QUOTE_TIERS = [
{ service_level: "standard", rate_option: "lowest" },
{ service_level: "standard", rate_option: "fastest" },
{ service_level: "guaranteed", rate_option: "lowest" },
{ service_level: "guaranteed", rate_option: "fastest" },
] as const;
/** MotherShip UI 可能出现的档位(仅排序参考,不作过滤白名单) */
export const UI_QUOTE_TIER_SORT_ORDER = [
{ service_level: "standard", rate_option: "lowest" },
{ service_level: "standard", rate_option: "fastest" },
{ service_level: "standard", rate_option: "bestValue" },
{ service_level: "guaranteed", rate_option: "lowest" },
{ service_level: "guaranteed", rate_option: "fastest" },
{ service_level: "guaranteed", rate_option: "bestValue" },
] as const;
/** @deprecated 使用 UI_QUOTE_TIER_SORT_ORDERMotherShip 返回档位数动态,禁止白名单过滤 */
export const UI_QUOTE_TIERS = UI_QUOTE_TIER_SORT_ORDER;
const SERVICE_LEVEL_RANK = new Map<string, number>(
["standard", "guaranteed"].map((k, i) => [k, i]),
);
const RATE_OPTION_RANK = new Map<string, number>(
["lowest", "fastest", "bestValue"].map((k, i) => [k.toLowerCase(), i]),
);
/** 稳定排序standard 先于 guaranteedlowest → fastest → bestValue */
export function compareUiTierSortOrder(
serviceLevelA: string,
rateOptionA: string,
serviceLevelB: string,
rateOptionB: string,
): number {
const sl =
(SERVICE_LEVEL_RANK.get(serviceLevelA) ?? 99) -
(SERVICE_LEVEL_RANK.get(serviceLevelB) ?? 99);
if (sl !== 0) {
return sl;
}
return (
(RATE_OPTION_RANK.get(rateOptionA.toLowerCase()) ?? 99) -
(RATE_OPTION_RANK.get(rateOptionB.toLowerCase()) ?? 99)
);
}
/** MotherShip 可选档位(如最优性价比 bestValue */
export const OPTIONAL_QUOTE_TIERS = [
{ service_level: "standard", rate_option: "bestValue" },
{ service_level: "guaranteed", rate_option: "bestValue" },
] as const;