优化履约路由并重命名乐玩通道
This commit is contained in:
@@ -4,7 +4,7 @@ import test from 'node:test'
|
||||
import { planFulfillmentTaskForOrderItem } from './planner.js'
|
||||
import type { OrderItemRow, OrderRow } from '../../types/repository/rows.js'
|
||||
|
||||
test('planFulfillmentTaskForOrderItem 为 cloudtentacles 商品生成 cloud 履约计划', async () => {
|
||||
test('planFulfillmentTaskForOrderItem 为 cloudtentacles 商品生成 kuaishou-lewan 履约计划', async () => {
|
||||
const plan = await planFulfillmentTaskForOrderItem({
|
||||
order: createOrder(),
|
||||
item: createOrderItem({
|
||||
@@ -23,7 +23,7 @@ test('planFulfillmentTaskForOrderItem 为 cloudtentacles 商品生成 cloud 履
|
||||
getProfileByKey: async (profileKey) => ({
|
||||
id: 9,
|
||||
profile_key: profileKey,
|
||||
name: '快手 cloud 履约',
|
||||
name: 'kuaishou-lewan 履约',
|
||||
executor_key: profileKey,
|
||||
requires_claim: true,
|
||||
auto_dispatch: true,
|
||||
@@ -76,6 +76,74 @@ test('planFulfillmentTaskForOrderItem 为 feifei 商品生成 feifei 履约计
|
||||
assert.equal((plan.context.kuaishouFeifei as any).productName, '测试皮肤')
|
||||
})
|
||||
|
||||
test('planFulfillmentTaskForOrderItem 尊重履约路由选择 feifei', async () => {
|
||||
const plan = await planFulfillmentTaskForOrderItem({
|
||||
order: createOrder(),
|
||||
item: createOrderItem({
|
||||
sku_code: 'FF-ROUTE',
|
||||
sku_name: '同时命中商品',
|
||||
item_snapshot_json: {
|
||||
fulfillmentRoute: {
|
||||
selectedExecutorKey: 'kuaishou_feifei',
|
||||
},
|
||||
cloudtentacles: {
|
||||
cloudSourceKeys: ['account-a'],
|
||||
cloudSkuId: 74,
|
||||
cloudSkuName: 'Cloud 商品',
|
||||
},
|
||||
kuaishouFeifei: {
|
||||
productCode: 'FF-ROUTE',
|
||||
skuName: 'feifei 商品',
|
||||
matchMode: 'kuaishou_feifei_name',
|
||||
},
|
||||
},
|
||||
}),
|
||||
getProfileByKey: async (profileKey) => ({
|
||||
id: 10,
|
||||
profile_key: profileKey,
|
||||
name: '测试履约',
|
||||
executor_key: profileKey,
|
||||
requires_claim: false,
|
||||
auto_dispatch: true,
|
||||
}),
|
||||
})
|
||||
|
||||
assert.ok(plan)
|
||||
assert.equal(plan.executorKey, 'kuaishou_feifei')
|
||||
assert.equal(plan.context.kuaishouCloudFulfillment, null)
|
||||
assert.equal((plan.context.kuaishouFeifei as any).productCode, 'FF-ROUTE')
|
||||
})
|
||||
|
||||
test('planFulfillmentTaskForOrderItem 支持履约路由转人工', async () => {
|
||||
const plan = await planFulfillmentTaskForOrderItem({
|
||||
order: createOrder(),
|
||||
item: createOrderItem({
|
||||
sku_code: 'MANUAL-1',
|
||||
sku_name: '人工商品',
|
||||
item_snapshot_json: {
|
||||
fulfillmentRoute: {
|
||||
selectedExecutorKey: 'manual_dispatch',
|
||||
},
|
||||
},
|
||||
}),
|
||||
getProfileByKey: async (profileKey) => ({
|
||||
id: 1,
|
||||
profile_key: profileKey,
|
||||
name: '人工发货',
|
||||
executor_key: 'manual_dispatch',
|
||||
requires_claim: true,
|
||||
auto_dispatch: true,
|
||||
}),
|
||||
})
|
||||
|
||||
assert.ok(plan)
|
||||
assert.equal(plan.executorKey, 'manual_dispatch')
|
||||
assert.equal(plan.requiresClaim, false)
|
||||
assert.equal(plan.autoDispatch, false)
|
||||
assert.equal(plan.context.kuaishouCloudFulfillment, null)
|
||||
assert.equal(plan.context.kuaishouFeifei, null)
|
||||
})
|
||||
|
||||
test('planFulfillmentTaskForOrderItem 未命中平台配置时返回 null', async () => {
|
||||
const plan = await planFulfillmentTaskForOrderItem({
|
||||
order: createOrder(),
|
||||
|
||||
Reference in New Issue
Block a user