refactor(douyin-mashida)!: 纠偏——删掉自建的皮肤通道,改回复用 affiliate_dash

上一轮我把皮肤交付做成了「另建一套执行器 + 独立领取接口 + 只提交账号就结束」,
跟买家实际要走的过程不一致(真正的完成信号是「扫码绑定后的 UID == 买家填的 UID」),
而且核销还触发了老通知逻辑,给买家**又发了一条 /redeem** —— 买家收到两条链接。
本次按用户要求改回**完全复用仓库现成的 affiliate_dash 通道**(= 旧的快手皮肤自动发货)。

**删掉**
- 执行器 `douyin_mashida_skin`(含 registry/types/planner/bootstrap/路由白名单注册)
- `services/claim/claim-skin-service.ts`、`routes/claim-skin.ts`、`/api/v1/claim-skin` 挂载
- 迁移 096 的 `claim_submission_json` 全链路(task-repo / rows / inputs / task-detail /
  admin-read-service 的 claimSubmission),并新增 **097 兜底迁移**把该列 DROP 掉
- 顺带清掉上一轮专为已删接口加的死代码(utils/http.ts 的 buildMessageSuccessPayload 等)

**改回复用**
- `resolveOrderItemClaimLink`:通用解析(只看订单项、不看执行器)→
  `buildConfiguredClaimUrl(claimLinkBase, token)`;多履约单元取 task id 最小并告警;
  **绝不回退** hash 形态的 `buildClaimUrl`
- `cert_link` 与付款后那条**唯一**消息共用同一个解析结果
- **核销后不再给抖音买家发第二条消息**(`shouldNotifyBuyerAfterVerify` 只放行非抖音 provider)
- 买家侧走既有流程:输 UID → 二维码 → 扫码绑定 → 比对 UID → delivered/REDEEMED;
  在 delivered 分支 best-effort 核销平台券(幂等、失败只 warn,不拖慢买家响应)
- 后台回显链接改按 **order.provider** 判断(抖音用 `claimLinkBase`)

**SQL 守卫**:允许「删除历史迁移」,但强制要求「同时新增兜底迁移」配对
(修改历史迁移仍禁止),并把改动来源换成 `git status --porcelain`(否则未跟踪的新迁移看不见)

`npm run check`:tests 671 / pass 668 / fail 0 / skipped 3(含新增的物品图回退用例)
This commit is contained in:
yml2213
2026-10-09 16:13:39 +08:00
parent 56ad06239b
commit 4fce07a621
37 changed files with 590 additions and 1300 deletions
@@ -12,11 +12,7 @@ test('normalizeFulfillmentRoutingConfig drops retired executors and keeps affili
})
assert.deepEqual(config.defaultExecutorPriority, ['affiliate_dash'])
assert.deepEqual(Object.keys(config.executors).sort(), [
'affiliate_dash',
'douyin_mashida_skin',
'manual_dispatch',
])
assert.deepEqual(Object.keys(config.executors).sort(), ['affiliate_dash', 'manual_dispatch'])
assert.equal(config.unmatchedExecutorKey, 'manual_dispatch')
})
@@ -186,7 +182,7 @@ test('normalizeFulfillmentRoutingConfig 支持按内部 SKU 的规则维度', ()
rules: [
{
internalSku: '幸运币2个',
executorKey: 'douyin_mashida_skin',
executorKey: 'affiliate_dash',
priority: 500,
},
],
@@ -201,7 +197,7 @@ test('normalizeFulfillmentRoutingConfig 支持按内部 SKU 的规则维度', ()
assert.equal(rule.normalizedProductName, '')
assert.equal(rule.internalSku, '幸运币2个')
assert.equal(rule.normalizedInternalSku, '幸运币2个')
assert.equal(rule.id, '幸运币2个:douyin_mashida_skin')
assert.equal(rule.id, '幸运币2个:affiliate_dash')
})
test('旧商品名规则归一化后带 matchField=product_name,语义不变', () => {
@@ -221,13 +217,13 @@ test('resolveFulfillmentRoute 命中内部 SKU 规则', () => {
const result = resolveFulfillmentRoute({
productName: '【测试专用】和平精英皮肤小店入口',
internalSku: '幸运币2个',
candidates: [{ executorKey: 'douyin_mashida_skin', available: true }],
candidates: [{ executorKey: 'affiliate_dash', available: true }],
config: normalizeFulfillmentRoutingConfig({
rules: [{ internalSku: '幸运币2个', executorKey: 'douyin_mashida_skin', priority: 500 }],
rules: [{ internalSku: '幸运币2个', executorKey: 'affiliate_dash', priority: 500 }],
}),
})
assert.equal(result.selectedExecutorKey, 'douyin_mashida_skin')
assert.equal(result.selectedExecutorKey, 'affiliate_dash')
assert.equal(result.reason, '命中商品路由规则')
assert.equal(result.matchedRule?.productName, '幸运币2个')
})
@@ -238,7 +234,7 @@ test('resolveFulfillmentRoute 内部 SKU 规则支持归一化与 contains', ()
{
internalSku: '幸运币',
matchType: 'contains',
executorKey: 'douyin_mashida_skin',
executorKey: 'affiliate_dash',
priority: 500,
},
],
@@ -247,15 +243,15 @@ test('resolveFulfillmentRoute 内部 SKU 规则支持归一化与 contains', ()
const exactFullWidth = resolveFulfillmentRoute({
productName: '',
internalSku: ' 幸运币2个 ',
candidates: [{ executorKey: 'douyin_mashida_skin', available: true }],
candidates: [{ executorKey: 'affiliate_dash', available: true }],
config,
})
assert.equal(exactFullWidth.selectedExecutorKey, 'douyin_mashida_skin')
assert.equal(exactFullWidth.selectedExecutorKey, 'affiliate_dash')
const miss = resolveFulfillmentRoute({
productName: '',
internalSku: '荣耀勋章2个',
candidates: [{ executorKey: 'douyin_mashida_skin', available: true }],
candidates: [],
config,
})
assert.equal(miss.selectedExecutorKey, 'manual_dispatch')
@@ -269,7 +265,7 @@ test('resolveFulfillmentRoute 未命中内部 SKU 规则时商品名规则仍然
config: normalizeFulfillmentRoutingConfig({
rules: [
{ productName: '荣耀套装', executorKey: 'affiliate_dash', priority: 200 },
{ internalSku: '幸运币2个', executorKey: 'douyin_mashida_skin', priority: 900 },
{ internalSku: '幸运币2个', executorKey: 'affiliate_dash', priority: 900 },
],
}),
})