管理后台新增打手详情抽屉聚合钱包流水待解冻与订单数据
This commit is contained in:
@@ -46,3 +46,39 @@ export async function listDueDepositUnfreezes({
|
||||
)
|
||||
return result.rows
|
||||
}
|
||||
|
||||
/** 管理端按打手列出全部解冻记录(含未到期与已释放),观察待解冻到账进度。 */
|
||||
export async function listWorkerDepositUnfreezes({
|
||||
workerId,
|
||||
status = '',
|
||||
page = 1,
|
||||
pageSize = 20,
|
||||
}: {
|
||||
workerId: number
|
||||
status?: string
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}): Promise<{ items: WorkerDepositUnfreezeRow[]; total: number }> {
|
||||
const params: unknown[] = [Number(workerId)]
|
||||
const normalizedStatus = String(status || '').trim()
|
||||
let statusClause = ''
|
||||
if (normalizedStatus) {
|
||||
params.push(normalizedStatus)
|
||||
statusClause = ` AND status = $${params.length}`
|
||||
}
|
||||
const totalResult = await query<{ total: number }>(
|
||||
`SELECT COUNT(*)::int AS total FROM worker_deposit_unfreezes WHERE worker_id = $1${statusClause}`,
|
||||
params,
|
||||
)
|
||||
params.push(pageSize, (page - 1) * pageSize)
|
||||
const result = await query<WorkerDepositUnfreezeRow>(
|
||||
`
|
||||
SELECT * FROM worker_deposit_unfreezes
|
||||
WHERE worker_id = $1${statusClause}
|
||||
ORDER BY unfreeze_at DESC, id DESC
|
||||
LIMIT $${params.length - 1} OFFSET $${params.length}
|
||||
`,
|
||||
params,
|
||||
)
|
||||
return { items: result.rows, total: Number(totalResult.rows[0]?.total || 0) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user