From 86cafaadfd2c8e76df954abaca15addcbd734b91 Mon Sep 17 00:00:00 2001 From: ymq Date: Wed, 26 Aug 2026 16:04:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20calculate=5Fproduct=5Fcost=20?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=AE=A2=E6=88=B7=E7=BA=A7=E6=8A=98=E6=89=A3?= =?UTF-8?q?=EF=BC=8C=E5=8F=AA=E7=AE=97=E5=8E=9F=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 折扣移到产品层按 product_id 精确计算(产品级折扣)。资源层不碰折扣。 --- storage_resource/product_interface.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/storage_resource/product_interface.py b/storage_resource/product_interface.py index 03fc363..84d4346 100644 --- a/storage_resource/product_interface.py +++ b/storage_resource/product_interface.py @@ -147,17 +147,8 @@ async def calculate_product_cost(resource_ref_id, usage_data, user_org_id=None): amount = sum(getattr(p, 'amount', 0) for p in prices) - # 客户折扣:资源真实定价 × 客户折扣 = 成交价(照 llmage 范式) - discount = 1.0 - if user_org_id: - try: - d = await env.get_customer_discount( - getattr(spec, 'org_id', '') or '0', user_org_id) - if d not in (None, '', 0): - discount = float(d) - except Exception: - discount = 1.0 - - return {'success': True, 'amount': round(amount * discount, 6), + # 资源层只算真实定价(原价)。产品级折扣(客户/分销商/供应商)由产品层 + # calculate_product_cost 按 product_id 精确计算,见 product_management.core。 + return {'success': True, 'amount': round(amount, 6), 'original_amount': round(amount, 6), - 'cost': 0.0, 'discount': discount, 'pricing_program_id': ppid} + 'cost': 0.0, 'discount': 1.0, 'pricing_program_id': ppid}