feifei 异步通知
This commit is contained in:
@@ -15,6 +15,7 @@ import type {
|
||||
} from '../types/repository/rows.js'
|
||||
|
||||
type TaskQueryExecutor = (text: string, params?: unknown[]) => Promise<{ rows: unknown[] }>
|
||||
const KUAISHOU_FEIFEI_EXECUTOR_KEY = 'kuaishou_feifei'
|
||||
|
||||
type TaskRuntimeContextRow = {
|
||||
runtime_session_id: string
|
||||
@@ -320,6 +321,40 @@ export async function findTaskByClaimTokenId(claimTokenId: number | string): Pro
|
||||
return result.rows[0] || null
|
||||
}
|
||||
|
||||
export async function findKuaishouFeifeiTaskByOrder(input: {
|
||||
platformOrderNo?: unknown
|
||||
orderNo?: unknown
|
||||
}): Promise<TaskRow | null> {
|
||||
const platformOrderNo = String(input.platformOrderNo || '').trim()
|
||||
const orderNo = String(input.orderNo || '').trim()
|
||||
const params: unknown[] = [KUAISHOU_FEIFEI_EXECUTOR_KEY]
|
||||
const orderFilters: string[] = []
|
||||
|
||||
if (platformOrderNo) {
|
||||
params.push(platformOrderNo)
|
||||
orderFilters.push(`ft.context_json #>> '{kuaishouFeifei,platformOrderNo}' = $${params.length}`)
|
||||
}
|
||||
|
||||
if (orderNo) {
|
||||
params.push(orderNo)
|
||||
orderFilters.push(`ft.context_json #>> '{kuaishouFeifei,orderNo}' = $${params.length}`)
|
||||
}
|
||||
|
||||
if (orderFilters.length === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
const result = await query<TaskRow>(
|
||||
`${buildTaskSelect()}
|
||||
WHERE ft.executor_key = $1
|
||||
AND (${orderFilters.join(' OR ')})
|
||||
ORDER BY ft.id DESC
|
||||
LIMIT 1`,
|
||||
params,
|
||||
)
|
||||
return result.rows[0] || null
|
||||
}
|
||||
|
||||
export async function listTasks({
|
||||
page = 1,
|
||||
pageSize = 20,
|
||||
|
||||
Reference in New Issue
Block a user