chore(shipping-notice): 统一货代发货生命周期阶段命名并优化全链路业务逻辑

This commit is contained in:
hugo committed 2026-08-17 19:56:51 +08:00
1 parent 5ef8329bd8
commit 4ec4e57005
183 files changed
+14653 -3936

No files matched your search

@@ -42,7 +42,7 @@ export function shippingProcessingStatusKey(status: string): string {
* @param code - 后端 status / status_label
* @param te - i18n te
* @param t - i18n t
* @returns 本地化文案;皆无则回退原码
* @returns 本地化文案;未知状态统一显示“状态待确认”,禁止暴露内部码
*/
export function resolveShippingProcessingStatusLabel(
code: string,
@@ -55,7 +55,28 @@ export function resolveShippingProcessingStatusLabel(
if (te(processingKey)) return t(processingKey);
const taskStatusKey = `chat.shippingProcessing.taskStatus.${raw}`;
if (te(taskStatusKey)) return t(taskStatusKey);
return raw;
const unknownKey = 'chat.shippingProcessing.taskStatus.unknown';
return te(unknownKey) ? t(unknownKey) : '状态待确认';
}
/**
* 解析后端阻塞原因的用户文案。
* 核心逻辑:先消费后端 i18n_key(兼容 snake/camel case),再使用原因码专用键;
* 未知原因只显示安全兜底,内部原因码仍保留在响应中供审计使用。
*/
export function resolveShippingProcessingReasonLabel(
reason: { code?: string | null; i18nKey?: string | null; i18n_key?: string | null } | null | undefined,
te: (key: string) => boolean,
t: (key: string) => string,
): string {
if (!reason) return '';
const i18nKey = String(reason.i18nKey || reason.i18n_key || '').trim();
if (i18nKey && te(i18nKey)) return t(i18nKey);
const code = String(reason.code || '').trim();
const reasonCodeKey = code ? `chat.shippingProcessing.reasonCode.${code}` : '';
if (reasonCodeKey && te(reasonCodeKey)) return t(reasonCodeKey);
const unknownKey = 'chat.shippingProcessing.reasonCode.unknown';
return te(unknownKey) ? t(unknownKey) : '当前步骤需要人工处理';
}
/**
@@ -124,7 +145,7 @@ export function resolveShippingProcessingStageLabel(
// 禁止把码当文案:无键时回退通用等待文案,而非裸 code。
return te('chat.shippingProcessing.stageLabel.waiting_system_start')
? t('chat.shippingProcessing.stageLabel.waiting_system_start')
: code;
: '等待系统启动';
}
/**