优化快手云领取发货校验

This commit is contained in:
yml2213
2026-05-26 16:24:50 +08:00
parent 604f1bbf54
commit dfcc8982c6
5 changed files with 331 additions and 26 deletions
@@ -19,6 +19,7 @@ import {
type JsonObject,
} from "./domain.js";
import { resolvePersistedCloudtentaclesContextBySourceKeys } from "./cloudtentacles-context.js";
import { syncKuaishouCloudRoleInfoBeforeDispatch } from "./dispatch-role-sync.js";
import { normalizeActor, parseTaskContext } from "./task-context.js";
import type { TaskRow } from "../../../types/repository/rows.js";
@@ -68,25 +69,36 @@ export async function dispatchKuaishouCloudFulfillmentTask(
return { task, flow };
}
const synced = await syncKuaishouCloudRoleInfoBeforeDispatch(task, {
now,
actor,
source: options.source || "system_before_dispatch",
cloudContext,
taskContext,
flow,
});
const syncedFlow = synced.flow;
const syncedTaskContext = synced.taskContext;
const dispatchResult = await useCloudtentaclesSku({
...cloudContext,
id: flow.binding.skuId,
virtualNumberId: flow.binding.vnId,
phone: flow.binding.vnPhone,
id: syncedFlow.binding.skuId,
virtualNumberId: syncedFlow.binding.vnId,
phone: syncedFlow.binding.vnPhone,
});
const nextContext = {
...taskContext,
...syncedTaskContext,
kuaishouCloudFulfillment: {
...flow,
...syncedFlow,
ticket: {
...flow.ticket,
...syncedFlow.ticket,
code: ticketCode || persistedTicketCode,
capturedAt: ticketCode ? now : flow.ticket.capturedAt,
capturedBy: ticketCode && actor ? actor : flow.ticket.capturedBy,
capturedAt: ticketCode ? now : syncedFlow.ticket.capturedAt,
capturedBy: ticketCode && actor ? actor : syncedFlow.ticket.capturedBy,
},
dispatch: {
...flow.dispatch,
...syncedFlow.dispatch,
status: "success",
dispatchAt: now,
dispatchBy: actor,
@@ -127,9 +139,9 @@ export async function dispatchKuaishouCloudFulfillmentTask(
{
source: String(options.source || "system").trim() || "system",
ticketCodeMasked: maskCode(ticketCode || persistedTicketCode),
skuId: flow.binding.skuId,
vnId: flow.binding.vnId,
vnPhoneMasked: maskPhone(flow.binding.vnPhone),
skuId: syncedFlow.binding.skuId,
vnId: syncedFlow.binding.vnId,
vnPhoneMasked: maskPhone(syncedFlow.binding.vnPhone),
sendType: dispatchResult.sendType,
note: dispatchResult.note,
actor,