|
|
/** 报价有效期: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;
|
|
|
|
|
|
/** 幂等记录 TTL:24 小时 */
|
|
|
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_ORDER;MotherShip 返回档位数动态,禁止白名单过滤 */
|
|
|
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 先于 guaranteed;lowest → 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;
|