fix(storefront): 产线年付展示价=月单价×months(10)——此前月/年显示同价
get_customer_price_display 只取定价单位价未乘 months 倍数,产线年付卡片 显示与月付相同价格(100 元/月 也显示 ¥100)。年付 months=10 → 总价=月价×10, 单位标签切'元/年'。存储/模型 months=1 不受影响。
This commit is contained in:
parent
1f399d6b00
commit
9389ae1237
@ -1335,7 +1335,8 @@ class ProductManager:
|
|||||||
except Exception:
|
except Exception:
|
||||||
discount = 1.0
|
discount = 1.0
|
||||||
|
|
||||||
# 2. 按产品类型解析 ppid 列表 [(charge_mode/meter_mode 标签, ppid)]
|
# 2. 按产品类型解析 ppid 列表 [(标签, ppid, months 倍数)]
|
||||||
|
# months:产线年付=10(年费=月单价×10),其余类型为 1
|
||||||
dbname = self._get_dbname()
|
dbname = self._get_dbname()
|
||||||
ppid_pairs = []
|
ppid_pairs = []
|
||||||
try:
|
try:
|
||||||
@ -1347,8 +1348,9 @@ class ProductManager:
|
|||||||
{'rid': ref_id})
|
{'rid': ref_id})
|
||||||
for r in (recs or []):
|
for r in (recs or []):
|
||||||
cm = str(getattr(r, 'charge_mode', '') or '')
|
cm = str(getattr(r, 'charge_mode', '') or '')
|
||||||
|
months = int(getattr(r, 'months', 1) or 1)
|
||||||
ppid_pairs.append(('包年' if cm == 'year' else '包月',
|
ppid_pairs.append(('包年' if cm == 'year' else '包月',
|
||||||
getattr(r, 'ppid', '') or ''))
|
getattr(r, 'ppid', '') or '', months))
|
||||||
elif product_type == 'workspace_storage':
|
elif product_type == 'workspace_storage':
|
||||||
recs = await sor.sqlExe(
|
recs = await sor.sqlExe(
|
||||||
"SELECT meter_mode, ppid FROM storres_pricing_map "
|
"SELECT meter_mode, ppid FROM storres_pricing_map "
|
||||||
@ -1359,7 +1361,7 @@ class ProductManager:
|
|||||||
ppid = getattr(r, 'ppid', '') or ''
|
ppid = getattr(r, 'ppid', '') or ''
|
||||||
if ppid and ppid not in seen:
|
if ppid and ppid not in seen:
|
||||||
seen.add(ppid)
|
seen.add(ppid)
|
||||||
ppid_pairs.append(('容量', ppid))
|
ppid_pairs.append(('容量', ppid, 1))
|
||||||
else:
|
else:
|
||||||
# 模型类(pipeline_llm_model / llm_model):ppid 挂模型表
|
# 模型类(pipeline_llm_model / llm_model):ppid 挂模型表
|
||||||
recs = await sor.sqlExe(
|
recs = await sor.sqlExe(
|
||||||
@ -1367,7 +1369,7 @@ class ProductManager:
|
|||||||
if recs:
|
if recs:
|
||||||
ppid = getattr(recs[0], 'ppid', '') or ''
|
ppid = getattr(recs[0], 'ppid', '') or ''
|
||||||
if ppid:
|
if ppid:
|
||||||
ppid_pairs.append(('按量', ppid))
|
ppid_pairs.append(('按量', ppid, 1))
|
||||||
await sor.sqlExe("COMMIT", {})
|
await sor.sqlExe("COMMIT", {})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
debug(f'get_customer_price_display: ppid 解析失败 {pid}: {e}')
|
debug(f'get_customer_price_display: ppid 解析失败 {pid}: {e}')
|
||||||
@ -1377,9 +1379,9 @@ class ProductManager:
|
|||||||
'prices': [], 'pricing_text': '未配置定价',
|
'prices': [], 'pricing_text': '未配置定价',
|
||||||
'discount': discount, 'original_text': ''}
|
'discount': discount, 'original_text': ''}
|
||||||
|
|
||||||
# 3. 取定价单位价 → × 折扣率
|
# 3. 取定价单位价 → × 折扣率(months>1 时单位价×months,如年付=月价×10)
|
||||||
prices = []
|
prices = []
|
||||||
for label, ppid in ppid_pairs:
|
for label, ppid, months in ppid_pairs:
|
||||||
if not ppid:
|
if not ppid:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
@ -1388,20 +1390,23 @@ class ProductManager:
|
|||||||
pd = None
|
pd = None
|
||||||
if not pd:
|
if not pd:
|
||||||
continue
|
continue
|
||||||
|
mult = months if months and months > 1 else 1
|
||||||
|
unit_suffix = '元/年' if mult > 1 else ''
|
||||||
for item in (pd.get('items') or []):
|
for item in (pd.get('items') or []):
|
||||||
for pf in (item.get('price_factors') or []):
|
for pf in (item.get('price_factors') or []):
|
||||||
up = pf.get('unit_price')
|
up = pf.get('unit_price')
|
||||||
if up is None:
|
if up is None:
|
||||||
continue
|
continue
|
||||||
up = float(up)
|
up = float(up)
|
||||||
|
total = up * mult
|
||||||
prices.append({
|
prices.append({
|
||||||
'label': label,
|
'label': label,
|
||||||
'factor': pf.get('factor', ''),
|
'factor': pf.get('factor', ''),
|
||||||
'factor_label': pf.get('label', ''),
|
'factor_label': pf.get('label', ''),
|
||||||
'unit': pf.get('unit', ''),
|
'unit': pf.get('unit', ''),
|
||||||
'unit_label': pf.get('unit_label', ''),
|
'unit_label': unit_suffix or pf.get('unit_label', ''),
|
||||||
'original_price': round(up, 6),
|
'original_price': round(total, 6),
|
||||||
'amount': round(up * discount, 6),
|
'amount': round(total * discount, 6),
|
||||||
})
|
})
|
||||||
|
|
||||||
if not prices:
|
if not prices:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user