feat(fulfillment): 固化当前尝试与历史自动化边界
This commit is contained in:
@@ -254,6 +254,7 @@ export async function assignPendingOrderItemChannels(
|
||||
afterId?: number
|
||||
orderItemIds?: number[]
|
||||
includeLocked?: boolean
|
||||
cutoffCreatedAt?: string
|
||||
} = {},
|
||||
): Promise<AssignChannelsResult> {
|
||||
const batchSize = Math.min(5000, Math.max(1, Math.trunc(options.batchSize || 500)))
|
||||
@@ -288,6 +289,12 @@ export async function assignPendingOrderItemChannels(
|
||||
params.push(requestedIds)
|
||||
requestedFilter = `AND oi.id = ANY($${params.length}::bigint[])`
|
||||
}
|
||||
const cutoffCreatedAt = String(options.cutoffCreatedAt || '').trim()
|
||||
let cutoffFilter = ''
|
||||
if (cutoffCreatedAt && Number.isFinite(Date.parse(cutoffCreatedAt))) {
|
||||
params.push(cutoffCreatedAt)
|
||||
cutoffFilter = `AND o.created_at >= $${params.length}::timestamptz`
|
||||
}
|
||||
|
||||
for (let batch = 0; batch < maxBatches; batch += 1) {
|
||||
params[0] = cursor
|
||||
@@ -323,6 +330,7 @@ export async function assignPendingOrderItemChannels(
|
||||
${options.includeLocked ? '' : 'AND oi.fulfillment_locked = FALSE'}
|
||||
AND oi.id > $1
|
||||
${requestedFilter}
|
||||
${cutoffFilter}
|
||||
ORDER BY oi.id
|
||||
LIMIT $2
|
||||
`,
|
||||
|
||||
Reference in New Issue
Block a user