From e1963b30c5be1f82fce969987d3bc6ac98e8b2cd Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 8 Sep 2026 18:50:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(storefront):=20=E6=8A=98=E6=89=A3=E2=89=A51?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=8E=9F=E4=BB=B7=E5=88=92=E7=BA=BF?= =?UTF-8?q?=E2=80=94=E2=80=94=E4=BB=85=E8=AE=A9=E5=88=A9(=E6=8A=98?= =?UTF-8?q?=E6=89=A3<1)=E6=97=B6=E5=B1=95=E7=A4=BA=E5=8E=9F=E4=BB=B7(?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E9=A1=B5+=E8=B4=AD=E4=B9=B0=E9=A1=B5?= =?UTF-8?q?=E4=B8=89=E5=A4=84=E5=90=8C=E8=A7=84=E5=88=99)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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包装语法检查) --- README.md | 1 + product_management/core.py | 6 ++++-- wwwroot/storefront/api/purchase_confirm.dspy | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e197993..47f7c5b 100644 --- a/README.md +++ b/README.md @@ -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 | 卡片点击 | 右下角 | diff --git a/product_management/core.py b/product_management/core.py index 67afb88..4c46e8b 100644 --- a/product_management/core.py +++ b/product_management/core.py @@ -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) diff --git a/wwwroot/storefront/api/purchase_confirm.dspy b/wwwroot/storefront/api/purchase_confirm.dspy index b713058..4c35f60 100644 --- a/wwwroot/storefront/api/purchase_confirm.dspy +++ b/wwwroot/storefront/api/purchase_confirm.dspy @@ -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';"