refactor(fulfillment): 移除飞飞/乐玩通道,仅保留 affiliate_dash

新单只路由 affiliate_dash(未命中走 manual_dispatch);历史飞飞/乐玩任务保留只读 stub,避免订单重同步失败。同步清理 cloudtentacles 调度、Admin 写路径与相关 env。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yml2213
2026-09-14 17:29:47 +08:00
co-authored by Cursor
parent 0cbcb89dd8
commit b3aad0044c
155 changed files with 661 additions and 23351 deletions
@@ -4,104 +4,27 @@ import test from 'node:test'
import { planFulfillmentTaskForOrderItem } from './planner.js'
import type { OrderItemRow, OrderRow } from '../../types/repository/rows.js'
test('planFulfillmentTaskForOrderItem 为 cloudtentacles 商品生成 kuaishou-lewan 履约计划', async () => {
test('planFulfillmentTaskForOrderItem 为 affiliate-dash 商品生成履约计划', async () => {
const plan = await planFulfillmentTaskForOrderItem({
order: createOrder(),
item: createOrderItem({
sku_code: '荣耀勋章礼包(30个)',
sku_name: '荣耀勋章礼包(30个)',
item_snapshot_json: {
cloudtentacles: {
matchMode: 'cloudtentacles_name',
normalizedProductName: '荣耀勋章礼包(30个)',
cloudSourceKeys: ['account-a'],
cloudSkuId: 74,
cloudSkuName: '荣耀勋章礼包(30个)',
},
},
}),
getProfileByKey: async (profileKey) => ({
id: 9,
profile_key: profileKey,
name: 'kuaishou-lewan 履约',
executor_key: profileKey,
requires_claim: true,
auto_dispatch: true,
}),
})
assert.ok(plan)
assert.equal(plan.executorKey, 'kuaishou_ct_assisted')
assert.equal(plan.requiresClaim, false)
assert.equal(plan.autoDispatch, false)
assert.equal(plan.context.profileKey, 'kuaishou_ct_assisted')
assert.equal(
(plan.context.kuaishouCloudFulfillment as any).binding.resolvedSourceKey,
'account-a',
)
assert.equal((plan.context.kuaishouCloudFulfillment as any).binding.skuId, 74)
assert.equal(plan.context.kuaishouFeifei, null)
})
test('planFulfillmentTaskForOrderItem 为 feifei 商品生成 feifei 履约计划', async () => {
const plan = await planFulfillmentTaskForOrderItem({
order: createOrder(),
item: createOrderItem({
sku_code: 'FF-1001',
sku_name: '测试皮肤',
item_snapshot_json: {
kuaishouFeifei: {
productCode: 'FF-1001',
skuName: '测试皮肤',
matchMode: 'kuaishou_feifei_name',
},
},
}),
getProfileByKey: async (profileKey) => ({
id: 10,
profile_key: profileKey,
name: 'kuaishou-feifei 履约',
executor_key: profileKey,
requires_claim: false,
auto_dispatch: true,
}),
})
assert.ok(plan)
assert.equal(plan.executorKey, 'kuaishou_feifei')
assert.equal(plan.requiresClaim, true)
assert.equal(plan.autoDispatch, false)
assert.equal(plan.context.kuaishouCloudFulfillment, null)
assert.equal((plan.context.kuaishouFeifei as any).productCode, 'FF-1001')
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: '同时命中商品',
sku_code: 'AFF-1001',
sku_name: '幸运币90个',
item_snapshot_json: {
fulfillmentRoute: {
selectedExecutorKey: 'kuaishou_feifei',
selectedExecutorKey: 'affiliate_dash',
},
cloudtentacles: {
cloudSourceKeys: ['account-a'],
cloudSkuId: 74,
cloudSkuName: 'Cloud 商品',
},
kuaishouFeifei: {
productCode: 'FF-ROUTE',
skuName: 'feifei 商品',
matchMode: 'kuaishou_feifei_name',
affiliateDash: {
sku: 'AFF-1001',
skuName: '幸运币90个',
matchMode: 'affiliate_dash_sku_mapping',
},
},
}),
getProfileByKey: async (profileKey) => ({
id: 10,
id: 11,
profile_key: profileKey,
name: '测试履约',
name: 'affiliate-dash 履约',
executor_key: profileKey,
requires_claim: false,
auto_dispatch: true,
@@ -109,9 +32,12 @@ test('planFulfillmentTaskForOrderItem 尊重履约路由选择 feifei', async ()
})
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')
assert.equal(plan.executorKey, 'affiliate_dash')
assert.equal(plan.requiresClaim, true)
assert.equal(plan.autoDispatch, false)
assert.equal(plan.context.profileKey, 'affiliate_dash')
assert.equal((plan.context.affiliateDash as { sku?: string }).sku, 'AFF-1001')
assert.equal((plan.context.affiliateDash as { productName?: string }).productName, '幸运币90个')
})
test('planFulfillmentTaskForOrderItem 支持履约路由转人工', async () => {
@@ -140,8 +66,7 @@ test('planFulfillmentTaskForOrderItem 支持履约路由转人工', async () =>
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)
assert.equal(plan.context.affiliateDash, null)
})
test('planFulfillmentTaskForOrderItem 未命中平台配置时返回 null', async () => {
@@ -149,8 +74,7 @@ test('planFulfillmentTaskForOrderItem 未命中平台配置时返回 null', asyn
order: createOrder(),
item: createOrderItem({
item_snapshot_json: {
cloudtentacles: null,
kuaishouFeifei: null,
affiliateDash: null,
},
}),
getProfileByKey: async () => null,
@@ -159,6 +83,32 @@ test('planFulfillmentTaskForOrderItem 未命中平台配置时返回 null', asyn
assert.equal(plan, null)
})
test('planFulfillmentTaskForOrderItem affiliate 缺 sku 时返回 null', async () => {
const plan = await planFulfillmentTaskForOrderItem({
order: createOrder(),
item: createOrderItem({
item_snapshot_json: {
fulfillmentRoute: {
selectedExecutorKey: 'affiliate_dash',
},
affiliateDash: {
skuName: '无 sku 商品',
},
},
}),
getProfileByKey: async (profileKey) => ({
id: 11,
profile_key: profileKey,
name: 'affiliate-dash 履约',
executor_key: profileKey,
requires_claim: true,
auto_dispatch: false,
}),
})
assert.equal(plan, null)
})
function createOrder(patch: Partial<OrderRow> = {}): OrderRow {
return {
id: 1,