修复 lewan 发货后 claim 轮询换号污染绑定与 UID 展示

发货成功时写入 shipped 身份快照,并冻结绑定资源变更;后台 UID 匹配优先使用发货快照,避免误报不一致。
This commit is contained in:
yml2213
2026-07-16 15:52:54 +08:00
parent be7347e600
commit 1216f252de
13 changed files with 384 additions and 11 deletions
@@ -4,7 +4,9 @@ import { createHttpError } from '../../../utils/http.js'
import { nowIso } from '../../../utils/time.js'
import { TASK_STATUS, normalizeTaskStatus } from '../../../domain/task-status.js'
import type { TaskRow } from '../../../types/repository/rows.js'
import { getClaimIdentityFromTask } from '../../claim/claim-identity.js'
import {
buildKuaishouCloudShippedSnapshot,
isIndustryEVoucherTask,
isKuaishouCloudTask,
maskCode,
@@ -148,6 +150,17 @@ export async function dispatchKuaishouCloudFulfillmentTask(
'cloudtentacles 发货成功',
).trim()
const claimIdentity = getClaimIdentityFromTask(synced.task || task)
const shippedSnapshot = buildKuaishouCloudShippedSnapshot({
expectedUid: claimIdentity.expectedUid,
roleId: syncedFlow.binding.roleId || syncedFlow.role.rid,
roleName: syncedFlow.binding.roleName || syncedFlow.role.name,
vnId: syncedFlow.binding.vnId,
vnPhone: syncedFlow.binding.vnPhone,
vnKey: syncedFlow.binding.vnKey,
dispatchedAt: now,
})
const nextContext = {
...syncedTaskContext,
kuaishouCloudFulfillment: {
@@ -169,6 +182,8 @@ export async function dispatchKuaishouCloudFulfillmentTask(
note: dispatchSummary,
items: dispatchResults,
},
// 冻结发货身份:后续 claim 轮询/过期换号不得改写展示与匹配依据
shipped: syncedFlow.shipped || shippedSnapshot,
purchase: {
...syncedFlow.purchase,
usedKnapsack: stockResult.usedKnapsack,
@@ -209,11 +224,15 @@ export async function dispatchKuaishouCloudFulfillmentTask(
skuId: syncedFlow.binding.skuId,
vnId: syncedFlow.binding.vnId,
vnPhoneMasked: maskPhone(syncedFlow.binding.vnPhone),
expectedUid: shippedSnapshot.expectedUid,
roleId: shippedSnapshot.roleId,
roleName: shippedSnapshot.roleName,
sendType: firstDispatchResult.sendType,
note: dispatchSummary,
deliveryItems,
dispatchResults,
stockResult,
shipped: shippedSnapshot,
actor,
},
now,