From 1a02733cdaf55057b02eb03a702ac741043213fd Mon Sep 17 00:00:00 2001 From: yml Date: Tue, 24 Nov 2026 23:43:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(fulfillment):=20=E5=8E=86=E5=8F=B2=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=86=BB=E7=BB=93=EF=BC=8C=E5=BF=AB=E7=85=A7=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E8=A7=A6=E5=8F=91=E8=87=AA=E5=8A=A8=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_platform_fulfillment.py | 16 ++++++++++++++++ .../services/platform_fulfillment/order_sync.py | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/tests/test_platform_fulfillment.py b/tests/test_platform_fulfillment.py index eff2a97..a1ac7c7 100644 --- a/tests/test_platform_fulfillment.py +++ b/tests/test_platform_fulfillment.py @@ -1098,6 +1098,22 @@ class TestSnapshotSync(_Base): assert service.list_tasks(self.session, flow_version=2)["pagination"]["total"] == 0 assert service.list_tasks(self.session, flow_version=1)["pagination"]["total"] == 1 + def test_legacy_task_is_frozen_against_snapshot_transitions(self): + task = self.task() + task.flow_version = 1 + self.session.commit() + + service.sync_order_snapshot( + self.session, + {"data": self.snapshot(orderStatus="refunded", douyuFulfillmentEnabled=False)}, + ) + + self.session.refresh(task) + assert task.flow_version == 1 + assert task.execution_status == "ready" + assert task.issue_code == "" + assert task.source_snapshot_json["orderStatus"] == "refunded" + def test_snapshot_after_clean_cutover_creates_clean_task(self): self.mapping() setting = self.session.get(PlatformFulfillmentSetting, 1) diff --git a/web/backend/services/platform_fulfillment/order_sync.py b/web/backend/services/platform_fulfillment/order_sync.py index 9a2c5f2..4019dc6 100644 --- a/web/backend/services/platform_fulfillment/order_sync.py +++ b/web/backend/services/platform_fulfillment/order_sync.py @@ -21,6 +21,7 @@ from ..external_order_source import ( ) from .common import ( AUTO_SYNC_INTERVAL_SECONDS, + FLOW_VERSION_LEGACY, SCOPE_ELITE, TARGET_PLATFORM, _flow_version_for_order, @@ -158,6 +159,10 @@ def _upsert_order_snapshot( .first() ) created = task is None + if task is not None and task.flow_version == FLOW_VERSION_LEGACY: + # 历史任务冻结:只保留来源快照,不参与任何自动状态迁移。 + task.source_snapshot_json = _jsonable(snapshot) + return task, created, False if task is None: task = PlatformFulfillmentTask( source_system="order_site",