调整(半自动履约): 去掉后台「领取」,任一客服均可操作
- 删除 POST /admin/semi-auto/tasks/:taskId/claim 与 claimAdminSemiAutoTask; 前端列表行与详情抽屉的「领取」按钮、claim 服务封装一并移除。 - 去掉三处「该任务已被其他客服领取」409 门禁(重新授权、开浏览器会话、完成履约), 任一有半自动权限的客服都能直接操作。 - assigned_admin_user_id 保留为「最近操作客服」:开浏览器会话与完成履约时写当前操作人, 列表/详情的列名改为「最近操作」,未操作过显示「—」。 - 权威文档改为「不设任务领取人门禁」,CK 导出与注入说明同步去掉领取人口径。 - 集成测试补断言:客服 A 开过会话后客服 B 仍可注入,且任务记录的是最近操作人。
This commit is contained in:
@@ -270,40 +270,6 @@ export async function exportAdminSemiAutoCredential(taskIdInput: unknown) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function claimAdminSemiAutoTask(taskIdInput: unknown, session: AdminSession) {
|
||||
const taskId = normalizeId(taskIdInput)
|
||||
const adminUserId = Number(session.userId || 0)
|
||||
let orderId = 0
|
||||
await withTransaction(async (client) => {
|
||||
const task = await loadTaskForUpdateWithClient(client, taskId)
|
||||
if (task.execution_status === 'completed' || task.execution_status === 'cancelled') {
|
||||
throw createHttpError('当前任务已结束,不能领取', {
|
||||
statusCode: 409,
|
||||
errorCode:
|
||||
task.execution_status === 'completed'
|
||||
? 'semi_auto_task_completed'
|
||||
: 'semi_auto_task_cancelled',
|
||||
})
|
||||
}
|
||||
if (task.assigned_admin_user_id && Number(task.assigned_admin_user_id) !== adminUserId) {
|
||||
throw createHttpError('该任务已被其他客服领取', {
|
||||
statusCode: 409,
|
||||
errorCode: 'semi_auto_task_claimed',
|
||||
})
|
||||
}
|
||||
orderId = Number(task.order_id)
|
||||
await convergeSemiAutoTaskState(client, taskId, {
|
||||
reason: 'task_claimed',
|
||||
actor: 'admin',
|
||||
actorId: String(adminUserId),
|
||||
patch: { assignedAdminUserId: adminUserId },
|
||||
event: { eventType: 'task_claimed' },
|
||||
})
|
||||
})
|
||||
publishSemiAutoTaskRealtimeChange(taskId, orderId)
|
||||
return getAdminSemiAutoTask(taskId)
|
||||
}
|
||||
|
||||
export async function syncAdminSemiAutoTask(taskIdInput: unknown) {
|
||||
const taskId = normalizeId(taskIdInput)
|
||||
let task = await ensureConnectorSessionForTask(await loadTask(taskId))
|
||||
@@ -777,12 +743,6 @@ export async function requestAdminSemiAutoCustomerReauth(
|
||||
})
|
||||
}
|
||||
const adminUserId = Number(session.userId || 0)
|
||||
if (task.assigned_admin_user_id && Number(task.assigned_admin_user_id) !== adminUserId) {
|
||||
throw createHttpError('该任务已被其他客服领取', {
|
||||
statusCode: 409,
|
||||
errorCode: 'semi_auto_task_claimed',
|
||||
})
|
||||
}
|
||||
if (task.connector_session_id) {
|
||||
await revokeSessionForTask(task, task.connector_session_id).catch(() => undefined)
|
||||
}
|
||||
@@ -803,12 +763,6 @@ export async function createAdminBrowserSession(
|
||||
const taskId = normalizeId(taskIdInput)
|
||||
const task = await ensureConnectorSessionForTask(await loadTask(taskId))
|
||||
const adminUserId = Number(session.userId || 0)
|
||||
if (task.assigned_admin_user_id && Number(task.assigned_admin_user_id) !== adminUserId) {
|
||||
throw createHttpError('该任务已被其他客服领取', {
|
||||
statusCode: 409,
|
||||
errorCode: 'semi_auto_task_claimed',
|
||||
})
|
||||
}
|
||||
if (!task.connector_session_id || task.login_status !== 'authenticated') {
|
||||
throw createHttpError('客户尚未完成登录,或登录会话已失效', {
|
||||
statusCode: 409,
|
||||
@@ -873,10 +827,8 @@ export async function createAdminBrowserSession(
|
||||
actor: 'admin',
|
||||
actorId: String(adminUserId),
|
||||
patch: {
|
||||
// 已领取任务保持原领取人(原 COALESCE 语义)。
|
||||
assignedAdminUserId: current.assigned_admin_user_id
|
||||
? Number(current.assigned_admin_user_id)
|
||||
: adminUserId,
|
||||
// 不设领取人:任何客服都能操作,这里只记录最近一次操作人。
|
||||
assignedAdminUserId: adminUserId,
|
||||
executionStatus:
|
||||
current.execution_status === 'waiting_operator' ? 'processing' : current.execution_status,
|
||||
},
|
||||
@@ -993,12 +945,6 @@ export async function completeAdminSemiAutoTask(
|
||||
errorCode: 'weibo_binding_not_confirmed',
|
||||
})
|
||||
}
|
||||
if (task.assigned_admin_user_id && Number(task.assigned_admin_user_id) !== adminUserId) {
|
||||
throw createHttpError('该任务已被其他客服领取', {
|
||||
statusCode: 409,
|
||||
errorCode: 'semi_auto_task_claimed',
|
||||
})
|
||||
}
|
||||
|
||||
await confirmManualFulfillment(
|
||||
{
|
||||
@@ -1016,10 +962,8 @@ export async function completeAdminSemiAutoTask(
|
||||
actor: 'admin',
|
||||
actorId: String(adminUserId),
|
||||
patch: {
|
||||
// 已领取任务保持原领取人(原 COALESCE 语义)。
|
||||
assignedAdminUserId: task.assigned_admin_user_id
|
||||
? Number(task.assigned_admin_user_id)
|
||||
: adminUserId,
|
||||
// 不设领取人:任何客服都能完成,这里只记录最近一次操作人。
|
||||
assignedAdminUserId: adminUserId,
|
||||
executionStatus: 'completed',
|
||||
completedQuantity: Number(task.target_quantity || 0),
|
||||
completedAt: SEMI_AUTO_NOW,
|
||||
|
||||
Reference in New Issue
Block a user