refactor: calculate_product_cost 去掉客户级折扣,只算原价
折扣移到产品层按 product_id 精确计算(产品级折扣)。资源层不碰折扣。
This commit is contained in:
parent
b81d1e0bfc
commit
86cafaadfd
@ -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}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user