接单工单支持置顶,抢单大厅优先展示

- 新增 work_orders.pinned_at 字段与迁移
- 管理端对已发布(待抢单)订单提供置顶/取消置顶操作,置顶订单带标记
- 抢单大厅按置顶时间优先排序,打手端卡片展示置顶标签
This commit is contained in:
yml2213
2026-08-16 15:57:25 +08:00
parent 737f9ddcbe
commit 8d07b06d52
12 changed files with 121 additions and 11 deletions
@@ -177,6 +177,7 @@ export type WorkOrderRow = {
sharing_total_quantity: number
sharing_unit_reward: number
published_at: string | null
pinned_at: string | null
assigned_at: string | null
submitted_at: string | null
accepted_at: string | null
@@ -218,6 +219,8 @@ export type ListInput = {
categoryId?: number
workerSharingId?: number
visibleAfterIso?: string
/** 置顶订单优先展示(抢单大厅使用) */
pinnedFirst?: boolean
sort?: 'id_desc' | 'worker_claimed_at_desc'
}
@@ -744,6 +744,7 @@ export async function listWorkOrders({
categoryId = 0,
workerSharingId = 0,
visibleAfterIso = '',
pinnedFirst = false,
sort = 'id_desc',
}: ListInput = {}): Promise<{ items: WorkOrderRow[]; total: number }> {
const effectiveStatuses =
@@ -786,11 +787,14 @@ export async function listWorkOrders({
) DESC NULLS LAST, wo.id DESC`
})()
: 'wo.id DESC'
const effectiveOrderBy = pinnedFirst
? `wo.pinned_at DESC NULLS LAST, ${orderBy}`
: orderBy
params.push(pageSize, offset)
const itemsResult = await query<WorkOrderRow>(
`${WORK_ORDER_SELECT}
${whereClause}
ORDER BY ${orderBy}
ORDER BY ${effectiveOrderBy}
LIMIT $${params.length - 1} OFFSET $${params.length}`,
params,
)
@@ -813,6 +817,7 @@ export async function updateWorkOrder(
| 'sharing_total_quantity'
| 'sharing_unit_reward'
| 'published_at'
| 'pinned_at'
| 'assigned_at'
| 'submitted_at'
| 'accepted_at'
@@ -838,11 +843,12 @@ export async function updateWorkOrder(
sharing_total_quantity = $9,
sharing_unit_reward = $10,
published_at = $11,
assigned_at = $12,
submitted_at = $13,
accepted_at = $14,
updated_at = $15
WHERE id = $16
pinned_at = $12,
assigned_at = $13,
submitted_at = $14,
accepted_at = $15,
updated_at = $16
WHERE id = $17
`,
[
next.status,
@@ -856,6 +862,7 @@ export async function updateWorkOrder(
toPositiveInteger(next.sharing_total_quantity, 1),
toPositiveInteger(next.sharing_unit_reward, 0),
next.published_at || null,
next.pinned_at || null,
next.assigned_at || null,
next.submitted_at || null,
next.accepted_at || null,