打手列表新增VIP等级筛选

This commit is contained in:
yml2213
2026-08-23 16:21:39 +08:00
parent 3df271b30c
commit b49fa12484
4 changed files with 38 additions and 2 deletions
@@ -420,6 +420,8 @@ export type ListInput = {
workerType?: string
/** 后台打手列表按主键精确定位。 */
workerId?: number
/** 后台打手列表按 VIP 等级筛选。 */
levelId?: number
/** 后台待验收筛选:普通单按接单人,拼单按参与打手等级。 */
workerLevelIds?: number[]
categoryId?: number
@@ -236,8 +236,15 @@ export async function listWorkerUsers({
keyword = '',
workerType = '',
workerId = 0,
levelId = 0,
}: ListInput = {}): Promise<{ items: WorkerUserRow[]; total: number }> {
const { whereClause, params } = buildWorkerUserWhere({ status, keyword, workerType, workerId })
const { whereClause, params } = buildWorkerUserWhere({
status,
keyword,
workerType,
workerId,
levelId,
})
const totalResult = await query<{ total: number }>(
`SELECT COUNT(*)::int AS total FROM worker_users wu ${whereClause}`,
params,
@@ -299,7 +306,8 @@ function buildWorkerUserWhere({
keyword = '',
workerType = '',
workerId = 0,
}: Pick<ListInput, 'status' | 'keyword' | 'workerType' | 'workerId'>) {
levelId = 0,
}: Pick<ListInput, 'status' | 'keyword' | 'workerType' | 'workerId' | 'levelId'>) {
const filters: string[] = []
const params: unknown[] = []
if (status) {
@@ -320,6 +328,10 @@ function buildWorkerUserWhere({
params.push(workerId)
filters.push(`wu.id = $${params.length}`)
}
if (levelId) {
params.push(levelId)
filters.push(`wu.level_id = $${params.length}`)
}
return {
whereClause: filters.length > 0 ? `WHERE ${filters.join(' AND ')}` : '',
params,