From 9389ae1237dbb304e56ca17da7fd970892d88b96 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 6 Sep 2026 17:21:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(storefront):=20=E4=BA=A7=E7=BA=BF=E5=B9=B4?= =?UTF-8?q?=E4=BB=98=E5=B1=95=E7=A4=BA=E4=BB=B7=3D=E6=9C=88=E5=8D=95?= =?UTF-8?q?=E4=BB=B7=C3=97months(10)=E2=80=94=E2=80=94=E6=AD=A4=E5=89=8D?= =?UTF-8?q?=E6=9C=88/=E5=B9=B4=E6=98=BE=E7=A4=BA=E5=90=8C=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit get_customer_price_display 只取定价单位价未乘 months 倍数,产线年付卡片 显示与月付相同价格(100 元/月 也显示 ¥100)。年付 months=10 → 总价=月价×10, 单位标签切'元/年'。存储/模型 months=1 不受影响。 --- product_management/core.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/product_management/core.py b/product_management/core.py index 43978a0..538eb85 100644 --- a/product_management/core.py +++ b/product_management/core.py @@ -1335,7 +1335,8 @@ class ProductManager: except Exception: discount = 1.0 - # 2. 按产品类型解析 ppid 列表 [(charge_mode/meter_mode 标签, ppid)] + # 2. 按产品类型解析 ppid 列表 [(标签, ppid, months 倍数)] + # months:产线年付=10(年费=月单价×10),其余类型为 1 dbname = self._get_dbname() ppid_pairs = [] try: @@ -1347,8 +1348,9 @@ class ProductManager: {'rid': ref_id}) for r in (recs or []): cm = str(getattr(r, 'charge_mode', '') or '') + months = int(getattr(r, 'months', 1) or 1) ppid_pairs.append(('包年' if cm == 'year' else '包月', - getattr(r, 'ppid', '') or '')) + getattr(r, 'ppid', '') or '', months)) elif product_type == 'workspace_storage': recs = await sor.sqlExe( "SELECT meter_mode, ppid FROM storres_pricing_map " @@ -1359,7 +1361,7 @@ class ProductManager: ppid = getattr(r, 'ppid', '') or '' if ppid and ppid not in seen: seen.add(ppid) - ppid_pairs.append(('容量', ppid)) + ppid_pairs.append(('容量', ppid, 1)) else: # 模型类(pipeline_llm_model / llm_model):ppid 挂模型表 recs = await sor.sqlExe( @@ -1367,7 +1369,7 @@ class ProductManager: if recs: ppid = getattr(recs[0], 'ppid', '') or '' if ppid: - ppid_pairs.append(('按量', ppid)) + ppid_pairs.append(('按量', ppid, 1)) await sor.sqlExe("COMMIT", {}) except Exception as e: debug(f'get_customer_price_display: ppid 解析失败 {pid}: {e}') @@ -1377,9 +1379,9 @@ class ProductManager: 'prices': [], 'pricing_text': '未配置定价', 'discount': discount, 'original_text': ''} - # 3. 取定价单位价 → × 折扣率 + # 3. 取定价单位价 → × 折扣率(months>1 时单位价×months,如年付=月价×10) prices = [] - for label, ppid in ppid_pairs: + for label, ppid, months in ppid_pairs: if not ppid: continue try: @@ -1388,20 +1390,23 @@ class ProductManager: pd = None if not pd: continue + mult = months if months and months > 1 else 1 + unit_suffix = '元/年' if mult > 1 else '' for item in (pd.get('items') or []): for pf in (item.get('price_factors') or []): up = pf.get('unit_price') if up is None: continue up = float(up) + total = up * mult prices.append({ 'label': label, 'factor': pf.get('factor', ''), 'factor_label': pf.get('label', ''), 'unit': pf.get('unit', ''), - 'unit_label': pf.get('unit_label', ''), - 'original_price': round(up, 6), - 'amount': round(up * discount, 6), + 'unit_label': unit_suffix or pf.get('unit_label', ''), + 'original_price': round(total, 6), + 'amount': round(total * discount, 6), }) if not prices: