diff --git a/storage_resource/product_interface.py b/storage_resource/product_interface.py index 05feeb9..03fc363 100644 --- a/storage_resource/product_interface.py +++ b/storage_resource/product_interface.py @@ -146,5 +146,18 @@ async def calculate_product_cost(resource_ref_id, usage_data, user_org_id=None): return {'success': False, 'message': '定价计算失败: %s' % e} amount = sum(getattr(p, 'amount', 0) for p in prices) - return {'success': True, 'amount': amount, 'original_amount': amount, - 'cost': 0.0, 'discount': 1.0, 'pricing_program_id': ppid} + + # 客户折扣:资源真实定价 × 客户折扣 = 成交价(照 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), + 'original_amount': round(amount, 6), + 'cost': 0.0, 'discount': discount, 'pricing_program_id': ppid}