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
@@ -116,7 +116,11 @@ export function createShippingActionsRefresher(ctx: ShippingRefreshContext) {
|
||||
// keep existing SSE-delivered ui_state if present
|
||||
}
|
||||
}
|
||||
const apiCheckpoint = apiState?.checkpoint ? String(apiState.checkpoint) : null;
|
||||
const apiCheckpoint = String(
|
||||
apiState?.checkpoint?.code
|
||||
|| apiState?.checkpoint_code
|
||||
|| '',
|
||||
).trim() || null;
|
||||
if (apiResolved && apiCheckpoint && SHIPPING_TERMINAL_CHECKPOINTS.has(apiCheckpoint)) {
|
||||
msgs.forEach((rawMsg) => {
|
||||
const m = rawMsg as ChatMessage;
|
||||
@@ -140,20 +144,36 @@ export function createShippingActionsRefresher(ctx: ShippingRefreshContext) {
|
||||
let cleanedText = stripShippingPlainActionMenu(String(chatMsg.content || ''));
|
||||
if (index === targetAssistantIndex && apiState) {
|
||||
chatMsg.shipping_ui_state = apiState;
|
||||
if (apiState.action_buttons?.length) {
|
||||
cleanedText = stripShippingActionListByButtons(cleanedText, apiState.action_buttons);
|
||||
const projectedActions = [apiState.actions?.primary, ...(apiState.actions?.secondary || [])]
|
||||
.filter(Boolean)
|
||||
.map((action) => ({
|
||||
id: String(action?.code || ''),
|
||||
label: String(action?.label || ''),
|
||||
message: String(action?.disabled_reason || ''),
|
||||
variant: action?.kind === 'terminate' ? 'danger' : 'primary',
|
||||
}));
|
||||
if (projectedActions.length) {
|
||||
cleanedText = stripShippingActionListByButtons(cleanedText, projectedActions);
|
||||
}
|
||||
} else if (!apiResolved && chatMsg.shipping_ui_state?.action_buttons?.length) {
|
||||
} else if (!apiResolved && chatMsg.shipping_ui_state?.actions) {
|
||||
const projectedActions = [chatMsg.shipping_ui_state.actions.primary, ...(chatMsg.shipping_ui_state.actions.secondary || [])]
|
||||
.filter(Boolean)
|
||||
.map((action) => ({
|
||||
id: String(action?.code || ''),
|
||||
label: String(action?.label || ''),
|
||||
message: String(action?.disabled_reason || ''),
|
||||
variant: action?.kind === 'terminate' ? 'danger' : 'primary',
|
||||
}));
|
||||
cleanedText = stripShippingActionListByButtons(
|
||||
cleanedText,
|
||||
chatMsg.shipping_ui_state.action_buttons,
|
||||
projectedActions,
|
||||
);
|
||||
}
|
||||
if (cleanedText !== String(chatMsg.content || '').trim()) {
|
||||
chatMsg.content = cleanedText;
|
||||
}
|
||||
if (chatMsg.type === 'shipping-match-result' && chatMsg.payload && typeof chatMsg.payload === 'object') {
|
||||
(chatMsg.payload as { action_buttons?: unknown[] }).action_buttons = [];
|
||||
delete (chatMsg.payload as { action_buttons?: unknown[] }).action_buttons;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user