refactor: calculate_product_cost 去掉客户级折扣,只算原价
折扣移到产品层按 product_id 精确计算(产品级折扣)。资源层不碰折扣。
This commit is contained in:
parent
ac72f6a56d
commit
f2972dba74
@ -174,17 +174,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)
|
amount = sum(getattr(p, 'amount', 0) for p in prices)
|
||||||
|
|
||||||
# 客户折扣:资源真实定价 × 客户折扣 = 成交价(照 llmage 范式)
|
# 资源层只算真实定价(原价)。产品级折扣(客户/分销商/供应商)由产品层
|
||||||
discount = 1.0
|
# calculate_product_cost 按 product_id 精确计算,见 product_management.core。
|
||||||
if user_org_id:
|
return {'success': True, 'amount': round(amount, 6),
|
||||||
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),
|
'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