feat(shipping-notice): 增强发货通知与订单抽取功能,支持多进程处理与紧急停止
- 移除不再使用的 SHIPPING_NOTICE_LAYOUT_PARSER_REVISION 配置 - 在环境配置中新增 SHIPPING_NOTICE_WORKER_CONCURRENCY 和 SHIPPING_NOTICE_JOB_RUNNING_TIMEOUT_SECONDS - 实现发货通知 worker 进程,支持并发处理订单抽取任务 - 引入紧急停止功能,允许管理员在运行中控制订单解析状态 - 更新相关 API,支持读取与设置紧急停止状态 - 增强文档与代码注释,反映新的业务逻辑与功能要求
This commit is contained in:
1 parent
d0fe084999
commit
b352c281d5
149 files changed
+12550
-1874
No files matched your search
@@ -50,8 +50,6 @@ export class BusinessError extends Error {
|
||||
* @returns 当前语言的用户可见错误信息
|
||||
*/
|
||||
export function resolveLocalizedErrorMessage(code?: string, fallbackMessage?: string): string {
|
||||
const normalizedCode = code ? code.replace(/\./g, '_') : '';
|
||||
const key = normalizedCode ? `errors.codes.${normalizedCode}` : '';
|
||||
const fallback = String(fallbackMessage || '').trim();
|
||||
const isGenericFallback = (msg: string) => {
|
||||
const v = msg.trim().toLowerCase();
|
||||
@@ -61,21 +59,44 @@ export function resolveLocalizedErrorMessage(code?: string, fallbackMessage?: st
|
||||
if (v.startsWith('http ')) return true;
|
||||
return false;
|
||||
};
|
||||
if (key && i18n.global.te(key)) {
|
||||
const localized = String(i18n.global.t(key));
|
||||
if (normalizedCode === 'VALIDATION_INVALID_PARAM' && fallback && !isGenericFallback(fallback) && fallback !== localized) {
|
||||
return `${localized} ${fallback}`;
|
||||
|
||||
/**
|
||||
* 在 errors.codes 中查找文案:优先字面量键(含点号),再尝试下划线键与路径解析。
|
||||
*/
|
||||
const lookupCodeMessage = (rawCode: string): string | null => {
|
||||
const bag = i18n.global.tm('errors.codes') as Record<string, unknown> | string | null;
|
||||
if (bag && typeof bag === 'object' && !Array.isArray(bag)) {
|
||||
const direct = bag[rawCode];
|
||||
if (typeof direct === 'string' && direct.trim()) return direct;
|
||||
const underscoredLeaf = rawCode.replace(/\./g, '_');
|
||||
const viaUnderscore = bag[underscoredLeaf];
|
||||
if (typeof viaUnderscore === 'string' && viaUnderscore.trim()) return viaUnderscore;
|
||||
}
|
||||
if (
|
||||
normalizedCode === 'AUTH_FORBIDDEN'
|
||||
&& fallback
|
||||
&& !isGenericFallback(fallback)
|
||||
&& fallback.toLowerCase() !== 'forbidden'
|
||||
&& fallback !== localized
|
||||
) {
|
||||
return fallback;
|
||||
const underscoredPath = `errors.codes.${rawCode.replace(/\./g, '_')}`;
|
||||
if (i18n.global.te(underscoredPath)) return String(i18n.global.t(underscoredPath));
|
||||
const dottedPath = `errors.codes.${rawCode}`;
|
||||
if (i18n.global.te(dottedPath)) return String(i18n.global.t(dottedPath));
|
||||
return null;
|
||||
};
|
||||
|
||||
if (code) {
|
||||
const localized = lookupCodeMessage(code);
|
||||
if (localized) {
|
||||
const normalizedCode = code.replace(/\./g, '_');
|
||||
if (normalizedCode === 'VALIDATION_INVALID_PARAM' && fallback && !isGenericFallback(fallback) && fallback !== localized) {
|
||||
return `${localized} ${fallback}`;
|
||||
}
|
||||
if (
|
||||
normalizedCode === 'AUTH_FORBIDDEN'
|
||||
&& fallback
|
||||
&& !isGenericFallback(fallback)
|
||||
&& fallback.toLowerCase() !== 'forbidden'
|
||||
&& fallback !== localized
|
||||
) {
|
||||
return fallback;
|
||||
}
|
||||
return localized;
|
||||
}
|
||||
return localized;
|
||||
}
|
||||
if (fallback) return fallback;
|
||||
if (i18n.global.te('errors.generic')) {
|
||||
|
||||
Reference in new issue
Block a user