支持cloudtentacles覆盖规则
This commit is contained in:
@@ -194,3 +194,92 @@ test('syncDeliveryTasksForOrderWithDeps creates kuaishou cloud task from cloudte
|
||||
assert.equal(result[0]?.claim_token, 'claim-token')
|
||||
assert.equal(updates[0]?.patch.claim_token, 'claim-token')
|
||||
})
|
||||
|
||||
test('syncDeliveryTasksForOrderWithDeps keeps override delivery items and quantities', async () => {
|
||||
const createdTasks = []
|
||||
|
||||
const dynamicOrderItems = [
|
||||
{
|
||||
id: 22,
|
||||
order_id: 10,
|
||||
sku_code: '套装1',
|
||||
sku_name: '套装1',
|
||||
quantity: 1,
|
||||
spec_json: '{}',
|
||||
item_snapshot_json: JSON.stringify({
|
||||
matchMode: 'cloudtentacles_override',
|
||||
cloudtentacles: {
|
||||
matchMode: 'cloudtentacles_override',
|
||||
normalizedProductName: '套装1',
|
||||
cloudSkuId: 28,
|
||||
cloudSkuName: '商品A',
|
||||
cloudSourceKeys: ['account-a'],
|
||||
resolvedSourceKey: 'account-a',
|
||||
deliveryItems: [
|
||||
{
|
||||
cloudSkuId: 28,
|
||||
cloudSkuName: '商品A',
|
||||
quantity: 1,
|
||||
},
|
||||
{
|
||||
cloudSkuId: 29,
|
||||
cloudSkuName: '商品B',
|
||||
quantity: 20,
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
},
|
||||
]
|
||||
|
||||
await syncDeliveryTasksForOrderWithDeps(paidOrder, dynamicOrderItems, {
|
||||
listTasksByOrderId: async () => [],
|
||||
getFulfillmentProfileByKey: async () => ({
|
||||
id: 2,
|
||||
profile_key: 'kuaishou_ct_assisted',
|
||||
name: '快手 cloud 履约',
|
||||
executor_key: 'kuaishou_ct_assisted',
|
||||
requires_claim: false,
|
||||
auto_dispatch: false,
|
||||
config_json: '{}',
|
||||
}),
|
||||
createTask: async (input) => {
|
||||
createdTasks.push(input)
|
||||
return {
|
||||
id: 32,
|
||||
order_id: input.orderId,
|
||||
order_item_id: input.orderItemId,
|
||||
task_status: input.taskStatus,
|
||||
executor_key: input.executorKey,
|
||||
requires_claim: input.requiresClaim,
|
||||
claim_token: '',
|
||||
primary_claim_token_id: null,
|
||||
last_error: '',
|
||||
context_json: input.contextJson,
|
||||
}
|
||||
},
|
||||
createTaskClaimToken: async () => ({
|
||||
token: 'claim-token',
|
||||
expired_at: '2026-04-15T12:00:00.000Z',
|
||||
}),
|
||||
updateTask: async (taskId, patch) => ({ id: taskId, ...patch }),
|
||||
nowIso: () => '2026-04-14T12:04:00.000Z',
|
||||
randomId: () => 'DT-OVERRIDE',
|
||||
})
|
||||
|
||||
const context = JSON.parse(createdTasks[0].contextJson)
|
||||
assert.equal(context.kuaishouCloudFulfillment.binding.skuId, 28)
|
||||
assert.equal(context.kuaishouCloudFulfillment.binding.resolvedSourceKey, 'account-a')
|
||||
assert.deepEqual(context.kuaishouCloudFulfillment.deliveryItems, [
|
||||
{
|
||||
cloudSkuId: 28,
|
||||
cloudSkuName: '商品A',
|
||||
quantity: 1,
|
||||
},
|
||||
{
|
||||
cloudSkuId: 29,
|
||||
cloudSkuName: '商品B',
|
||||
quantity: 20,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user