fix(storefront): 折扣≥1不显示原价划线——仅让利(折扣<1)时展示原价(展示页+购买页三处同规则)

- core.py get_customer_price_display: abs(discount-1)>1e-9 → discount<1.0-1e-9,
  加价(如存储1.5)/无折扣(产线1.0)时「原价」低于或等于现价还划线是误导
- purchase_confirm.dspy: 服务端初始算价文本 + 前端JS刷新脚本同款条件修正
- 验证脚本扩至44断言全过(含卡片级无原价/无line-through断言+dspy包装语法检查)
This commit is contained in:
yumoqing 2026-09-08 18:50:43 +08:00
parent cd58974146
commit e1963b30c5
3 changed files with 9 additions and 4 deletions

View File

@ -245,6 +245,7 @@ product_use(product_id, user_id, user_org_id, used_amount, used_unit)
### 商店展示价与卡片行为storefront
- **展示价唯一入口** `get_customer_price_display(product_id, user_org_id)`:显示价 = 资源真实定价 × 客户折扣率(专属折扣 → `'*'` 兜底 → 1.0;未登录按 `'*'` 报价,访客可见)。
- **原价仅让利时显示**2026-09-08折扣 <1 才输出 `original_text` 原价划线折扣 1无折扣/加价如存储 1.5产线 1.0不显示原价——加价时原价低于现价还划线是误导展示页core.py与购买页purchase_confirm.dspy 服务端初始价 + 前端 JS 刷新脚本三处同规则
- **多价目必带表头**2026-09-08产品有多个价格因子时如模型按量的 非缓存输入Token/输出tokens/缓存Token 三档),`pricing_text` 每段前拼 `factor_label`(来自定价 YAML fields 的 label禁止输出裸的「¥2.1 元/百万 | ¥8.4 元/百万」让客户猜含义。单价目(如存储 元/GB月不加表头产线用 包月/包年 表头。
- **卡片按钮按 product_type 分流**
| product_type | 卡片点击 | 右下角 |

View File

@ -1414,7 +1414,9 @@ class ProductManager:
'prices': [], 'pricing_text': '未配置定价',
'discount': discount, 'original_text': ''}
# 4. 拼展示文本折扣≠1 时同时给原价,让客户看见让利/加价幅度)
# 4. 拼展示文本(仅折扣<1 让利时给原价划线,让客户看见优惠幅度;
# 折扣≥1无折扣/加价不显示原价——2026-09-08 用户定夺:加价时
# 「原价」低于现价还划线展示是误导,产线展示页/购买页同规则)
# 多价目产品(如模型按量:输入/输出/缓存三档 tokens 价)必须带因子表头,
# 否则客户看到裸的「¥2.1 元/百万 | ¥8.4 元/百万」不知道各是什么价
# 2026-09-08 用户反馈。factor_label 来自定价 YAML fields 的 label。
@ -1427,7 +1429,7 @@ class ProductManager:
seg = ('%s ' % head if head else '') + '¥%.4g %s' % (
p['amount'], p['unit_label'] or '')
parts.append(seg.strip())
if abs(discount - 1.0) > 1e-9:
if discount < 1.0 - 1e-9:
orig_parts.append('%.4g' % p['original_price'])
pricing_text = ' | '.join(parts)

View File

@ -70,7 +70,9 @@ else:
_orig = float(_c.get('original_amount', 0) or 0)
_disc = float(_c.get('discount', 1.0) or 1.0)
init_price_text = '应付金额:¥ %.2f' % _amt
if abs(_disc - 1.0) > 1e-9:
# 仅让利(折扣<1显示原价折扣≥1 不显示2026-09-08 用户定夺,
# 与展示页 get_customer_price_display 同规则)
if _disc < 1.0 - 1e-9:
init_price_text += '(原价 ¥ %.2f × 折扣 %.4g' % (_orig, _disc)
else:
init_price_text = '算价失败:%s' % ((_c or {}).get('message', '') or '未知')[:80]
@ -117,7 +119,7 @@ else:
"{method:'POST',body:params}).then(function(r){return r.json()}).then(function(d){"
" var t=bricks.getWidgetById('buy_price_text',bricks.app); if(!t)return;"
" if(d.success){var s='应付金额:¥ '+(Math.round(d.amount*100)/100).toFixed(2);"
" if(Math.abs((d.discount||1)-1)>1e-9){"
" if((d.discount||1)<1-1e-9){"
" s+='(原价 ¥ '+(Math.round(d.original_amount*100)/100).toFixed(2)"
" +' × 折扣 '+d.discount+'';}"
" t.set_text(s);t.dom_element.style.color='#e74c3c';"