From 631862217d34eb3ccd3fd9ad429384b90a6ad8c5 Mon Sep 17 00:00:00 2001 From: yml Date: Wed, 18 Nov 2026 19:49:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(fulfillment):=20=E7=A8=B3=E5=AE=9A=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F=E5=B9=B6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BB=BB=E5=8A=A1=20ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_platform_fulfillment.py | 39 +++++++++++++++++++ .../services/platform_fulfillment/service.py | 2 +- .../src/pages/PlatformFulfillmentPage.tsx | 12 +++++- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/tests/test_platform_fulfillment.py b/tests/test_platform_fulfillment.py index 1e51178..5187509 100644 --- a/tests/test_platform_fulfillment.py +++ b/tests/test_platform_fulfillment.py @@ -308,6 +308,45 @@ class TestSyncAndMapping(_Base): assert listed["pagination"]["total"] == 0 + def test_list_order_is_stable_by_paid_time_not_updated_at(self): + first = self.task() + second = PlatformFulfillmentTask( + source_system="order_site", + source_order_id="108", + source_order_item_id="109", + source_fulfillment_id="209", + platform_order_id="ORDER-109", + provider="91kaquan", + shop_id="shop-1", + shop_name="测试店", + sku_code=INTERNAL_SKU, + sku_name=INTERNAL_SKU, + internal_sku_key=INTERNAL_SKU, + quantity=1, + order_amount_fen=9900, + target_platform="douyu", + scope="elite", + commodity_mapping_id=first.commodity_mapping_id, + commodity_id=COMMODITY, + required_points=1280, + binding_status="not_started", + execution_status="ready", + exchange_status="not_started", + paid_at=NOW + timedelta(minutes=1), + created_at=NOW, + updated_at=NOW, + ) + self.session.add(second) + self.session.commit() + + # 模拟 worker 重试:旧订单的 updated_at 变得更新,但列表顺序不能跳。 + first.updated_at = NOW + timedelta(minutes=10) + self.session.commit() + + listed = service.list_tasks(self.session) + + assert [item["id"] for item in listed["items"]] == [second.id, first.id] + def test_list_includes_recent_paid_task_created_before_order_match_cutoff(self): mapping = self.mapping() task = PlatformFulfillmentTask( diff --git a/web/backend/services/platform_fulfillment/service.py b/web/backend/services/platform_fulfillment/service.py index d654e08..23d33be 100644 --- a/web/backend/services/platform_fulfillment/service.py +++ b/web/backend/services/platform_fulfillment/service.py @@ -911,7 +911,7 @@ def list_tasks( total = query.count() rows = ( query.order_by( - PlatformFulfillmentTask.updated_at.desc(), + PlatformFulfillmentTask.paid_at.desc(), PlatformFulfillmentTask.id.desc(), ) .offset((max(1, page) - 1) * max(1, page_size)) diff --git a/web/frontend/src/pages/PlatformFulfillmentPage.tsx b/web/frontend/src/pages/PlatformFulfillmentPage.tsx index 098d693..2fc0e9b 100644 --- a/web/frontend/src/pages/PlatformFulfillmentPage.tsx +++ b/web/frontend/src/pages/PlatformFulfillmentPage.tsx @@ -586,6 +586,16 @@ export default function PlatformFulfillmentPage() { }; const columns: ColumnsType = [ + { + title: '任务 ID', + dataIndex: 'id', + key: 'id', + width: 100, + fixed: 'left', + render: (value: number) => ( + #{value} + ), + }, { title: '订单 / 商品', key: 'order', @@ -805,7 +815,7 @@ export default function PlatformFulfillmentPage() { loading={loading} columns={columns} dataSource={rows} - scroll={{ x: 1500 }} + scroll={{ x: 1600 }} pagination={{ current: page, pageSize,