收敛押金到期查询
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { query } from '../../db/client.js'
|
import { query } from '../../db/client.js'
|
||||||
|
import type { WorkerDepositUnfreezeRow } from './types.js'
|
||||||
|
|
||||||
/** 汇总仍在等待解冻的押金,供订单详情和实时通知展示。 */
|
/** 汇总仍在等待解冻的押金,供订单详情和实时通知展示。 */
|
||||||
export async function sumPendingUnfreezeByOrderIds(
|
export async function sumPendingUnfreezeByOrderIds(
|
||||||
@@ -22,3 +23,26 @@ export async function sumPendingUnfreezeByOrderIds(
|
|||||||
}
|
}
|
||||||
return totals
|
return totals
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function listDueDepositUnfreezes({
|
||||||
|
limit = 100,
|
||||||
|
workerId = 0,
|
||||||
|
}: { limit?: number; workerId?: number } = {}): Promise<WorkerDepositUnfreezeRow[]> {
|
||||||
|
const params: unknown[] = []
|
||||||
|
let workerClause = ''
|
||||||
|
if (workerId > 0) {
|
||||||
|
params.push(workerId)
|
||||||
|
workerClause = `AND worker_id = $${params.length}`
|
||||||
|
}
|
||||||
|
params.push(limit)
|
||||||
|
const result = await query<WorkerDepositUnfreezeRow>(
|
||||||
|
`
|
||||||
|
SELECT * FROM worker_deposit_unfreezes
|
||||||
|
WHERE status = 'pending' AND unfreeze_at <= NOW() ${workerClause}
|
||||||
|
ORDER BY unfreeze_at ASC
|
||||||
|
LIMIT $${params.length}
|
||||||
|
`,
|
||||||
|
params,
|
||||||
|
)
|
||||||
|
return result.rows
|
||||||
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import { maybeUpgradeWorkerLevelWithClient } from './worker-ranking-repo.js'
|
|||||||
|
|
||||||
export * from './work-order-query-repo.js'
|
export * from './work-order-query-repo.js'
|
||||||
export { sumPendingUnfreezeByOrderIds } from './work-order-deposit-query-repo.js'
|
export { sumPendingUnfreezeByOrderIds } from './work-order-deposit-query-repo.js'
|
||||||
|
export { listDueDepositUnfreezes } from './work-order-deposit-query-repo.js'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
createWorkOrder,
|
createWorkOrder,
|
||||||
@@ -1770,32 +1771,6 @@ export async function deductPendingDepositUnfreeze(input: {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listDueDepositUnfreezes({
|
|
||||||
limit = 100,
|
|
||||||
workerId = 0,
|
|
||||||
}: { limit?: number; workerId?: number } = {}): Promise<WorkerDepositUnfreezeRow[]> {
|
|
||||||
const params: unknown[] = []
|
|
||||||
let workerClause = ''
|
|
||||||
if (workerId > 0) {
|
|
||||||
params.push(workerId)
|
|
||||||
workerClause = `AND worker_id = $${params.length}`
|
|
||||||
}
|
|
||||||
params.push(limit)
|
|
||||||
const result = await query<WorkerDepositUnfreezeRow>(
|
|
||||||
`
|
|
||||||
SELECT *
|
|
||||||
FROM worker_deposit_unfreezes
|
|
||||||
WHERE status = 'pending'
|
|
||||||
AND unfreeze_at <= NOW()
|
|
||||||
${workerClause}
|
|
||||||
ORDER BY unfreeze_at ASC
|
|
||||||
LIMIT $${params.length}
|
|
||||||
`,
|
|
||||||
params,
|
|
||||||
)
|
|
||||||
return result.rows
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function releaseDepositUnfreeze({
|
export async function releaseDepositUnfreeze({
|
||||||
unfreezeId,
|
unfreezeId,
|
||||||
now,
|
now,
|
||||||
|
|||||||
Reference in New Issue
Block a user