feat(shipping-notice): 新增订单行与字段冲突管理功能,支持字段冲突查询与解决
This commit is contained in:
1 parent
4fbaed2b4c
commit
9da0481fc3
74 files changed
+4861
-375
No files matched your search
@@ -352,10 +352,18 @@ export async function updateWorkspaceShippingNoticeFields(
|
||||
taskNo: string,
|
||||
fields: Partial<ShippingNoticeHeader>,
|
||||
comment?: string,
|
||||
options?: { expectedOrderDataVersion?: number; idempotencyKey?: string },
|
||||
) {
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/update-notice-fields`,
|
||||
jsonPost({ fields, ...(comment ? { comment } : {}) }),
|
||||
jsonPost({
|
||||
fields,
|
||||
...(comment ? { comment } : {}),
|
||||
...(options?.expectedOrderDataVersion != null
|
||||
? { expected_order_data_version: options.expectedOrderDataVersion }
|
||||
: {}),
|
||||
...(options?.idempotencyKey ? { idempotency_key: options.idempotencyKey } : {}),
|
||||
}),
|
||||
);
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
@@ -373,14 +381,73 @@ export async function updateWorkspaceShippingNoticeLine(
|
||||
lineIndex: number,
|
||||
patch: Partial<ShippingNoticeLine> & { quantity?: number },
|
||||
comment?: string,
|
||||
options?: { expectedOrderDataVersion?: number; idempotencyKey?: string },
|
||||
) {
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/update-notice-line`,
|
||||
jsonPost({ line_index: lineIndex, patch, ...(comment ? { comment } : {}) }),
|
||||
jsonPost({
|
||||
line_index: lineIndex,
|
||||
patch,
|
||||
...(comment ? { comment } : {}),
|
||||
...(options?.expectedOrderDataVersion != null
|
||||
? { expected_order_data_version: options.expectedOrderDataVersion }
|
||||
: {}),
|
||||
...(options?.idempotencyKey ? { idempotency_key: options.idempotencyKey } : {}),
|
||||
}),
|
||||
);
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出任务未解决字段冲突。
|
||||
* @param taskNo - 发货任务编号
|
||||
*/
|
||||
export async function listWorkspaceShippingFieldConflicts(taskNo: string) {
|
||||
return requestJson<{
|
||||
task_no: string;
|
||||
order_data_version: number;
|
||||
open_count: number;
|
||||
items: import('@/features/chat/types/shipping.api.types').ShippingFieldConflict[];
|
||||
}>(`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/field-conflicts`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解决字段冲突(keep_existing / take_incoming / custom)。
|
||||
*/
|
||||
export async function resolveWorkspaceShippingFieldConflict(
|
||||
taskNo: string,
|
||||
conflictId: number,
|
||||
payload: {
|
||||
resolution: 'keep_existing' | 'take_incoming' | 'custom' | string;
|
||||
resolvedValue?: string;
|
||||
expectedConflictVersion?: number;
|
||||
expectedOrderDataVersion?: number;
|
||||
reason?: string;
|
||||
idempotencyKey?: string;
|
||||
},
|
||||
) {
|
||||
return requestJson<{
|
||||
conflict: import('@/features/chat/types/shipping.api.types').ShippingFieldConflict;
|
||||
order_data_version: number;
|
||||
open_conflict_count: number;
|
||||
idempotent_replay?: boolean;
|
||||
}>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/field-conflicts/${conflictId}/resolve`,
|
||||
jsonPost({
|
||||
resolution: payload.resolution,
|
||||
...(payload.resolvedValue != null ? { resolved_value: payload.resolvedValue } : {}),
|
||||
...(payload.expectedConflictVersion != null
|
||||
? { expected_conflict_version: payload.expectedConflictVersion }
|
||||
: {}),
|
||||
...(payload.expectedOrderDataVersion != null
|
||||
? { expected_order_data_version: payload.expectedOrderDataVersion }
|
||||
: {}),
|
||||
...(payload.reason ? { reason: payload.reason } : {}),
|
||||
...(payload.idempotencyKey ? { idempotency_key: payload.idempotencyKey } : {}),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为发货通知新增订单行。
|
||||
* @param taskNo - 发货任务编号
|
||||
|
||||
Reference in new issue
Block a user