优化订单打手信息展示

This commit is contained in:
yml2213
2026-08-21 11:49:42 +08:00
parent db2a401e33
commit 993ddcd034
8 changed files with 192 additions and 42 deletions
@@ -338,6 +338,7 @@ export type ListInput = {
keyword?: string
/** 打手类型筛选:internal 内部打手 / external 外部打手 */
workerType?: string
/** 后台打手列表按主键精确定位。 */
workerId?: number
/** 后台待验收筛选:普通单按接单人,拼单按参与打手等级。 */
workerLevelIds?: number[]
@@ -483,8 +483,9 @@ export async function listWorkerUsers({
status = '',
keyword = '',
workerType = '',
workerId = 0,
}: ListInput = {}): Promise<{ items: WorkerUserRow[]; total: number }> {
const { whereClause, params } = buildWorkerUserWhere({ status, keyword, workerType })
const { whereClause, params } = buildWorkerUserWhere({ status, keyword, workerType, workerId })
const totalResult = await query<{ total: number }>(
`SELECT COUNT(*)::int AS total FROM worker_users wu ${whereClause}`,
params,
@@ -1257,7 +1258,8 @@ function buildWorkerUserWhere({
status = '',
keyword = '',
workerType = '',
}: Pick<ListInput, 'status' | 'keyword' | 'workerType'>) {
workerId = 0,
}: Pick<ListInput, 'status' | 'keyword' | 'workerType' | 'workerId'>) {
const filters: string[] = []
const params: unknown[] = []
if (status) {
@@ -1274,6 +1276,10 @@ function buildWorkerUserWhere({
params.push(workerType)
filters.push(`wu.worker_type = $${params.length}`)
}
if (workerId) {
params.push(workerId)
filters.push(`wu.id = $${params.length}`)
}
return {
whereClause: filters.length > 0 ? `WHERE ${filters.join(' AND ')}` : '',
params,