From bc90cdba79877a21d1e1044d179084edab4776ea Mon Sep 17 00:00:00 2001 From: wsb1224 Date: Fri, 3 Jul 2026 16:14:32 +0800 Subject: [PATCH] =?UTF-8?q?7-3=20=E4=BF=AE=E5=A4=8D=E6=88=90=E6=9C=AC?= =?UTF-8?q?=E6=A0=B8=E7=AE=97=E4=BD=BF=E7=94=A8=E5=AE=9A=E4=BB=B7=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E8=AE=A1=E7=AE=97=E7=BB=93=E6=9E=9C=E8=80=8C=E9=9D=9E?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E4=BC=A0=E5=85=A5=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _enrich_items_with_pricing 之前丢弃了定价引擎计算的 cost_price, 导致成本金额 = 数量 × 前端单价,未经过单位换算和公式计算。 现在使用引擎结果,确保成本核算正确。 Co-Authored-By: Claude Sonnet 4.6 --- backend/app/services/order_service.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/app/services/order_service.py b/backend/app/services/order_service.py index d7d0c97..42f4bbe 100644 --- a/backend/app/services/order_service.py +++ b/backend/app/services/order_service.py @@ -131,10 +131,11 @@ class OrderService: try: result = pricing_engine.calculate_for_order_item(rule, user_inputs, product_attrs) - # 不覆盖前端传入的 cost_price,只填充快照字段用于展示 item_copy = dict(item) - # 填充快照字段 + # 使用定价引擎计算的 cost_price(包含单位换算、公式计算、附加费) snapshot = result.get("item_snapshot", {}) + if snapshot.get("cost_price") is not None: + item_copy["cost_price"] = snapshot["cost_price"] if snapshot.get("pricing_type"): item_copy["pricing_type"] = snapshot["pricing_type"] if result.get("area_sqm"):