From e85bbee7e0cc2b9722ee8d8ca83c911286b62943 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Fri, 6 Nov 2026 17:53:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(worker-platform):=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=AF=84=E5=94=AE=E7=AD=9B=E9=80=89=E5=8F=A0=E5=8A=A0=E6=8E=A5?= =?UTF-8?q?=E5=8D=95=E4=BA=BA=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../worker-platform/work-order-query-repo.ts | 9 +++------ .../worker-platform/worker-platform-service.test.ts | 13 ++++++++++--- apps/frontend/src/utils/consignment-display.ts | 7 +++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/apps/backend/src/repositories/worker-platform/work-order-query-repo.ts b/apps/backend/src/repositories/worker-platform/work-order-query-repo.ts index 0a679a55..b0315442 100644 --- a/apps/backend/src/repositories/worker-platform/work-order-query-repo.ts +++ b/apps/backend/src/repositories/worker-platform/work-order-query-repo.ts @@ -1526,12 +1526,9 @@ export function buildWorkOrderWhere({ if (acceptanceMode) { const rawMode = String(acceptanceMode).trim() if (rawMode === 'internal_consignment') { - filters.push(`( - wo.material_json->'consignment'->>'inventoryId' IS NOT NULL - AND (wo.material_json->'consignment'->>'fulfillmentType' IS NULL OR wo.material_json->'consignment'->>'fulfillmentType' != 'worker_deposit') - AND (wo.material_json->'consignment'->>'workerId' IS NULL OR wo.material_json->'consignment'->>'workerId' = '0') - AND (wo.assigned_worker_id IS NULL OR wo.assigned_worker_id = 0) - )`) + // 「寄售来源」与是否已经匹配打手是两个正交条件。 + // 这里不能内置“必须未指派”,否则再接 workerId 筛选会恒为空。 + filters.push(`wo.material_json->'consignment'->>'inventoryId' IS NOT NULL`) } else if (rawMode === WORK_ORDER_ACCEPTANCE_MODE.FRIEND_GIFT) { filters.push(`( wo.acceptance_mode = 'friend_gift' diff --git a/apps/backend/src/services/worker-platform/worker-platform-service.test.ts b/apps/backend/src/services/worker-platform/worker-platform-service.test.ts index 203e2e81..6a06bef2 100644 --- a/apps/backend/src/services/worker-platform/worker-platform-service.test.ts +++ b/apps/backend/src/services/worker-platform/worker-platform-service.test.ts @@ -1970,15 +1970,22 @@ test('好友赠送待打手提交资料筛选排除待抢单订单', () => { assert.match(whereClause, /wo\.status IN \('in_progress', 'problem'\)/) }) -test('工单筛选支持内部寄售匹配与打手好友赠送隔离,且赠送冷却中排除已验收已取消工单', () => { +test('工单筛选支持内部寄售来源叠加人员条件,并保持好友赠送与冷却筛选', () => { const internalQuery = buildWorkOrderWhere({ acceptanceMode: 'internal_consignment' }) assert.match( internalQuery.whereClause, /wo\.material_json->'consignment'->>'inventoryId' IS NOT NULL/, ) + assert.doesNotMatch(internalQuery.whereClause, /wo\.assigned_worker_id IS NULL/) + + const workerScopedInternalQuery = buildWorkOrderWhere({ + acceptanceMode: 'internal_consignment', + workerSharingId: 25, + }) + assert.match(workerScopedInternalQuery.joins, /worker_visible\.work_order_id = wo\.id/) assert.match( - internalQuery.whereClause, - /wo\.assigned_worker_id IS NULL OR wo\.assigned_worker_id = 0/, + workerScopedInternalQuery.whereClause, + /wo\.material_json->'consignment'->>'inventoryId' IS NOT NULL/, ) const friendGiftQuery = buildWorkOrderWhere({ acceptanceMode: 'friend_gift' }) diff --git a/apps/frontend/src/utils/consignment-display.ts b/apps/frontend/src/utils/consignment-display.ts index e78180cc..68821294 100644 --- a/apps/frontend/src/utils/consignment-display.ts +++ b/apps/frontend/src/utils/consignment-display.ts @@ -34,11 +34,10 @@ export type ConsignmentWorkerDisplayInfo = { } /** - * 内部现货履约单:由客服/内部仓代交付,工单上没有接单打手。 + * 尚未匹配打手的内部现货履约单:由客服/内部仓代交付,工单上没有接单打手。 * - * 口径必须与后端「内部寄售匹配」筛选(work-order-query-repo 的 internal_consignment 分支)一致: - * `material.consignment.inventoryId` 有值、`fulfillmentType ≠ worker_deposit`、 - * `consignment.workerId` 缺失或为 0(后端按字符串 '0' 也视为无打手)、且工单未指派打手。 + * 这是操作能力判断,不用于「内部寄售」来源筛选;来源筛选允许匹配前后, + * 因此可以和接单人员条件叠加。 */ export function isInternalConsignmentOrder(row: { material?: unknown; worker?: unknown }): boolean { const consignment = asRecord(asRecord(row.material).consignment)