refactor(fulfillment): 移除飞飞/乐玩通道,仅保留 affiliate_dash
新单只路由 affiliate_dash(未命中走 manual_dispatch);历史飞飞/乐玩任务保留只读 stub,避免订单重同步失败。同步清理 cloudtentacles 调度、Admin 写路径与相关 env。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,25 +6,20 @@ import {
|
||||
resolveFulfillmentRoute,
|
||||
} from './routing-config-service.js'
|
||||
|
||||
test('normalizeFulfillmentRoutingConfig adds channels missing from historical priority configs', () => {
|
||||
test('normalizeFulfillmentRoutingConfig drops retired executors and keeps affiliate_dash default', () => {
|
||||
const config = normalizeFulfillmentRoutingConfig({
|
||||
defaultExecutorPriority: ['kuaishou_ct_assisted', 'kuaishou_feifei'],
|
||||
})
|
||||
|
||||
assert.deepEqual(config.defaultExecutorPriority, [
|
||||
'kuaishou_ct_assisted',
|
||||
'kuaishou_feifei',
|
||||
'affiliate_dash',
|
||||
])
|
||||
assert.deepEqual(config.defaultExecutorPriority, ['affiliate_dash'])
|
||||
assert.deepEqual(Object.keys(config.executors).sort(), ['affiliate_dash', 'manual_dispatch'])
|
||||
assert.equal(config.unmatchedExecutorKey, 'manual_dispatch')
|
||||
})
|
||||
|
||||
test('resolveFulfillmentRoute 总开关关闭后不再回退默认配置,返回未选中', () => {
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '测试商品',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true },
|
||||
{ executorKey: 'kuaishou_feifei', available: true },
|
||||
],
|
||||
candidates: [{ executorKey: 'affiliate_dash', available: true }],
|
||||
config: normalizeFulfillmentRoutingConfig({
|
||||
enabled: false,
|
||||
}),
|
||||
@@ -34,72 +29,59 @@ test('resolveFulfillmentRoute 总开关关闭后不再回退默认配置,返
|
||||
assert.equal(result.reason, '履约路由未启用,自动发货已停止')
|
||||
})
|
||||
|
||||
test('resolveFulfillmentRoute 默认保持 kuaishou-lewan 优先', () => {
|
||||
test('resolveFulfillmentRoute 默认选择 affiliate_dash', () => {
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '测试商品',
|
||||
candidates: [{ executorKey: 'affiliate_dash', available: true }],
|
||||
config: normalizeFulfillmentRoutingConfig({}),
|
||||
})
|
||||
|
||||
assert.equal(result.selectedExecutorKey, 'affiliate_dash')
|
||||
assert.equal(result.reason, '按全局优先级命中')
|
||||
})
|
||||
|
||||
test('resolveFulfillmentRoute affiliate 不可用时回退人工', () => {
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '测试商品',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true },
|
||||
{ executorKey: 'kuaishou_feifei', available: true },
|
||||
{ executorKey: 'affiliate_dash', available: false, reason: '未命中 affiliate-dash sku 映射' },
|
||||
],
|
||||
config: normalizeFulfillmentRoutingConfig({}),
|
||||
})
|
||||
|
||||
assert.equal(result.selectedExecutorKey, 'kuaishou_ct_assisted')
|
||||
assert.equal(result.reason, '按全局优先级命中')
|
||||
})
|
||||
|
||||
test('resolveFulfillmentRoute 全局关闭 kuaishou-lewan 后选择 feifei', () => {
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '测试商品',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true },
|
||||
{ executorKey: 'kuaishou_feifei', available: true },
|
||||
],
|
||||
config: normalizeFulfillmentRoutingConfig({
|
||||
executors: {
|
||||
kuaishou_ct_assisted: { enabled: false },
|
||||
kuaishou_feifei: { enabled: true },
|
||||
},
|
||||
}),
|
||||
})
|
||||
|
||||
assert.equal(result.selectedExecutorKey, 'kuaishou_feifei')
|
||||
assert.equal(result.selectedExecutorKey, 'manual_dispatch')
|
||||
assert.equal(result.reason, '未命中自动履约通道,进入人工履约')
|
||||
assert.deepEqual(result.skipped[0], {
|
||||
executorKey: 'kuaishou_ct_assisted',
|
||||
reason: '履约通道已停用',
|
||||
executorKey: 'affiliate_dash',
|
||||
reason: '未命中 affiliate-dash sku 映射',
|
||||
})
|
||||
})
|
||||
|
||||
test('resolveFulfillmentRoute 商品规则可以强制走 feifei', () => {
|
||||
test('resolveFulfillmentRoute 商品规则可以强制走 affiliate_dash', () => {
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '荣耀套装',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true },
|
||||
{ executorKey: 'kuaishou_feifei', available: true },
|
||||
],
|
||||
candidates: [{ executorKey: 'affiliate_dash', available: true }],
|
||||
config: normalizeFulfillmentRoutingConfig({
|
||||
rules: [
|
||||
{
|
||||
enabled: true,
|
||||
productName: '荣耀套装',
|
||||
executorKey: 'kuaishou_feifei',
|
||||
executorKey: 'affiliate_dash',
|
||||
priority: 200,
|
||||
},
|
||||
],
|
||||
}),
|
||||
})
|
||||
|
||||
assert.equal(result.selectedExecutorKey, 'kuaishou_feifei')
|
||||
assert.equal(result.selectedRuleId, '荣耀套装:kuaishou_feifei')
|
||||
assert.equal(result.selectedExecutorKey, 'affiliate_dash')
|
||||
assert.equal(result.selectedRuleId, '荣耀套装:affiliate_dash')
|
||||
assert.equal(result.reason, '命中商品路由规则')
|
||||
})
|
||||
|
||||
test('resolveFulfillmentRoute 商品规则目标不可用时回退全局优先级', () => {
|
||||
test('resolveFulfillmentRoute 商品规则目标不可用时不再静默改通道', () => {
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '套装-糯粉咩咩',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true },
|
||||
{ executorKey: 'kuaishou_feifei', available: true },
|
||||
{ executorKey: 'affiliate_dash', available: false, reason: '未命中 affiliate-dash sku 映射' },
|
||||
],
|
||||
config: normalizeFulfillmentRoutingConfig({
|
||||
@@ -114,8 +96,8 @@ test('resolveFulfillmentRoute 商品规则目标不可用时回退全局优先
|
||||
}),
|
||||
})
|
||||
|
||||
assert.equal(result.selectedExecutorKey, 'kuaishou_ct_assisted')
|
||||
assert.equal(result.reason, '商品路由规则目标不可用,按全局优先级回退')
|
||||
assert.equal(result.selectedExecutorKey, '')
|
||||
assert.equal(result.reason, '商品路由规则目标通道不可用,且未命中其他履约通道')
|
||||
assert.deepEqual(result.skipped[0], {
|
||||
executorKey: 'affiliate_dash',
|
||||
reason: '未命中 affiliate-dash sku 映射',
|
||||
@@ -125,10 +107,7 @@ test('resolveFulfillmentRoute 商品规则目标不可用时回退全局优先
|
||||
test('resolveFulfillmentRoute 商品规则可以强制转人工', () => {
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '临时停用商品',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true },
|
||||
{ executorKey: 'kuaishou_feifei', available: false },
|
||||
],
|
||||
candidates: [{ executorKey: 'affiliate_dash', available: true }],
|
||||
config: normalizeFulfillmentRoutingConfig({
|
||||
rules: [
|
||||
{
|
||||
@@ -150,11 +129,7 @@ test('resolveFulfillmentRoute 指定匹配(显式映射)最高优先', () =>
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '幸运币90个',
|
||||
preferredExecutorKey: 'affiliate_dash',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true, reason: 'cloud 名字命中' },
|
||||
{ executorKey: 'kuaishou_feifei', available: true, reason: 'feifei 名字命中' },
|
||||
{ executorKey: 'affiliate_dash', available: true },
|
||||
],
|
||||
candidates: [{ executorKey: 'affiliate_dash', available: true }],
|
||||
config: normalizeFulfillmentRoutingConfig({}),
|
||||
})
|
||||
|
||||
@@ -162,15 +137,11 @@ test('resolveFulfillmentRoute 指定匹配(显式映射)最高优先', () =>
|
||||
assert.equal(result.reason, '命中指定匹配(显式映射),优先选择')
|
||||
})
|
||||
|
||||
test('resolveFulfillmentRoute 指定匹配命中但通道停用时回退全局优先级', () => {
|
||||
test('resolveFulfillmentRoute 指定匹配命中但通道停用时回退人工', () => {
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '幸运币90个',
|
||||
preferredExecutorKey: 'affiliate_dash',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true },
|
||||
{ executorKey: 'kuaishou_feifei', available: true },
|
||||
{ executorKey: 'affiliate_dash', available: true },
|
||||
],
|
||||
candidates: [{ executorKey: 'affiliate_dash', available: true }],
|
||||
config: normalizeFulfillmentRoutingConfig({
|
||||
executors: {
|
||||
affiliate_dash: { enabled: false },
|
||||
@@ -178,23 +149,21 @@ test('resolveFulfillmentRoute 指定匹配命中但通道停用时回退全局
|
||||
}),
|
||||
})
|
||||
|
||||
assert.equal(result.selectedExecutorKey, 'kuaishou_ct_assisted')
|
||||
assert.equal(result.selectedExecutorKey, 'manual_dispatch')
|
||||
assert.ok(result.skipped.some((item) => item.executorKey === 'affiliate_dash'))
|
||||
})
|
||||
|
||||
test('resolveFulfillmentRoute 指定匹配命中但商品不可用时回退全局优先级', () => {
|
||||
test('resolveFulfillmentRoute 指定匹配命中但商品不可用时回退人工', () => {
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '幸运币90个',
|
||||
preferredExecutorKey: 'affiliate_dash',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true },
|
||||
{ executorKey: 'kuaishou_feifei', available: false },
|
||||
{ executorKey: 'affiliate_dash', available: false, reason: '未命中 sku 映射' },
|
||||
],
|
||||
config: normalizeFulfillmentRoutingConfig({}),
|
||||
})
|
||||
|
||||
assert.equal(result.selectedExecutorKey, 'kuaishou_ct_assisted')
|
||||
assert.equal(result.selectedExecutorKey, 'manual_dispatch')
|
||||
assert.ok(result.skipped.some((item) => item.executorKey === 'affiliate_dash'))
|
||||
})
|
||||
|
||||
@@ -202,14 +171,10 @@ test('resolveFulfillmentRoute 无指定匹配时按全局优先级选择', () =>
|
||||
const result = resolveFulfillmentRoute({
|
||||
productName: '幸运币90个',
|
||||
preferredExecutorKey: '',
|
||||
candidates: [
|
||||
{ executorKey: 'kuaishou_ct_assisted', available: true },
|
||||
{ executorKey: 'kuaishou_feifei', available: false },
|
||||
{ executorKey: 'affiliate_dash', available: true },
|
||||
],
|
||||
candidates: [{ executorKey: 'affiliate_dash', available: true }],
|
||||
config: normalizeFulfillmentRoutingConfig({}),
|
||||
})
|
||||
|
||||
assert.equal(result.selectedExecutorKey, 'kuaishou_ct_assisted')
|
||||
assert.equal(result.selectedExecutorKey, 'affiliate_dash')
|
||||
assert.equal(result.reason, '按全局优先级命中')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user