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: