refactor(shipping-notice): 重构货代发货通知状态管理,移除废弃的process_status字段
统一货代发货通知的业务阶段为四个标准阶段:接收解析、订单复核、发货准备、上传完成 设置 ui_state 为前端唯一状态数据源,不再依赖 process_status 驱动业务流程 删除 shipping_notices 表的废弃 process_status 列及对应复合索引,新增数据库迁移脚本 替换全栈代码中所有对 process_status 的引用为生命周期、上传状态等领域字段 更新相关文档、测试用例与前端展示逻辑适配新的状态管理规则
This commit is contained in:
1 parent
6684e7181a
commit
5ef8329bd8
178 files changed
+5091
-1734
No files matched your search
@@ -20,6 +20,7 @@ import type {
|
||||
ShippingProcessingStageNodeStatus,
|
||||
ShippingProcessingStatus,
|
||||
ShippingProcessingWorkItemType,
|
||||
ShippingProcessGateUserSummary,
|
||||
} from '../types/shipping.api.types';
|
||||
|
||||
/**
|
||||
@@ -372,6 +373,7 @@ export function normalizeShippingProcessingProjection(
|
||||
lastActivityAt: readString(item, 'last_activity_at', 'lastActivityAt'),
|
||||
stageNodes: stageNodes?.length ? stageNodes : undefined,
|
||||
currentGate: normalizeGate(item.current_gate ?? item.currentGate),
|
||||
processGate: normalizeProcessGateSummary(item.process_gate ?? item.processGate),
|
||||
availableActions,
|
||||
sourceSummary: {
|
||||
emailSubject: readNullableString(summaryRaw, 'email_subject', 'emailSubject'),
|
||||
@@ -396,6 +398,7 @@ export function normalizeShippingProcessingProjection(
|
||||
retryable:
|
||||
(item.retryable as boolean | undefined) == null ? false : Boolean(item.retryable),
|
||||
primaryAction: normalizePrimaryAction(item.primary_action ?? item.primaryAction),
|
||||
uiState: normalizeProcessingUiState(item.ui_state ?? item.uiState),
|
||||
facts: normalizeFacts(item.facts),
|
||||
userGroup: readNullableString(item, 'user_group', 'userGroup') as ShippingProcessingProjection['userGroup'],
|
||||
aggregateSummary: normalizeAggregateSummary(item.aggregate_summary ?? item.aggregateSummary),
|
||||
@@ -410,6 +413,38 @@ export function normalizeShippingProcessingProjection(
|
||||
};
|
||||
}
|
||||
|
||||
/** 保留后端 Gate 摘要原字段;写操作需要 execution_no 与 evaluation_version,不能降级为展示节点。 */
|
||||
function normalizeProcessGateSummary(raw: unknown): ShippingProcessGateUserSummary | null {
|
||||
if (!raw || typeof raw !== 'object') return null;
|
||||
const item = raw as Record<string, unknown>;
|
||||
return readString(item, 'execution_no', 'executionNo')
|
||||
? item as unknown as ShippingProcessGateUserSummary
|
||||
: null;
|
||||
}
|
||||
|
||||
/** 规范化单项后端 UI 裁决;缺失时返回 undefined 以保留旧响应兼容。 */
|
||||
function normalizeProcessingUiState(raw: unknown): ShippingProcessingProjection['uiState'] {
|
||||
if (!raw || typeof raw !== 'object') return undefined;
|
||||
const state = raw as Record<string, unknown>;
|
||||
const secondaryRaw = state.secondary_actions ?? state.secondaryActions;
|
||||
const secondaryActions = Array.isArray(secondaryRaw)
|
||||
? secondaryRaw
|
||||
.filter((item): item is Record<string, unknown> => Boolean(item && typeof item === 'object'))
|
||||
.map((item) => ({
|
||||
code: readString(item, 'code', 'code'),
|
||||
enabled: item.enabled !== false,
|
||||
}))
|
||||
.filter((item) => Boolean(item.code))
|
||||
: [];
|
||||
return {
|
||||
status: (readString(state, 'status', 'status') || 'running') as NonNullable<ShippingProcessingProjection['userStatus']>,
|
||||
stage: readString(state, 'stage', 'stage'),
|
||||
blocking_reason: normalizeBlockingReason(state.blocking_reason ?? state.blockingReason),
|
||||
primary_action: normalizePrimaryAction(state.primary_action ?? state.primaryAction),
|
||||
secondary_actions: secondaryActions,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 将会话级统一投影响应中的 work_items 规范为数组。
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user