清理旧消息和历史命名

This commit is contained in:
yml
2026-05-25 22:03:07 +08:00
parent e7aa194dde
commit 0caa38e690
41 changed files with 63 additions and 1044 deletions
@@ -5,8 +5,8 @@ import { syncDeliveryTasksForOrderWithDeps } from './delivery-task-service.js'
const paidOrder = {
id: 10,
provider: 'agiso',
platform: 'xianyu',
provider: '91kaquan',
platform: 'kuaishou',
shop_id: 'shop-1',
shop_name: '测试店铺',
platform_order_id: 'P10001',
@@ -27,7 +27,7 @@ function createTaskFixture(patch = {}) {
id: 30,
order_item_id: 20,
task_status: 'paid',
executor_key: 'tencent_claim_assisted',
executor_key: 'claim_link_dispatch',
requires_claim: true,
claim_token: '',
primary_claim_token_id: null,
@@ -48,16 +48,6 @@ type SourceOrderEvent = {
type UpsertOrderSourceOptions = {
sourceLabel?: string
handleClaimLinkTask?: (input: {
event: SourceOrderEvent
order: OrderRow
task: TaskRow
}) => Promise<Record<string, unknown> | null | undefined>
}
type MessageDeliveryResult = {
taskId: number
[key: string]: unknown
}
type UpsertOrderIgnoredResult = {
@@ -66,7 +56,6 @@ type UpsertOrderIgnoredResult = {
order: null
orderItems: []
tasks: []
messageDeliveries: []
}
type UpsertOrderResult = {
@@ -75,7 +64,6 @@ type UpsertOrderResult = {
order: OrderRow
orderItems: OrderItemRow[]
tasks: TaskRow[]
messageDeliveries: MessageDeliveryResult[]
} | UpsertOrderIgnoredResult
type OrderStateInput = {
@@ -101,7 +89,7 @@ export async function upsertOrderFromWebhook(event: SourceOrderEvent): Promise<U
export async function upsertOrderFromSource(
event: SourceOrderEvent,
{ sourceLabel = 'source', handleClaimLinkTask }: UpsertOrderSourceOptions = {},
{ sourceLabel = 'source' }: UpsertOrderSourceOptions = {},
): Promise<UpsertOrderResult> {
const now = nowIso()
const exactExisting = await findOrderByPlatformOrderId({
@@ -154,7 +142,6 @@ export async function upsertOrderFromSource(
order: null,
orderItems: [],
tasks: [],
messageDeliveries: [],
}
}
@@ -207,7 +194,6 @@ export async function upsertOrderFromSource(
)
const tasks = await syncDeliveryTasksForOrder(order, orderItems)
const messageDeliveries: MessageDeliveryResult[] = []
logWebhook('[order-service]', `${sourceLabel} 订单 upsert 完成`, {
orderId: order.id,
@@ -221,35 +207,10 @@ export async function upsertOrderFromSource(
resolvedSkuCodes: configuredItems.map((item) => item.skuCode),
})
if (handleClaimLinkTask) {
for (const task of tasks) {
const isClaimLinkTask = String(task.task_status || '') === 'link_generated'
|| (
String(task.executor_key || '').trim() === 'kuaishou_ct_assisted'
&& ['pending_binding_prepare', 'waiting_binding', 'role_confirmed', 'dispatched_pending_return'].includes(String(task.task_status || '').trim())
)
if (!isClaimLinkTask || !task.primary_claim_token_id) {
continue
}
const result = await handleClaimLinkTask({ event, order, task })
if (!result) {
continue
}
messageDeliveries.push({
taskId: task.id,
...result,
})
}
}
return {
order,
orderItems,
tasks,
messageDeliveries,
}
}