feat(worker-platform): 实现打手寄卖白名单权限控制与存量发布打手平滑过渡
1. 新增数据库迁移 082_worker_consignment_whitelist.sql,worker_users 表增加 can_consign 与 consignment_activated_at 字段,存量在 consignment_submissions 提报过的打手默认自动开启; 2. 打手端提报接口 publishWorkerConsignment 增加白名单权限服务端强校验拦截(403 consignment_permission_required); 3. 管理后台打手管理表格增加「寄卖权限」实时 Switch 开关列与打手详情抽屉权限展示,支持客服即时开通或关闭打手寄卖权限; 4. 打手端我要寄卖页面在未开通权限时展示专属白名单引导卡片,一键呼起联系客服开通寄卖弹窗; 5. 补充寄卖权限拦截与路由单测,前端59项单测与后端507项单测全部通过。
This commit is contained in:
@@ -45,6 +45,8 @@ export type WorkerUserRow = {
|
||||
is_withdrawal_blacklisted?: boolean
|
||||
withdrawal_blacklist_reason?: string | null
|
||||
withdrawal_blacklisted_at?: string | null
|
||||
can_consign?: boolean
|
||||
consignment_activated_at?: string | null
|
||||
}
|
||||
|
||||
export type WorkerUserStatistics = {
|
||||
|
||||
@@ -478,3 +478,29 @@ export async function consumeWorkerRenameCard(input: {
|
||||
}
|
||||
return getWorkerUserById(input.workerId)
|
||||
}
|
||||
|
||||
export async function updateWorkerConsignmentPermission(input: {
|
||||
workerId: number | string
|
||||
canConsign: boolean
|
||||
now: string
|
||||
}): Promise<WorkerUserRow | null> {
|
||||
const result = await query<{ id: number }>(
|
||||
`
|
||||
UPDATE worker_users
|
||||
SET
|
||||
can_consign = $1,
|
||||
consignment_activated_at = CASE
|
||||
WHEN $1 = TRUE THEN COALESCE(consignment_activated_at, $2::timestamptz)
|
||||
ELSE consignment_activated_at
|
||||
END,
|
||||
updated_at = $2
|
||||
WHERE id = $3
|
||||
RETURNING id
|
||||
`,
|
||||
[input.canConsign, input.now, Number(input.workerId)],
|
||||
)
|
||||
if (!result.rows[0]) {
|
||||
return null
|
||||
}
|
||||
return getWorkerUserById(input.workerId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user