删除库存和旧回调管理
This commit is contained in:
@@ -31,58 +31,12 @@ function createTaskFixture(patch = {}) {
|
||||
requires_claim: true,
|
||||
claim_token: '',
|
||||
primary_claim_token_id: null,
|
||||
primary_inventory_item_id: null,
|
||||
last_error: '',
|
||||
context_json: JSON.stringify({
|
||||
inventorySkuCode: 'dnf-cdk-a',
|
||||
primaryRequirement: {
|
||||
roleKey: 'primary_code',
|
||||
credentialType: 'claim_code',
|
||||
},
|
||||
}),
|
||||
context_json: '{}',
|
||||
...patch,
|
||||
}
|
||||
}
|
||||
|
||||
test('syncDeliveryTasksForOrderWithDeps moves paid claim task to waiting inventory when reservation fails', async () => {
|
||||
const updates = []
|
||||
const reserveCalls = []
|
||||
|
||||
const result = await syncDeliveryTasksForOrderWithDeps(paidOrder, orderItems, {
|
||||
listTasksByOrderId: async () => [createTaskFixture()],
|
||||
reserveInventoryForTask: async (payload) => {
|
||||
reserveCalls.push(payload)
|
||||
return null
|
||||
},
|
||||
updateTask: async (taskId, patch) => {
|
||||
updates.push({ taskId, patch })
|
||||
return { id: taskId, ...patch }
|
||||
},
|
||||
nowIso: () => '2026-04-14T12:00:00.000Z',
|
||||
})
|
||||
|
||||
assert.deepEqual(reserveCalls, [
|
||||
{
|
||||
skuCode: 'dnf-cdk-a',
|
||||
taskId: 30,
|
||||
credentialType: 'claim_code',
|
||||
roleKey: 'primary_code',
|
||||
},
|
||||
])
|
||||
assert.deepEqual(updates, [
|
||||
{
|
||||
taskId: 30,
|
||||
patch: {
|
||||
task_status: 'waiting_inventory',
|
||||
inventory_status: 'pending',
|
||||
last_error: '库存不足,等待可用库存凭据',
|
||||
updated_at: '2026-04-14T12:00:00.000Z',
|
||||
},
|
||||
},
|
||||
])
|
||||
assert.equal(result[0]?.task_status, 'waiting_inventory')
|
||||
})
|
||||
|
||||
test('syncDeliveryTasksForOrderWithDeps sends manual dispatch tasks to manual review', async () => {
|
||||
const notifications = []
|
||||
const updates = []
|
||||
@@ -150,7 +104,6 @@ test('syncDeliveryTasksForOrderWithDeps prepares kuaishou cloud task with claim
|
||||
taskId: 30,
|
||||
patch: {
|
||||
task_status: 'pending_binding_prepare',
|
||||
inventory_status: 'not_required',
|
||||
claim_token: 'claim-token',
|
||||
claim_expires_at: '2026-04-15T12:00:00.000Z',
|
||||
user_action_status: 'pending_claim',
|
||||
|
||||
Reference in New Issue
Block a user