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:
@@ -1,7 +1,11 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import { resolveClaimTokenExpiration, buildSkinClaimUrl } from './claim-service.js'
|
||||
import {
|
||||
buildConfiguredClaimUrl,
|
||||
pickOrderItemClaimTask,
|
||||
resolveClaimTokenExpiration,
|
||||
} from './claim-service.js'
|
||||
|
||||
test('领取链接默认可配置为长期有效', () => {
|
||||
assert.equal(resolveClaimTokenExpiration('2026-08-11T08:00:00.000Z', 0), null)
|
||||
@@ -14,24 +18,69 @@ test('领取链接保留正整数小时的限时配置能力', () => {
|
||||
)
|
||||
})
|
||||
|
||||
test('皮肤领取链接只拼传入基址(去尾斜杠),不读全局 claimBaseUrl', () => {
|
||||
test('配置化领取链接只拼传入基址(去尾斜杠),不读全局 claimBaseUrl', () => {
|
||||
assert.equal(
|
||||
buildSkinClaimUrl('https://x.ngrok-free.app/claim', 'AbC123'),
|
||||
buildConfiguredClaimUrl('https://x.ngrok-free.app/#/claim', 'AbC123'),
|
||||
'https://x.ngrok-free.app/#/claim/AbC123',
|
||||
)
|
||||
assert.equal(
|
||||
buildConfiguredClaimUrl('https://x.ngrok-free.app/claim/', 'AbC123'),
|
||||
'https://x.ngrok-free.app/claim/AbC123',
|
||||
)
|
||||
assert.equal(
|
||||
buildSkinClaimUrl('https://x.ngrok-free.app/claim/', 'AbC123'),
|
||||
'https://x.ngrok-free.app/claim/AbC123',
|
||||
)
|
||||
assert.equal(
|
||||
buildSkinClaimUrl('https://x.ngrok-free.app', 'AbC123'),
|
||||
buildConfiguredClaimUrl('https://x.ngrok-free.app', 'AbC123'),
|
||||
'https://x.ngrok-free.app/AbC123',
|
||||
)
|
||||
})
|
||||
|
||||
test('皮肤领取链接基址/token 缺失返回空串(由调用方决定不发链接、不发消息)', () => {
|
||||
assert.equal(buildSkinClaimUrl('', 'AbC123'), '')
|
||||
assert.equal(buildSkinClaimUrl(undefined, 'AbC123'), '')
|
||||
assert.equal(buildSkinClaimUrl('https://x/claim', ''), '')
|
||||
assert.equal(buildSkinClaimUrl('https://x/claim', null), '')
|
||||
test('配置化领取链接基址/token 缺失返回空串(由调用方决定不发链接、不发消息)', () => {
|
||||
assert.equal(buildConfiguredClaimUrl('', 'AbC123'), '')
|
||||
assert.equal(buildConfiguredClaimUrl(undefined, 'AbC123'), '')
|
||||
assert.equal(buildConfiguredClaimUrl('https://x/claim', ''), '')
|
||||
assert.equal(buildConfiguredClaimUrl('https://x/claim', null), '')
|
||||
})
|
||||
|
||||
test('pickOrderItemClaimTask 取该订单项 task id 最小且带 token 的单元', () => {
|
||||
const picked = pickOrderItemClaimTask(
|
||||
[
|
||||
{ id: 12, order_item_id: 7, claim_token: 'token-12' },
|
||||
{ id: 10, order_item_id: 7, primary_claim_token: 'token-10' },
|
||||
{ id: 9, order_item_id: 7, claim_token: '' },
|
||||
{ id: 11, order_item_id: 8, claim_token: 'token-11' },
|
||||
],
|
||||
7,
|
||||
)
|
||||
|
||||
assert.deepEqual(picked, {
|
||||
taskId: 10,
|
||||
token: 'token-10',
|
||||
taskCount: 3,
|
||||
tokenTaskCount: 2,
|
||||
})
|
||||
})
|
||||
|
||||
test('pickOrderItemClaimTask 区分「有任务但没 token」与「压根没任务」', () => {
|
||||
const withoutToken = pickOrderItemClaimTask(
|
||||
[
|
||||
{ id: 1, order_item_id: 7, claim_token: '' },
|
||||
{ id: 2, order_item_id: 7, claim_token: '' },
|
||||
],
|
||||
7,
|
||||
)
|
||||
assert.equal(withoutToken.taskId, null)
|
||||
assert.equal(withoutToken.token, '')
|
||||
assert.equal(withoutToken.taskCount, 2)
|
||||
assert.equal(withoutToken.tokenTaskCount, 0)
|
||||
|
||||
const empty = { taskId: null, token: '', taskCount: 0, tokenTaskCount: 0 }
|
||||
assert.deepEqual(
|
||||
pickOrderItemClaimTask([{ id: 1, order_item_id: 8, claim_token: 'x' }], 7),
|
||||
empty,
|
||||
)
|
||||
assert.deepEqual(pickOrderItemClaimTask([], 7), empty)
|
||||
assert.deepEqual(pickOrderItemClaimTask(null, 7), empty)
|
||||
assert.deepEqual(
|
||||
pickOrderItemClaimTask([{ id: 1, order_item_id: 7, claim_token: 'x' }], ''),
|
||||
empty,
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user