From eb93e7aca2b79fa8cee5b0a0687d52824d79b72e Mon Sep 17 00:00:00 2001 From: yml Date: Tue, 24 Nov 2026 21:44:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(fulfillment):=20=E5=A2=9E=E5=8A=A0=E5=BE=85?= =?UTF-8?q?=E6=98=A0=E5=B0=84=E9=98=9F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 待映射任务未配置商品映射时不再被列表过滤掉 - 工作台新增待映射标签,显示同步后尚未映射的订单 - 补充未映射任务列表测试 --- tests/test_platform_fulfillment.py | 13 +++++++++++++ web/backend/services/platform_fulfillment/views.py | 12 +++++++----- web/frontend/src/pages/PlatformFulfillmentPage.tsx | 8 +++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/tests/test_platform_fulfillment.py b/tests/test_platform_fulfillment.py index 169b739..7372716 100644 --- a/tests/test_platform_fulfillment.py +++ b/tests/test_platform_fulfillment.py @@ -182,6 +182,19 @@ class TestWorkbenchReadPath(_Base): self.session.commit() return task + def test_pending_mapping_queue_shows_unmapped_tasks(self): + views.invalidate_task_list_count_cache() + task = self.task(mapped=False) + + result = service.list_tasks( + self.session, + queue_bucket="pending_mapping", + page_size=100, + ) + + assert [item["id"] for item in result["items"]] == [task.id] + assert result["items"][0]["executionStatus"] == "pending_mapping" + def test_task_list_count_uses_short_ttl_cache_until_invalidated(self): views.invalidate_task_list_count_cache() mapping = self.mapping() diff --git a/web/backend/services/platform_fulfillment/views.py b/web/backend/services/platform_fulfillment/views.py index bc17207..7429faf 100644 --- a/web/backend/services/platform_fulfillment/views.py +++ b/web/backend/services/platform_fulfillment/views.py @@ -216,12 +216,14 @@ def list_tasks( cutoff = _order_match_started_at(db) query = db.query(PlatformFulfillmentTask) query = _apply_order_match_cutoff(query, cutoff) - query = query.filter( - or_( - PlatformFulfillmentTask.commodity_mapping_id.isnot(None), - PlatformFulfillmentTask.commodity_id != "", + # 待映射队列本身就是要展示“还没有映射”的任务,不能再套映射存在条件。 + if queue_bucket != "pending_mapping": + query = query.filter( + or_( + PlatformFulfillmentTask.commodity_mapping_id.isnot(None), + PlatformFulfillmentTask.commodity_id != "", + ) ) - ) mode_filter = classification.normalize_sale_mode(sale_mode) if sale_mode and mode_filter != "unknown": query = query.filter(PlatformFulfillmentTask.sale_mode == mode_filter) diff --git a/web/frontend/src/pages/PlatformFulfillmentPage.tsx b/web/frontend/src/pages/PlatformFulfillmentPage.tsx index e0ed2e2..c7a311c 100644 --- a/web/frontend/src/pages/PlatformFulfillmentPage.tsx +++ b/web/frontend/src/pages/PlatformFulfillmentPage.tsx @@ -122,6 +122,7 @@ const MANUAL_REASON_LABELS: Record = { const QUEUE_BUCKET_OPTIONS = [ { value: 'current', label: '当前待办' }, + { value: 'pending_mapping', label: '待映射' }, { value: 'presale_waiting', label: '预售待开放' }, { value: 'ready_for_fulfillment', label: '可履约' }, { value: 'needs_action', label: '需要人工' }, @@ -537,7 +538,12 @@ export default function PlatformFulfillmentPage() { const queueBackedStatus = queueBucket === 'current' ? 'unfinished' : (['completed', 'cancelled'].includes(queueBucket) ? queueBucket : undefined); - const backendBucket = ['presale_waiting', 'ready_for_fulfillment', 'needs_action'].includes(queueBucket) + const backendBucket = [ + 'pending_mapping', + 'presale_waiting', + 'ready_for_fulfillment', + 'needs_action', + ].includes(queueBucket) ? queueBucket : undefined; const result = await platformFulfillmentApi.listTasks({