7-3 修复成本核算使用定价引擎计算结果而非前端传入值

_enrich_items_with_pricing 之前丢弃了定价引擎计算的 cost_price,
导致成本金额 = 数量 × 前端单价,未经过单位换算和公式计算。
现在使用引擎结果,确保成本核算正确。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
wsb1224 2026-07-03 16:14:32 +08:00
parent 3e0bf7f356
commit bc90cdba79

View File

@ -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"):