Explorar el Código

feat(api): P0 套餐三分类落地——plan_family 两值、条目只引档位、席位归属订阅

- 目录:use_category 五值换 plan_family(link/addon),新增与编辑共用
  family_shape_guard;addon 档额度恒 0、带宽三键一律不传(D-15/D-18),
  plan_kind/plan_family 建档后不可改(K204)。
- 合同:条目只剩 plan_id/quantity/item_family/line_exits,派生自定义档
  机制整条退休;price/带宽/账号数等档位自有列出现即 11103 并点名到
  service_items[i].键(新建与编辑同一判据)。
- 订阅:item_family 收入只读派生列拒收名单;份数口径随形态(link 恒 1、
  addon ≥1);I6 判据与 uq_i6_active 兜底退役,KLT-M224 码位保留不抛出。
- 席位:sub_account.subscription_id 落库,额度补建与计费按单份订阅对齐。
- 建档:Ops 可建自定义档(D-16),created_by 写鉴权账号、created_team_id
  记建档时点团队快照并四表 join 读出(D-17)。
- openapi 两份同步:字段、必填项、错误码与 D-15~D-18 口径一致。

验证:cargo test --workspace 全绿;temp/p0_accept.py 49/49(含断言 21~25)。

Co-authored-by: Cursor <cursoragent@cursor.com>
cg hace 3 días
padre
commit
c24ed50987

+ 75 - 44
src/bin/klt-bos/openapi.yaml

@@ -3721,7 +3721,7 @@ paths:
   /catalog/create@v1:
     post:
       summary: 新建套餐档位
-      description: 新建固定/自定义档位。拒收 monthly_settle_cents、sub_mode、first_referred_at。自定义档必填 customer_id。
+      description: 新建固定/自定义档位。拒收 sub_mode、first_referred_at。自定义档必填 customer_id。Ops 角色只能建自定义档(D-16);created_by=鉴权账号、created_team_id=建档团队快照(D-17)。
       operationId: catalog_create
       tags:
       - 套餐档位
@@ -3757,18 +3757,24 @@ paths:
                     plan_desc:
                       type: string
                       description: 套餐说明(报价单权益口径,可空;去首尾空白后 ≤512 字符,超长报 11103)。引用冻结后仍可改(与名称、随附成本项同档)
-                    use_category:
+                    plan_family:
                       type: string
-                      description: 用途分类:office/live/ai/value_add/customized
+                      description: 交付形态:link=跨境链路(份数恒 1);addon=附加项(份数≥1,不设带宽列)
+                      enum:
+                      - link
+                      - addon
                     annual_price_cents:
                       type: integer
                       description: 年价(分)
+                    monthly_settle_cents:
+                      type: integer
+                      description: 月结算标准(分,可选,1~上限);可录入(2026-11-19 起由只读列改为可写)
                     sub_account_quota:
                       type: integer
-                      description: 分账号配额
+                      description: 分账号额度(非负,上限 9999):link 档必须 > 0;addon 档必须为 0(D-15)
                     bandwidth_committed:
                       type: boolean
-                      description: 是否承诺带宽(界面「是否承诺带宽」开关):true=承诺(缺省,同列 DEFAULT TRUE);false=该档「不承诺带宽」,此时上行/下行两字段一律不传
+                      description: 是否承诺带宽:仅 link 档可传(缺省 true);addon 档一律不传(D-18)
                     bandwidth_up_mbps:
                       type: integer
                       description: 上行带宽(Mbps,整数 1~1000);bandwidth_committed=true 时必填。不再有单值 total_bandwidth_mbps(2026-11-05 D8 关闭=该列退役,「总带宽」只是显示列名)
@@ -3781,7 +3787,7 @@ paths:
                   required:
                   - plan_kind
                   - plan_name
-                  - use_category
+                  - plan_family
                   - annual_price_cents
               required:
               - data
@@ -3792,7 +3798,7 @@ paths:
   /catalog/update@v1:
     post:
       summary: 编辑套餐档位
-      description: 编辑档位;use_category 建后不可改;被订阅引用冻结后多数字段只读。
+      description: 编辑档位;plan_kind/plan_family 建后不可改(K204);被订阅引用冻结后多数字段只读。
       operationId: catalog_update
       tags:
       - 套餐档位
@@ -3828,9 +3834,12 @@ paths:
                     annual_price_cents:
                       type: integer
                       description: 年价(分)
+                    monthly_settle_cents:
+                      type: integer
+                      description: 月结算标准(分,可选,1~上限);可录入(2026-11-19 起由只读列改为可写)
                     sub_account_quota:
                       type: integer
-                      description: 分账号配额
+                      description: 分账号额度(非负,上限 9999):link 档必须 > 0;addon 档必须为 0(D-15)
                     bandwidth_committed:
                       type: boolean
                       description: 是否承诺带宽:true=承诺(缺省);false=该档「不承诺带宽」,上下行两字段一律不传
@@ -3854,7 +3863,7 @@ paths:
   /catalog/get_list@v1:
     post:
       summary: 套餐档位列表
-      description: 按 plan_kind 等条件筛选档位列表。
+      description: 按 plan_kind/plan_family 等条件筛选档位列表。每行回 plan_family、use_purpose、created_by/created_team_id 及读侧名称 created_by_name/created_team_name(D-17)。
       operationId: catalog_get_list
       tags:
       - 套餐档位
@@ -3895,9 +3904,12 @@ paths:
                     plan_kind:
                       type: string
                       description: 档位类型筛选:fixed/custom
-                    use_category:
+                    plan_family:
                       type: string
-                      description: 用途分类筛选
+                      description: 交付形态筛选:link/addon(仅自定义档可筛,固定档带此参报错)
+                      enum:
+                      - link
+                      - addon
                     customer_id:
                       type: string
                       description: 自定义档客户筛选
@@ -4285,24 +4297,18 @@ paths:
                         type: object
                         description: 服务条目
                         properties:
-                          item_kind:
-                            type: string
-                            description: 条目类型:plan_based/custom_spec
                           plan_id:
                             type: string
-                            description: 档位 ID(plan_based)
+                            description: 档位 ID(必填;2026-11-19 D-15 起条目只能引用目录档位)
                           quantity:
                             type: integer
-                            description: 数量
-                          account_count:
-                            type: integer
-                            description: 账号数(custom_spec)
-                          bandwidth_up_mbps:
-                            type: integer
-                            description: 上行带宽(Mbps,整数 1~1000,custom_spec);与下行至少填一侧,只填一侧时按上下行对称填同一值
-                          bandwidth_down_mbps:
-                            type: integer
-                            description: 下行带宽(Mbps,整数 1~1000,custom_spec);两值原样投影到派生自定义档,不折算(2026-11-05 D8 关闭)
+                            description: 份数:link 档恒 1;addon 档≥1
+                          item_family:
+                            type: string
+                            description: 交付形态(只读确认位,可缺省):只能与所引档位的 plan_family 相同,不同即 KLT-L216
+                            enum:
+                            - link
+                            - addon
                           line_exits:
                             type: array
                             maxItems: 1
@@ -4318,8 +4324,8 @@ paths:
                               契约内逐条替换(升降配,2026-11-17):本条目的新订阅顶替哪份原订阅。
                               **仅在新建合同受理**,编辑合同出现即 KLT-L222。只接受三键(价格/状态/
                               row_version 等只读派生列出现即点名)。候选须同客户、status ∈ active/pending、
-                              同用途分类、同 line_exit_key、非 value_add、未被替换过(KLT-M226);
-                              同一 replaces_subscription_id 在本请求内至多一次;plan_based 条目 quantity 须为 1。
+                              同 line_exit_key、双方均 plan_family=link、未被替换过(KLT-M226);
+                              同一 replaces_subscription_id 在本请求内至多一次;link 条目 quantity 须为 1。
                               替换与合同写入同一条 dml_batch(任一条失败=整批回滚),应答回 data.replacements[]。
                             properties:
                               replaces_subscription_id:
@@ -4331,7 +4337,7 @@ paths:
                                 description: 新订阅起日,缺省=max(业务当天, 合同生效日);须 ≤ 合同止期。结束日恒取合同止期
                               term:
                                 type: string
-                                description: 订阅方式(yearly/quarterly/monthly);缺省按档位与用途分类派生
+                                description: 订阅方式(yearly/quarterly/monthly);缺省按档位与账期派生
                             required:
                             - replaces_subscription_id
                   required:
@@ -4418,9 +4424,34 @@ paths:
                         klt/contract/attachment/ 的对象键;空串=清空附件。
                     service_items:
                       type: array
-                      description: 服务构成条目(含 item_id 的增删改)
+                      description: >-
+                        服务构成条目(含 item_id 的增删改)。条目形态只含 plan_id/quantity/item_family/
+                        line_exits(item_family 由档位带入,⛔ 自造);年价/账号数/带宽等旧字段已删列,
+                        出现即视为未知键。
                       items:
                         type: object
+                        properties:
+                          item_id:
+                            type: string
+                            description: 既有条目主键(三向对比:带=UPDATE/不带=INSERT/库有载荷无=DELETE)
+                          plan_id:
+                            type: string
+                            description: 档位 ID
+                          quantity:
+                            type: integer
+                            description: 份数:link 档恒 1;addon 档≥1
+                          item_family:
+                            type: string
+                            description: 交付形态(只读确认位,可缺省):与档位 plan_family 不同即 KLT-L216
+                            enum:
+                            - link
+                            - addon
+                          line_exits:
+                            type: array
+                            maxItems: 1
+                            description: 线路出口(单选,长度 1)
+                            items:
+                              type: string
                   required:
                   - contract_id
                   - row_version
@@ -4757,9 +4788,12 @@ paths:
                     monthly_settle_cents:
                       type: integer
                       description: 不得传的只读派生列:由 `monthly_settle_of` 按年价折算落库(传值即 KLT-S20004 拒收)
-                    use_category:
+                    plan_family:
                       type: string
-                      description: 派生档用途分类(需要时填写)
+                      description: 交付形态(只读确认位,可缺省):只能与所选档位的 plan_family 相同,不同即 11103
+                      enum:
+                      - link
+                      - addon
                     term:
                       type: string
                       description: 账期(三态:yearly/quarterly/monthly)
@@ -4848,10 +4882,13 @@ paths:
                       type: integer
                       description: 只读派生列(服务端按档位折算);传即 11103
                       readOnly: true
-                    use_category:
+                    plan_family:
                       type: string
-                      description: 只读派生列(随新档位);传即 11103
+                      description: 只读派生列(随新档位);传不同值即 11103
                       readOnly: true
+                      enum:
+                      - link
+                      - addon
                     term:
                       type: string
                       description: 账期(三态:yearly/quarterly/monthly;缺省沿用原订阅或按年)
@@ -4885,10 +4922,10 @@ paths:
       summary: 替换候选探测(只读)
       description: >-
         合同新建页逐条判定「是否已有可替换的原订阅」(契约内逐条替换=升降配,2026-11-17)。
-        后端统一解析用途分类(use_category 优先,否则取档位),按「同客户 × 同分类 × 同 line_exit_key」
-        过滤(status ∈ active/pending、排除 value_add、排除已被指过的 replaces_subscription_id),
+        交付形态唯一取档位 `plan_family`(D-15),按「同客户 × 同出口 × 双方均 link」
+        过滤(status ∈ active/pending、排除 addon 档、排除已被指过的 replaces_subscription_id),
         与 /contract/create@v1 的保存期校验是**同一份函数**(succession::candidate_filter),前端不得自造候选范围。
-        index 与 service_items 的 0 基下标对齐;用途分类或出口判定不出 ⇒ KLT-L222 点名 probes[i]。
+        index 与 service_items 的 0 基下标对齐;档位或出口判定不出 ⇒ KLT-L222 点名 probes[i]。
       operationId: subscription_replacement_candidates
       tags:
       - 订阅
@@ -4924,15 +4961,9 @@ paths:
                           index:
                             type: integer
                             description: 0 基条目下标(缺省=数组位置)
-                          item_kind:
-                            type: string
-                            description: 条目类型:plan_based/custom_spec
                           plan_id:
                             type: string
-                            description: 档位 ID(plan_based;用途分类可由档位带出)
-                          use_category:
-                            type: string
-                            description: 用途分类(custom_spec;缺省时回落档位的 use_category)
+                            description: 档位 ID(交付形态由档位带出)
                           line_exits:
                             type: array
                             maxItems: 1
@@ -4950,7 +4981,7 @@ paths:
       responses:
         "200":
           description: >-
-            成功。data.probes[] 每项回 index/item_kind/plan_id/use_category(后端解析结果)/
+            成功。data.probes[] 每项回 index/plan_id/plan_family(后端按档位解析)/
             line_exit_key/line_exits/candidates[];候选行含 subscription_id/plan_id/plan_name/
             plan_kind/contract_id/contract_no/start_date/end_date/status/annual_price_cents/
             monthly_settle_cents/customized(true=定制档,须用户显式勾选确认后才允许替换)。

+ 2 - 1
src/crates/bos-core/src/error.rs

@@ -260,7 +260,8 @@ pub enum KltCode {
     /// 所选合同已开通,不能作为新订阅合同
     #[serde(rename = "KLT-M223")]
     M223,
-    /// I6:同客户同用途已有生效中/待生效订阅(返回那份订阅定位)
+    /// 已停用(原 I6:同客户同形态已有生效中/待生效订阅)。⚠️ 码位与 60217 保留不复用,
+    /// 历史日志/前端分支仍要认得出它。
     #[serde(rename = "KLT-M224")]
     M224,
     /// 承接的原订阅状态已变化,请刷新重试

+ 148 - 425
src/crates/bos-invariant/src/lib.rs

@@ -192,71 +192,48 @@ pub fn replaced_attachment_object<'a>(old: Option<&'a str>, new: Option<&str>) -
 /// 条目」下线后,合同侧不再有引用本常量的校验(`check_ip_entries` 已停用)。
 pub const IP_BANDWIDTH_TIERS: [i64; 3] = [5, 10, 30];
 
-/// 用途分类字典(订阅§2.1 五值,⛔ 缺省值=不得默认「通用办公」)。
+/// 交付形态字典(订阅§2.1 两值,⛔ 缺省值=不得默认「跨境链路」)。
+///
+/// 2026-11-19 三分类收敛(D-15):原「用途分类」五值退役,交付形态改由**档位**表达,
+/// 条目与订阅都只是引用档位上的这一列:
+/// - `link` 跨境链路:一份订阅=一条链路,席位由档位额度决定,条目份数恒 1(D-8 `ck_item_qty`);
+/// - `addon` 附加项:不占席位、不带带宽,条目份数 ≥1(如单独境外 IP)。
+///
+/// 原来的 `sub_mode`(`upgrade`/`stackable`/`customized`)随 I6 停用而不再派生:
+/// 新行写 `NULL`,读侧只回显历史值(M3 取消 I6 后该列无判据消费者)。
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum UseCategory {
-    Office,
-    Live,
-    Ai,
-    ValueAdd,
-    Customized,
+pub enum PlanFamily {
+    Link,
+    Addon,
 }
 
-impl UseCategory {
+impl PlanFamily {
     /// 解析字典原值;未知值 ⇒ `11103`(⛔ 兜底成任何一档,那等于凭空造分类)。
     pub fn parse(raw: &str) -> Result<Self, BosError> {
         Ok(match raw.trim() {
-            "office" => Self::Office,
-            "live" => Self::Live,
-            "ai" => Self::Ai,
-            "value_add" => Self::ValueAdd,
-            "customized" => Self::Customized,
-            other => return Err(BosError::bad_params(format!("未知用途分类:{other}"))),
+            "link" => Self::Link,
+            "addon" => Self::Addon,
+            other => return Err(BosError::bad_params(format!("未知交付形态:{other}"))),
         })
     }
 
     pub fn as_str(self) -> &'static str {
         match self {
-            Self::Office => "office",
-            Self::Live => "live",
-            Self::Ai => "ai",
-            Self::ValueAdd => "value_add",
-            Self::Customized => "customized",
+            Self::Link => "link",
+            Self::Addon => "addon",
         }
     }
-}
-
-/// 订阅方式(订阅§2.3 `sub_mode` 三值)。
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum SubMode {
-    Upgrade,
-    Stackable,
-    Customized,
-}
 
-impl SubMode {
-    pub fn as_str(self) -> &'static str {
+    /// 条目/订阅份数的合法域(D-8 `ck_item_qty`/`ck_sub_qty` 的同一口径):
+    /// 跨境链路恒 1(一条链路=一份),附加项 1~9999。
+    pub fn quantity_ok(self, q: i64) -> bool {
         match self {
-            Self::Upgrade => "upgrade",
-            Self::Stackable => "stackable",
-            Self::Customized => "customized",
+            Self::Link => q == 1,
+            Self::Addon => (1..=9999).contains(&q),
         }
     }
 }
 
-/// 拦「静默放宽 I6」:用途分类 → 订阅方式的唯一映射(订阅§3.3)。
-///
-/// 为什么单独成函数:I6 的谓词读 `sub_mode='upgrade'`,映射一旦默认落到 `stackable`,
-/// 同分类同出口就会被允许多份,出账直接重复。故用 `match` **穷举**——新增分类未扩映射
-/// ⇒ 编译失败,运行期⛔ 兜底分支。
-pub fn sub_mode_of(use_category: UseCategory) -> SubMode {
-    match use_category {
-        UseCategory::Office | UseCategory::Live | UseCategory::Ai => SubMode::Upgrade,
-        UseCategory::ValueAdd => SubMode::Stackable,
-        UseCategory::Customized => SubMode::Customized,
-    }
-}
-
 /// 月结算标准金额的唯一算式(订阅§3.3):`coalesce(monthly_settle_cents, floor(年价/12))`。
 ///
 /// 为什么单独成函数:这是**跨册契约**(第 6 册出账读同一式),除不尽一律**向下舍到分**
@@ -508,13 +485,6 @@ pub fn validate_contract_payload(raw: &ContractRaw<'_>) -> Result<ContractDraft,
     })
 }
 
-/// 服务构成条目形态(订阅§4.3 两种形态,一份合同可混用)。
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum ItemKind {
-    PlanBased,
-    CustomSpec,
-}
-
 /// 档位快照(调用方已取出的行,I12a 判据的输入)。
 #[derive(Debug, Clone, PartialEq, Eq)]
 pub struct PlanRef {
@@ -524,6 +494,8 @@ pub struct PlanRef {
     pub plan_kind: String,
     /// 自定义档归属客户(固定档=`None`)
     pub owner_customer_id: Option<String>,
+    /// 交付形态:`link`/`addon`(条目与订阅的形态唯一来源)
+    pub plan_family: PlanFamily,
     pub sub_account_quota: i64,
     pub annual_price_cents: i64,
     pub monthly_settle_cents: Option<i64>,
@@ -532,17 +504,16 @@ pub struct PlanRef {
 }
 
 /// 服务构成条目原始入参。
+///
+/// 2026-11-19(D-15):条目只剩「档位 × 份数」,形态、额度、价格、带宽一律随档位,
+/// 条目上不再有任何自有数值列(`item_family` 只是回传校验,不是第二来源)。
 #[derive(Debug, Clone, Default)]
 pub struct ContractItemRaw<'a> {
     pub item_id: Option<&'a str>,
-    pub item_kind: &'a str,
     pub plan_id: Option<&'a str>,
     pub quantity: Option<i64>,
-    pub account_count: Option<i64>,
-    pub bandwidth_up_mbps: Option<i64>,
-    pub bandwidth_down_mbps: Option<i64>,
-    pub annual_price_cents: Option<i64>,
-    pub monthly_settle_cents: Option<i64>,
+    /// 可选回传:给了就必须等于所引档位的 `plan_family`(前端两处表单同源,⛔ 各判各的)。
+    pub item_family: Option<&'a str>,
     pub line_exits: &'a [String],
 }
 
@@ -550,27 +521,19 @@ pub struct ContractItemRaw<'a> {
 #[derive(Debug, Clone)]
 pub struct CheckedItem<'a> {
     pub item_id: Option<&'a str>,
-    pub item_kind: ItemKind,
-    pub plan: Option<PlanRef>,
+    pub plan: PlanRef,
+    /// =所引档位的交付形态(落库列 `item_family` 的唯一取值来源)。
+    pub plan_family: PlanFamily,
     pub line_exits: Vec<String>,
     pub line_exit_key: String,
-    /// **入库值**(02 册 §2.2「套餐式必空」):套餐式三列恒 `None`=库里 NULL——额度与价格随
-    /// 所引档位,只在读侧/派生档投影按档位算,⛔ 另存一份到条目上(另存=与档位额度对不上)。
-    /// 自定义式=业主录入值(`annual` 必填、`account_count` 必填);`monthly` ⚠️ 业主填了才是
-    /// `Some`,未填=`None`(÷12 只发生在派生档投影,见 [`monthly_settle_of`])。
-    /// 为什么必须是 `Option`:§2.1「不设来源标记列」⇒ NULL 是库里唯一区分「业主未填/系统派生」
-    /// 的手段,把派生值写进列=把这个信号永久抹掉。
-    pub account_count: Option<i64>,
-    pub annual_price_cents: Option<i64>,
-    pub monthly_settle_cents: Option<i64>,
 }
 
-/// 服务构成条目逐条判定(订阅§4.3):至少一条 ⇒ `L215`;形态与字段不匹配 ⇒ `L216`;
+/// 服务构成条目逐条判定(订阅§4.3):至少一条 ⇒ `L215`;缺档位/形态串味/份数越界 ⇒ `L216`;
 /// 档位不可用/不属于该客户 ⇒ `I112`。
 ///
-/// 为什么单独成函数:两种形态的**互斥落库口径**(套餐式不落账号数与价格、自定义式不落档位)
-/// 是同一张表上的 `CHECK`,dev ⛔ `CHECK` 落库(脏数据可读纪律)⇒ 这一层是唯一防线。
-/// ⚠️ 本函数⛔ 建派生自定义档——建档紧随其后由合同保存事务执行(订阅§10.1)。
+/// 2026-11-19(D-15)判据塌成三条:**必须有档位 ∧ 份数合法(`link`=1、`addon`≥1)∧
+/// `item_family`(若回传)== 档位形态**。原先的「套餐式/自定义式」互斥与派生自定义档整链
+/// 已删除——自定义档改走目录建档(D-16),条目只引用已存在的档位。
 ///
 /// ⚠️ 偏差登记(18 册):订阅§10.1 本行「档位不可用」写 `KLT-L211`,但契约 §1 的 `L211`
 /// 语义=「签约客户不在可见/代录范围内」,档位可用性判据属 **I12a** ⇒ 本函数按
@@ -589,102 +552,51 @@ pub fn check_contract_items<'a>(
     let mut out = Vec::with_capacity(items.len());
     for (idx, it) in items.iter().enumerate() {
         let at = format!("第 {} 条服务构成条目", idx + 1);
-        let kind = match it.item_kind.trim() {
-            "plan_based" => ItemKind::PlanBased,
-            "custom_spec" => ItemKind::CustomSpec,
-            other => {
-                return Err(BosError::klt(
-                    KltCode::L216,
-                    format!("{at}:未知条目形态 {other}"),
-                ))
-            }
-        };
-        // 出口集合是 I6 判据的前置(纪律③):任何写 line_exits 的路径都必须过归一化。
+        // 出口集合是任何写 `line_exits` 路径的前置(纪律③):先归一化,再判其它。
         let exits = normalize_line_exits(it.line_exits).map_err(|_| {
             BosError::klt(KltCode::L216, format!("{at}:线路出口至少一条(形态与字段不匹配)"))
         })?;
-        let (plan, account_count, annual, monthly) = match kind {
-            ItemKind::PlanBased => {
-                if it.account_count.is_some()
-                    || it.annual_price_cents.is_some()
-                    || it.monthly_settle_cents.is_some()
-                    || it.bandwidth_up_mbps.is_some()
-                    || it.bandwidth_down_mbps.is_some()
-                {
-                    return Err(BosError::klt(
-                        KltCode::L216,
-                        format!("{at}:套餐式条目不落账号数、带宽与价格(以档位为准)"),
-                    ));
-                }
-                let plan_id = it.plan_id.ok_or_else(|| {
-                    BosError::klt(KltCode::L216, format!("{at}:套餐式条目缺档位"))
-                })?;
-                let quantity = match it.quantity {
-                    Some(q @ 1..=9999) => q,
-                    _ => return Err(BosError::bad_params(format!("{at}:数量须在 1~9999"))),
-                };
-                let plan = check_plan_available(plans.get(plan_id), customer_id)?;
-                // ⚠️ 派生额度(档位额度 × 数量,叠加档额度 0 ⇒ 不新增额度)只用于溢出校验:
-                // 套餐式条目⛔ 落 `account_count`(§2.2「套餐式必空」)⇒ 额度由读侧按档位现算。
-                let _quota_x_qty = plan.sub_account_quota.checked_mul(quantity).ok_or_else(|| {
-                    BosError::bad_params(format!("{at}:账号数(档位额度 × 数量)溢出"))
-                })?;
-                (Some(plan), None, None, None)
-            }
-            ItemKind::CustomSpec => {
-                if it.plan_id.is_some() || it.quantity.is_some() {
-                    return Err(BosError::klt(
-                        KltCode::L216,
-                        format!("{at}:自定义式条目不带档位与数量"),
-                    ));
-                }
-                let account_count = match it.account_count {
-                    Some(v @ 0..=9999) => v,
-                    _ => return Err(BosError::klt(KltCode::L216, format!("{at}:缺开通账号数目"))),
-                };
-                let up = match it.bandwidth_up_mbps {
-                    Some(v @ 1..=1000) => v,
-                    _ => return Err(BosError::klt(KltCode::L216, format!("{at}:上行带宽须在 1~1000 兆"))),
-                };
-                let down = match it.bandwidth_down_mbps {
-                    Some(v @ 1..=1000) => v,
-                    _ => return Err(BosError::klt(KltCode::L216, format!("{at}:下行带宽须在 1~1000 兆"))),
-                };
-                let annual = it.annual_price_cents.filter(|v| *v > 0 && *v <= MAX_AMOUNT_CENTS);
-                let annual = match annual {
-                    Some(v) => v,
-                    None => {
-                        return Err(BosError::klt(
-                            KltCode::L216,
-                            format!("{at}:年订阅价格必填且大于 0"),
-                        ))
-                    }
-                };
-                let monthly = match it.monthly_settle_cents {
-                    Some(v) if v > 0 && v <= MAX_AMOUNT_CENTS => Some(v),
-                    Some(_) => {
-                        return Err(BosError::klt(
-                            KltCode::L216,
-                            format!("{at}:月结算标准金额须大于 0"),
-                        ))
-                    }
-                    // ⚠️ 未填=NULL(§2.2「未填即 NULL」):÷12 的派生只发生在**派生档投影**,
-                    // 落进条目列=把「业主未填」这一唯一信号抹掉(§2.1「不设来源标记列」)。
-                    None => None,
-                };
-                let _ = (up, down);
-                (None, Some(account_count), Some(annual), monthly)
+        let plan_id = it.plan_id.map(str::trim).filter(|s| !s.is_empty()).ok_or_else(|| {
+            BosError::klt(KltCode::L216, format!("{at}:服务构成条目必须指明档位(plan_id)"))
+        })?;
+        let plan = check_plan_available(plans.get(plan_id), customer_id)?;
+        // 形态只在档位上:条目回传的 `item_family` 与档位不一致=前后端两本账,⛔ 静默以档位为准。
+        if let Some(raw) = it.item_family.map(str::trim).filter(|s| !s.is_empty()) {
+            let got = PlanFamily::parse(raw).map_err(|e| {
+                BosError::klt(KltCode::L216, format!("{at}:{e}"))
+            })?;
+            if got != plan.plan_family {
+                return Err(BosError::klt(
+                    KltCode::L216,
+                    format!(
+                        "{at}:交付形态与档位不一致(条目 {}/档位 {})",
+                        got.as_str(),
+                        plan.plan_family.as_str()
+                    ),
+                ));
             }
-        };
+        }
+        let quantity = it.quantity.unwrap_or(1);
+        if !plan.plan_family.quantity_ok(quantity) {
+            return Err(BosError::klt(
+                KltCode::L216,
+                format!(
+                    "{at}:{} 的份数必须是{}(实得 {quantity})",
+                    plan.plan_family.as_str(),
+                    if plan.plan_family == PlanFamily::Link { " 1" } else { " 1~9999" }
+                ),
+            ));
+        }
+        // 额度(档位额度 × 份数)只用于溢出校验:`addon` 额度恒 0 ⇒ 不新增额度。
+        plan.sub_account_quota
+            .checked_mul(quantity)
+            .ok_or_else(|| BosError::bad_params(format!("{at}:账号数(档位额度 × 份数)溢出")))?;
         out.push(CheckedItem {
             item_id: it.item_id,
-            item_kind: kind,
+            plan_family: plan.plan_family,
             plan,
             line_exits: exits.line_exits,
             line_exit_key: exits.line_exit_key,
-            account_count,
-            annual_price_cents: annual,
-            monthly_settle_cents: monthly,
         });
     }
     Ok(out)
@@ -1261,79 +1173,9 @@ pub fn check_i12b_same_customer(
     }
 }
 
-/// 活跃订阅行快照(事前校验的候选集,由调用方按 `status IN ('pending','active')` 取出)。
-#[derive(Debug, Clone)]
-pub struct ActiveSubscriptionRow<'a> {
-    pub subscription_id: &'a str,
-    pub customer_id: &'a str,
-    pub plan_name: &'a str,
-    pub use_category: &'a str,
-    pub line_exit_key: &'a str,
-    pub sub_mode: &'a str,
-    pub status: &'a str,
-    pub start_date: &'a str,
-    pub end_date: &'a str,
-}
-
-/// 两个闭区间是否相交(`YYYY-MM-DD` 字典序=时间序);任一端缺值 ⇒ **保守判相交**。
-///
-/// 为什么缺值判相交:期间不明的存量行⛔ 因为「读不出日期」被放过——I6 是唯一防线
-/// (dev 无 `uq_i6_active` 兜底),宁可多拦一次由人确认。
-fn periods_overlap(a_start: &str, a_end: &str, b_start: &str, b_end: &str) -> bool {
-    if a_start.trim().is_empty() || a_end.trim().is_empty() || b_start.trim().is_empty() || b_end.trim().is_empty()
-    {
-        return true;
-    }
-    a_start <= b_end && b_start <= a_end
-}
-
-/// **I6(精化)** 事前校验:同客户 × 同用途分类 × 同出口集合至多一份升降配类订阅 ⇒ `M224`。
-///
-/// 为什么单独成函数:① `sub_mode='upgrade'` 是判据的一半,漏写就把叠加档一起钉死;
-/// ② 出口判据用 `line_exit_key` 摘要(集合相等,子集⛔ 不判同一出口);
-/// ③ **事前校验宽于索引**(含 `pending`)——两份待生效订阅到生效日会同时转正,
-/// 那一刻部分唯一索引只能让一条翻转失败,用户早已收不到可操作的提示。
-///
-/// **2026-11-17 定案:判据再加「期间相交」**。状态是物化值,`active` 不等于「此刻与
-/// 新订阅争同一时段」:老订阅 12-31 到期、新订阅次年 1-01 起,是**到期续签**而非
-/// 同类冲突(旧口径会误报 `M224`,把续签路彻底堵死)。故只有期间真正重叠、
-/// 且都在 `pending`/`active`,才判同一冲突。
-///
-/// ⚠️ dev **无 `uq_i6_active` 兜底**(部分唯一索引谓词含 `CURRENT_DATE` ⇒ 非 IMMUTABLE,
-/// 建不出来),并发兜底**暂缺** ⇒ 差异登 18 册;`status='expired'` ⛔ 计入活跃集。
-pub fn check_i6_subscription(
-    customer_id: &str,
-    use_category: UseCategory,
-    line_exit_key: &str,
-    new_start: &str,
-    new_end: &str,
-    rows: &[ActiveSubscriptionRow<'_>],
-) -> Result<(), BosError> {
-    if let Some(c) = rows.iter().find(|r| {
-        r.customer_id == customer_id
-            && r.use_category == use_category.as_str()
-            && r.line_exit_key == line_exit_key
-            && r.sub_mode == SubMode::Upgrade.as_str()
-            && matches!(r.status, "active" | "pending")
-            && periods_overlap(r.start_date, r.end_date, new_start, new_end)
-    }) {
-        return Err(BosError::klt(
-            KltCode::M224,
-            format!(
-                "该客户在【{}】已有一份期间重叠的生效中/待生效订阅({},{} 至 {},订阅号 {})\
-                 :请在该行点「升降配」替换,或把新订阅开始日排到 {} 之后(到期续签)",
-                use_category.as_str(),
-                c.plan_name,
-                c.start_date,
-                c.end_date,
-                c.subscription_id,
-                c.end_date
-            ),
-        ));
-    }
-    Ok(())
-}
-
+/// **I6 已停用(2026-11-19,D-15)**:三分类收敛后 `sub_mode` 不再派生(新行恒 `NULL`),
+/// 判据失去输入 ⇒ [`check_i6_subscription`]/`ActiveSubscriptionRow` 与全部调用点已删。
+/// 码位 `M224`/60217 **保留不复用**(历史日志与前端文案分支仍要认得出它)。
 /// **I13** 试用优惠期:`trial_months ∈ 1–2` 且与 `discount_monthly_cents` **成对** ⇒ `11103`。
 ///
 /// 为什么单独成函数:0 或 3 会让「优惠期」与「整档」的边界失效并直接改变出账侧的
@@ -1629,6 +1471,7 @@ mod tests {
             plan_name: format!("{id}档"),
             plan_kind: kind.to_string(),
             owner_customer_id: owner.map(str::to_string),
+            plan_family: if quota == 0 { PlanFamily::Addon } else { PlanFamily::Link },
             sub_account_quota: quota,
             annual_price_cents: 1_000_000,
             monthly_settle_cents: None,
@@ -1642,29 +1485,26 @@ mod tests {
         m.insert("P2".to_string(), plan_of("P2", "custom", Some("C01"), 4, true));
         m.insert("P3".to_string(), plan_of("P3", "custom", Some("C99"), 6, true));
         m.insert("P4".to_string(), plan_of("P4", "fixed", None, 3, false));
+        m.insert("P5".to_string(), plan_of("P5", "fixed", None, 0, true));
         m
     }
 
     #[test]
-    fn sub_mode_of_is_exhaustive_and_never_defaults_to_stackable() {
-        // 正:三个升降配分类 + 叠加 + 定制化
-        assert_eq!(sub_mode_of(UseCategory::Office), SubMode::Upgrade);
-        assert_eq!(sub_mode_of(UseCategory::Live), SubMode::Upgrade);
-        assert_eq!(sub_mode_of(UseCategory::Ai), SubMode::Upgrade);
-        assert_eq!(sub_mode_of(UseCategory::ValueAdd), SubMode::Stackable);
-        assert_eq!(sub_mode_of(UseCategory::Customized), SubMode::Customized);
-        // 落库串与 02§2.3 的 `sub_mode` 字典一致(第6册出账分支按这三值分支)
-        assert_eq!(sub_mode_of(UseCategory::Office).as_str(), "upgrade");
-    }
-
-    #[test]
-    fn use_category_parse_accepts_dictionary_and_rejects_unknown() {
-        assert_eq!(UseCategory::parse(" value_add ").unwrap(), UseCategory::ValueAdd);
-        assert_eq!(UseCategory::Customized.as_str(), "customized");
-        // 反:字典外的值直接报错,⛔ 兜底成任何一档(那等于凭空造分类、静默放宽 I6)
-        let bad = UseCategory::parse("通用办公").unwrap_err();
-        assert_eq!(biz(&bad).0, 60004, "字段级失败一律 11103 收段码");
-        assert!(bad.to_string().contains("通用办公"));
+    fn plan_family_parse_accepts_two_values_and_rejects_unknown() {
+        assert_eq!(PlanFamily::parse(" link ").unwrap(), PlanFamily::Link);
+        assert_eq!(PlanFamily::Addon.as_str(), "addon");
+        // 反:字典外的值直接报错(旧五值一并下线,⛔ 静默映射到 link)
+        for bad_raw in ["通用办公", "office", "value_add", ""] {
+            let bad = PlanFamily::parse(bad_raw).unwrap_err();
+            assert_eq!(biz(&bad).0, 60004, "字段级失败一律 11103 收段码");
+        }
+        // 份数域(D-8 ck_item_qty):link 恒 1、addon ≥1
+        assert!(PlanFamily::Link.quantity_ok(1));
+        assert!(!PlanFamily::Link.quantity_ok(2));
+        assert!(!PlanFamily::Link.quantity_ok(0));
+        assert!(PlanFamily::Addon.quantity_ok(1));
+        assert!(PlanFamily::Addon.quantity_ok(6));
+        assert!(!PlanFamily::Addon.quantity_ok(0));
     }
 
     #[test]
@@ -1820,104 +1660,91 @@ mod tests {
     }
 
     #[test]
-    fn check_contract_items_plan_based_persists_nothing_but_the_reference() {
+    fn check_contract_items_carries_plan_family_and_quantity_rules() {
         let exits = t(&["JP", "HK", "hk"]);
+        // 跨境链路:份数恒 1;形态/额度/价格全部随档位(条目上不再有自有数值列)
         let items = vec![ContractItemRaw {
             item_id: Some("I1"),
-            item_kind: "plan_based",
             plan_id: Some("P1"),
-            quantity: Some(2),
+            quantity: Some(1),
+            item_family: Some("link"),
             line_exits: &exits,
-            ..Default::default()
         }];
         let got = check_contract_items("C01", &items, &plans_fixture()).unwrap();
         assert_eq!(got.len(), 1);
-        assert_eq!(got[0].item_kind, ItemKind::PlanBased);
-        // §2.2「套餐式必空」三列:额度与价格随所引档位 ⇒ 入库存 NULL,读侧按档位投影
-        assert_eq!(got[0].account_count, None, "套餐式不落账号数(派生值另存=与档位额度对不上)");
-        assert_eq!(got[0].annual_price_cents, None, "套餐式不另存年价(随所引档位)");
-        assert_eq!(got[0].monthly_settle_cents, None, "套餐式不落月结算标准");
-        assert_eq!(got[0].plan.as_ref().unwrap().sub_account_quota, 10, "额度只在档位上,随 plan 一起给出");
+        assert_eq!(got[0].plan_family, PlanFamily::Link, "形态的唯一来源=所引档位");
+        assert_eq!(got[0].plan.sub_account_quota, 10, "额度只在档位上,随 plan 一起给出");
         assert_eq!(got[0].line_exits, t(&["hk", "jp"]), "去重 + 小写 + 字典序");
+
+        // 附加项:份数 ≥1(单独境外 IP 这类),额度恒 0 ⇒ 不新增席位
+        let addon = vec![ContractItemRaw {
+            item_id: Some("I2"),
+            plan_id: Some("P5"),
+            quantity: Some(6),
+            item_family: None,
+            line_exits: &exits,
+        }];
+        let got = check_contract_items("C01", &addon, &plans_fixture()).unwrap();
+        assert_eq!(got[0].plan_family, PlanFamily::Addon);
+        assert_eq!(got[0].plan.sub_account_quota, 0);
     }
 
     #[test]
-    fn check_contract_items_custom_spec_and_rejections() {
+    fn check_contract_items_rejections_collapse_to_three_rules() {
         let exits = t(&["HK"]);
-        // 正:自定义式条目年价必填、月单价选填(未填=NULL,⛔ ÷12 入库)
-        let items = vec![ContractItemRaw {
-            item_kind: "custom_spec",
-            account_count: Some(5),
-            bandwidth_up_mbps: Some(10),
-            bandwidth_down_mbps: Some(50),
-            annual_price_cents: Some(600_000),
+        let link = |quantity: Option<i64>| ContractItemRaw {
+            plan_id: Some("P1"),
+            quantity,
             line_exits: &exits,
             ..Default::default()
-        }];
-        let got = check_contract_items("C01", &items, &plans_fixture()).unwrap();
-        assert_eq!(got[0].annual_price_cents, Some(600_000));
-        assert_eq!(got[0].monthly_settle_cents, None, "业主未填=NULL(÷12 只发生在派生档投影)");
-        assert_eq!(got[0].account_count, Some(5));
-
+        };
         // 反 1:零条 ⇒ L215
         assert_klt(
             &check_contract_items("C01", &[], &plans_fixture()).unwrap_err(),
             KltCode::L215,
         );
-        // 反 2:自定义式带档位 ⇒ L216(形态互斥)
-        let with_plan = vec![ContractItemRaw {
-            item_kind: "custom_spec",
-            plan_id: Some("P1"),
-            account_count: Some(5),
-            bandwidth_up_mbps: Some(10),
-            bandwidth_down_mbps: Some(50),
-            annual_price_cents: Some(600_000),
+        // 反 2:缺档位 ⇒ L216(条目只剩「档位 × 份数」,⛔ 无档位无形态)
+        let no_plan = [ContractItemRaw { quantity: Some(1), line_exits: &exits, ..Default::default() }];
+        assert_klt(
+            &check_contract_items("C01", &no_plan, &plans_fixture()).unwrap_err(),
+            KltCode::L216,
+        );
+        // 反 3:跨境链路份数 ≠ 1 ⇒ L216(D-8 ck_item_qty 的应用层同口径)
+        assert_klt(
+            &check_contract_items("C01", &[link(Some(2))], &plans_fixture()).unwrap_err(),
+            KltCode::L216,
+        );
+        // 反 4:附加项份数 0 ⇒ L216
+        let addon_zero = [ContractItemRaw {
+            plan_id: Some("P5"),
+            quantity: Some(0),
             line_exits: &exits,
             ..Default::default()
         }];
         assert_klt(
-            &check_contract_items("C01", &with_plan, &plans_fixture()).unwrap_err(),
+            &check_contract_items("C01", &addon_zero, &plans_fixture()).unwrap_err(),
             KltCode::L216,
         );
-        // 反 3:套餐式自己填三列中任何一列 ⇒ L216(形态串味;三列入参一律⛔ 出现)
-        for (at, extra) in [
-            ("年价", ContractItemRaw { annual_price_cents: Some(1), ..Default::default() }),
-            ("账号数", ContractItemRaw { account_count: Some(3), ..Default::default() }),
-            ("月结算标准", ContractItemRaw { monthly_settle_cents: Some(100), ..Default::default() }),
-        ] {
-            let mut with_price = vec![ContractItemRaw {
-                item_kind: "plan_based",
-                plan_id: Some("P1"),
-                quantity: Some(1),
-                line_exits: &exits,
-                ..Default::default()
-            }];
-            with_price[0].account_count = extra.account_count;
-            with_price[0].annual_price_cents = extra.annual_price_cents;
-            with_price[0].monthly_settle_cents = extra.monthly_settle_cents;
-            let err = check_contract_items("C01", &with_price, &plans_fixture()).unwrap_err();
-            assert_eq!(
-                biz(&err),
-                (KltCode::L216.numeric(), Some(KltCode::L216.as_str())),
-                "套餐式条目不该接受{at}入参:{err}"
-            );
-        }
-        // 反 4:出口空集 ⇒ L216
-        let no_exit = vec![ContractItemRaw {
-            item_kind: "custom_spec",
-            account_count: Some(5),
-            bandwidth_up_mbps: Some(10),
-            bandwidth_down_mbps: Some(50),
-            annual_price_cents: Some(600_000),
-            ..Default::default()
-        }];
+        // 反 5:条目回传的形态与档位不一致 ⇒ L216(前后端两本账,⛔ 静默以条目为准)
+        let mismatch = [ContractItemRaw { item_family: Some("addon"), ..link(Some(1)) }];
+        assert_klt(
+            &check_contract_items("C01", &mismatch, &plans_fixture()).unwrap_err(),
+            KltCode::L216,
+        );
+        // 反 6:形态字典外 ⇒ L216
+        let bad_family = [ContractItemRaw { item_family: Some("office"), ..link(Some(1)) }];
+        assert_klt(
+            &check_contract_items("C01", &bad_family, &plans_fixture()).unwrap_err(),
+            KltCode::L216,
+        );
+        // 反 7:出口空集 ⇒ L216
+        let no_exit = [ContractItemRaw { plan_id: Some("P1"), quantity: Some(1), ..Default::default() }];
         assert_klt(
             &check_contract_items("C01", &no_exit, &plans_fixture()).unwrap_err(),
             KltCode::L216,
         );
-        // 反 5:别人的自定义档 ⇒ I112(I12a;⛔ 用 L211,见函数 doc 的偏差登记)
-        let other_custom = vec![ContractItemRaw {
-            item_kind: "plan_based",
+        // 反 8:别人的自定义档 ⇒ I112(I12a;⛔ 用 L211,见函数 doc 的偏差登记)
+        let other_custom = [ContractItemRaw {
             plan_id: Some("P3"),
             quantity: Some(1),
             line_exits: &exits,
@@ -1929,45 +1756,6 @@ mod tests {
         );
     }
 
-    #[test]
-    fn check_contract_items_custom_spec_monthly_unset_is_null_not_div12() {
-        let exits = t(&["HK"]);
-        // 年价取 1_000_003 分(÷12 除不尽)=最能咬住「未填也被算成派生值」的那个值
-        let base = ContractItemRaw {
-            item_kind: "custom_spec",
-            account_count: Some(1),
-            bandwidth_up_mbps: Some(10),
-            bandwidth_down_mbps: Some(50),
-            annual_price_cents: Some(1_000_003),
-            line_exits: &exits,
-            ..Default::default()
-        };
-        // ① 未填月单价 ⇒ 出参 NULL(÷12 只发生在派生档投影,⛔ 落条目列)
-        let got = check_contract_items("C01", &[base.clone()], &plans_fixture()).unwrap();
-        assert_eq!(got[0].annual_price_cents, Some(1_000_003), "自定义式年价必填语义不变");
-        assert_eq!(got[0].account_count, Some(1));
-        assert_eq!(got[0].monthly_settle_cents, None, "未填=NULL(§2.1「不设来源标记列」)");
-        // 同一条目在**派生档投影**上的月结算=年价 ÷12 向下舍到分(1_000_003/12 = 83_333.58)
-        assert_eq!(
-            monthly_settle_of(got[0].monthly_settle_cents, 1_000_003),
-            83_333,
-            "floor 语义:向下舍到分,不四舍五入"
-        );
-
-        // ② 填了月单价 ⇒ 原样 Some(⛔ 被 ÷12 改写)
-        let filled = ContractItemRaw { monthly_settle_cents: Some(55_555), ..base.clone() };
-        let got = check_contract_items("C01", &[filled], &plans_fixture()).unwrap();
-        assert_eq!(got[0].monthly_settle_cents, Some(55_555));
-        assert_eq!(monthly_settle_of(got[0].monthly_settle_cents, 1_000_003), 55_555);
-
-        // 反:填了但 ≤0 ⇒ 仍 L216(报错口径⛔ 变)
-        let zero = ContractItemRaw { monthly_settle_cents: Some(0), ..base };
-        assert_klt(
-            &check_contract_items("C01", &[zero], &plans_fixture()).unwrap_err(),
-            KltCode::L216,
-        );
-    }
-
     #[test]
     fn check_ip_entries_is_request_level() {
         let rows = [IpEntryRaw { line_exit: Some("HK"), bandwidth_tier_mbps: Some(10), bandwidth_committed: None, ip_count: Some(2) }];
@@ -2109,71 +1897,6 @@ mod tests {
         assert_eq!(biz(&check_i12b_same_customer(None, "C01").unwrap_err()).0, 60005);
     }
 
-    fn sub_row<'a>(id: &'a str, cat: &'a str, key: &'a str, mode: &'a str, status: &'a str) -> ActiveSubscriptionRow<'a> {
-        ActiveSubscriptionRow {
-            subscription_id: id,
-            customer_id: "C01",
-            plan_name: "标准档",
-            use_category: cat,
-            line_exit_key: key,
-            sub_mode: mode,
-            status,
-            start_date: "2026-03-18",
-            end_date: "2027-03-17",
-        }
-    }
-
-    /// 新订阅期间(与 [`sub_row`] 的 2026-03-18 ~ 2027-03-17 相交)。
-    const NEW_START: &str = "2026-06-01";
-    const NEW_END: &str = "2027-06-01";
-
-    #[test]
-    fn check_i6_subscription_conflicts_only_on_active_and_pending() {
-        let rows = [sub_row("S1", "office", "K1", "upgrade", "active")];
-        let e = check_i6_subscription("C01", UseCategory::Office, "K1", NEW_START, NEW_END, &rows).unwrap_err();
-        assert_klt(&e, KltCode::M224);
-        // 文案四要素:冲突档名、原期间、订阅号、可操作出路(顺延开始日)
-        assert!(e.to_string().contains("标准档") && e.to_string().contains("2027-03-17") && e.to_string().contains("S1"));
-        assert!(e.to_string().contains("到期续签"), "要给出顺延出路:{e}");
-        // pending 同样拦(事前校验宽于部分唯一索引,有意为之)
-        assert_klt(
-            &check_i6_subscription(
-                "C01",
-                UseCategory::Office,
-                "K1",
-                NEW_START,
-                NEW_END,
-                &[sub_row("S2", "office", "K1", "upgrade", "pending")],
-            )
-            .unwrap_err(),
-            KltCode::M224,
-        );
-        // 反例(应当放行):expired 不计入活跃集;叠加/定制化不受 I6 约束;
-        // 换客户、换分类、换出口集合都不判同一冲突
-        assert!(check_i6_subscription("C01", UseCategory::Office, "K1", NEW_START, NEW_END, &[sub_row("S3", "office", "K1", "upgrade", "expired")]).is_ok());
-        assert!(check_i6_subscription("C01", UseCategory::ValueAdd, "K1", NEW_START, NEW_END, &[sub_row("S4", "value_add", "K1", "stackable", "active")]).is_ok());
-        assert!(check_i6_subscription("C02", UseCategory::Office, "K1", NEW_START, NEW_END, &rows).is_ok());
-        assert!(check_i6_subscription("C01", UseCategory::Live, "K1", NEW_START, NEW_END, &rows).is_ok());
-        assert!(check_i6_subscription("C01", UseCategory::Office, "K2", NEW_START, NEW_END, &rows).is_ok());
-    }
-
-    #[test]
-    fn check_i6_subscription_allows_back_to_back_renewal() {
-        // 2026-11-17 定案:老订阅 2027-03-17 到期、新订阅自 03-18 起 ⇒ 期间不相交,续签放行。
-        let rows = [sub_row("S1", "office", "K1", "upgrade", "active")];
-        assert!(check_i6_subscription("C01", UseCategory::Office, "K1", "2027-03-18", "2028-03-17", &rows).is_ok());
-        // 边界:与到期日**同日**开始=一天重叠 ⇒ 仍判冲突(替换口径:新订阅自次日或截原)
-        assert_klt(
-            &check_i6_subscription("C01", UseCategory::Office, "K1", "2027-03-17", "2028-03-16", &rows).unwrap_err(),
-            KltCode::M224,
-        );
-        // 同日开始、同月结束=完全重叠 ⇒ 冲突
-        assert_klt(
-            &check_i6_subscription("C01", UseCategory::Office, "K1", "2026-03-18", "2027-03-17", &rows).unwrap_err(),
-            KltCode::M224,
-        );
-    }
-
     #[test]
     fn check_i13_trial_months_requires_pair_and_range() {
         assert!(check_i13_trial_months(None, None).is_ok(), "非试用订阅该列为空");

+ 4 - 3
src/modules/account/src/handlers/billing.rs

@@ -1828,13 +1828,14 @@ pub(crate) async fn freeze_period(db: &UdsClient, period: &str) -> Result<bool,
                 json!(share_base), json!("period_snapshot"), json!(from.to_string()), json!(to.to_string()),
             ],
         ).await?;
-        // 在期账号(一期口径:客户现存分账号,未开通不计;天数取本期计费天数)。
+        // 在期账号(M4:**按订阅**取账号——席位归属订阅,同一客户多份订阅各算各的;未开通不计;
+        // 天数取本期计费天数)。
         dmlx(db, "receivable", "INSERT INTO billing_receivable_account (period, subscription_id, sub_account_id, in_period_days, created_at) \
              SELECT $1, $2, a.sub_account_id, $3, now() FROM sub_account a \
-             WHERE a.customer_id = $4 AND COALESCE(a.status,'') <> 'not_opened' \
+             WHERE a.subscription_id = $2 AND COALESCE(a.status,'') <> 'not_opened' \
                AND NOT EXISTS (SELECT 1 FROM billing_receivable_account x \
                     WHERE x.period=$1 AND x.subscription_id=$2 AND x.sub_account_id=a.sub_account_id)",
-            &[json!(period), json!(sid), json!(days), json!(cid)],
+            &[json!(period), json!(sid), json!(days)],
         ).await?;
     }
 

+ 225 - 106
src/modules/account/src/handlers/catalog.rs

@@ -1,7 +1,7 @@
 //! 套餐档位目录+随附成本项(第 3 册 03 章)——读写两侧真落库。
 //!
 //! 列集=一期骨架(`src/migrations/dev/20261104000001_bos_core_tables.sql:365`)
-//! + 写侧缺口列(`20261107000002`:`use_category`/`sub_account_quota`/`bandwidth_committed`/
+//! + 写侧缺口列(`20261107000002`:`plan_family`/`sub_account_quota`/`bandwidth_committed`/
 //! `bandwidth_up_mbps`/`bandwidth_down_mbps`/`customer_id`/`row_version`)
 //! + 本期缺口列(`20261109000001`:`line_exits`/`line_exit_key`/`monthly_settle_cents`/
 //! `first_referred_at`/`derived_from_contract_item_id`/`sort_no`/`updated_at`/`created_by`/`updated_by`)。
@@ -46,8 +46,8 @@ const COLUMNS_PENDING: &[&str] = &[];
 
 /// 档位类型枚举(第 3 册 §2)。
 const PLAN_KINDS: &[&str] = &["fixed", "custom"];
-/// 用途分类枚举(第 3 册 §2;建后⛔ 改)。
-const USE_CATEGORIES: &[&str] = &["office", "live", "ai", "value_add", "customized"];
+/// 交付形态枚举(D-15/D-18:两值,建后⛔ 改)。
+const PLAN_FAMILIES: &[&str] = &["link", "addon"];
 /// 新建档位的起始乐观锁版本(=列 `DEFAULT 1`,显式写死让响应能回同一真值)。
 const ROW_VERSION_INIT: i64 = 1;
 
@@ -80,14 +80,14 @@ const OPTIONS_LIMIT: i64 = 500;
 /// 弹窗⛔ 接受的只读/派生键(§3.2+§3.3:出现即 `11103`,⛔ 静默忽略——静默忽略会让前端
 /// 把派生值当可填值长期挂着)。
 const READONLY_KEYS: &[&str] = &[
-    "monthly_settle_cents",
     "sub_mode",
     "first_referred_at",
     "source",
+    "derived_from_contract_item_id",
 ];
 
 /// 建档后**一律**不可改的字段(§3.2「用途分类」+§3.3:判据是字段本身,⛔ 读 `first_referred_at`)。
-const LOCKED_ALWAYS: &[&str] = &["plan_kind", "use_category"];
+const LOCKED_ALWAYS: &[&str] = &["plan_kind", "plan_family"];
 /// 引用冻结后不可改的字段(§3.6「除 `plan_name` 外一律只读:年价、月结算标准金额、额度、
 /// 总带宽、归属客户」的列级展开)。
 const LOCKED_FROZEN: &[&str] = &[
@@ -111,27 +111,33 @@ const EDITABLE_THAWED: &[&str] = &[
     "plan_desc",
     "cost_items",
     "annual_price_cents",
+    "monthly_settle_cents",
     "sub_account_quota",
     "bandwidth_committed",
     "bandwidth_up_mbps",
     "bandwidth_down_mbps",
     "customer_id",
 ];
-/// 合同条目派生档:目录侧整单拒改(§3.6),可改集恒空。
-const EDITABLE_DERIVED: &[&str] = &[];
-
 /// 月成本只读口未接线的固定口径(§3.1:该列显示**「未配置」**,⛔ 静默按 0 显示)。
 const PLAN_COST_NOTE: &str =
     "一期月成本取数口 plan_cost_amount 未接线 ⇒ plan_cost_state=unconfigured、plan_cost_cents=null(不按 0 显示)";
 
 /// 读侧列集(`p` = `catalog_plan`,`c` = `customer`)。
 const PLAN_COLS: &str = "p.plan_id, p.plan_name, p.plan_desc, p.plan_kind, p.annual_price_cents, p.status, \
-     p.created_at, p.use_category, p.sub_account_quota, p.bandwidth_committed, p.bandwidth_up_mbps, \
+     p.created_at, p.plan_family, p.sub_account_quota, p.bandwidth_committed, p.bandwidth_up_mbps, \
      p.bandwidth_down_mbps, p.customer_id, p.row_version, p.line_exits, p.line_exit_key, \
-     p.monthly_settle_cents, p.first_referred_at, p.derived_from_contract_item_id, p.sort_no, \
-     p.updated_at, c.customer_name";
-/// 读侧 `FROM`(`customer_id` 是 `customer` 主键 ⇒ LEFT JOIN 不产生行膨胀,可安全用于 `COUNT`)。
-const PLAN_FROM: &str = "FROM catalog_plan p LEFT JOIN customer c ON c.customer_id = p.customer_id";
+     p.monthly_settle_cents, p.first_referred_at, p.sort_no, \
+     p.updated_at, c.customer_name, p.created_by, p.created_team_id, \
+     NULLIF(COALESCE(NULLIF(a.display_name,''), NULLIF(u.username,''), p.created_by), '') AS created_by_name, \
+     NULLIF(COALESCE(NULLIF(et.team_name,''), NULLIF(ot.team_name,''), \
+       CASE WHEN u.subject_type = 'hq' THEN '总运营' END), '') AS created_team_name";
+/// 读侧 `FROM`(四个 LEFT JOIN 都按主键/账号一一对应 ⇒ 不产生行膨胀,可安全用于 `COUNT`)。
+const PLAN_FROM: &str = "FROM catalog_plan p \
+     LEFT JOIN customer c ON c.customer_id = p.customer_id \
+     LEFT JOIN bos_user_binding u ON u.user_id::text = p.created_by \
+     LEFT JOIN bos_account_ext a ON a.user_id = u.user_id \
+     LEFT JOIN ent_team et ON et.team_id = u.subject_id AND u.subject_type = 'ent_team' \
+     LEFT JOIN ops_team ot ON ot.team_id = u.subject_id AND u.subject_type = 'ops_team'";
 /// 成本项读侧列集。
 const COST_COLS: &str = "item_id, plan_id, item_name, amount_cents, billing_unit, category, \
      remark, sort_no, created_at";
@@ -148,7 +154,7 @@ pub struct CatalogListReq {
     /// 归属客户精确过滤(§3.1 自定义档检索项)。
     pub customer_id: Option<String>,
     /// 用途分类过滤——§3.1 明文**只对自定义档提供**,固定档请求它 ⇒ 显式失败。
-    pub use_category: Option<String>,
+    pub plan_family: Option<String>,
 }
 
 #[derive(Deserialize)]
@@ -174,8 +180,10 @@ pub struct CatalogCreateReq {
     pub plan_kind: Option<String>,
     pub plan_name: Option<String>,
     pub plan_desc: Option<String>,
-    pub use_category: Option<String>,
+    pub plan_family: Option<String>,
     pub annual_price_cents: Option<i64>,
+    /// 月结算标准(分,选填;custom 档可录,fixed 档由年价/12 派生)。
+    pub monthly_settle_cents: Option<i64>,
     pub sub_account_quota: Option<i64>,
     pub bandwidth_committed: Option<bool>,
     pub bandwidth_up_mbps: Option<i64>,
@@ -188,7 +196,7 @@ pub struct CatalogCreateReq {
 
 /// `/catalog/update@v1`。
 ///
-/// `plan_kind`/`use_category` 未列进 openapi 的 `data`,但⛔ 靠 serde 忽略它们=
+/// `plan_kind`/`plan_family` 未列进 openapi 的 `data`,但⛔ 靠 serde 忽略它们=
 /// 静默接受越权改列,故显式收下再进同一处载荷 diff 判定(§3.6)。
 #[derive(Deserialize)]
 pub struct CatalogUpdateReq {
@@ -196,13 +204,14 @@ pub struct CatalogUpdateReq {
     pub plan_name: Option<String>,
     pub plan_desc: Option<String>,
     pub annual_price_cents: Option<i64>,
+    pub monthly_settle_cents: Option<i64>,
     pub sub_account_quota: Option<i64>,
     pub bandwidth_committed: Option<bool>,
     pub bandwidth_up_mbps: Option<i64>,
     pub bandwidth_down_mbps: Option<i64>,
     pub row_version: Option<i64>,
     pub plan_kind: Option<String>,
-    pub use_category: Option<String>,
+    pub plan_family: Option<String>,
     pub customer_id: Option<String>,
     pub cost_items: Option<Vec<CostItemReq>>,
     #[serde(flatten)]
@@ -256,7 +265,7 @@ struct PlanRow {
     #[serde(deserialize_with = "de::as_string")]
     created_at: String,
     #[serde(deserialize_with = "de::as_opt_string")]
-    use_category: Option<String>,
+    plan_family: Option<String>,
     #[serde(deserialize_with = "de::as_opt_string")]
     sub_account_quota: Option<String>,
     #[serde(deserialize_with = "de::as_opt_string")]
@@ -280,11 +289,21 @@ struct PlanRow {
     #[serde(deserialize_with = "de::as_opt_string")]
     first_referred_at: Option<String>,
     #[serde(deserialize_with = "de::as_opt_string")]
-    derived_from_contract_item_id: Option<String>,
-    #[serde(deserialize_with = "de::as_opt_string")]
     sort_no: Option<String>,
     #[serde(deserialize_with = "de::as_opt_string")]
     updated_at: Option<String>,
+    /// 建档人=`auth.user_id`(D-17)。
+    #[serde(deserialize_with = "de::as_opt_string")]
+    created_by: Option<String>,
+    /// 建档人可读名(`display_name` → 登录名 → 账号 ID 兜底)。
+    #[serde(deserialize_with = "de::as_opt_string")]
+    created_by_name: Option<String>,
+    /// 建档团队快照(D-17:建时取 `auth.subject`,团队改名不回溯)。
+    #[serde(deserialize_with = "de::as_opt_string")]
+    created_team_id: Option<String>,
+    /// 建档团队可读名(`ent_team`/`ops_team` 现名;`hq` 账号回落「总运营」)。
+    #[serde(deserialize_with = "de::as_opt_string")]
+    created_team_name: Option<String>,
 }
 
 #[derive(Deserialize)]
@@ -431,17 +450,9 @@ fn frozen_of(first_referred_at: Option<&str>) -> bool {
     norm(first_referred_at).is_some()
 }
 
-/// 合同条目派生档(§3.6:比冻结更严=目录侧整单拒改)。
-fn derived_of(contract_item_id: Option<&str>) -> bool {
-    norm(contract_item_id).is_some()
-}
-
-fn source_label(derived: bool) -> &'static str {
-    if derived {
-        "合同条目派生"
-    } else {
-        "人工建档"
-    }
+/// 建档来源(D-15:派生档整链已删 ⇒ 目录里只有人工建档)。
+fn source_label() -> &'static str {
+    "人工建档"
 }
 
 fn cross_state<T>(v: &CrossRead<T>) -> &'static str {
@@ -468,12 +479,7 @@ fn month_cost_cents_json(v: &CrossRead<i64>) -> Value {
 }
 
 /// 锁定/可改清单(确定性枚举,供弹窗置灰;判据=§3.2/§3.6)。
-fn locked_editable(frozen: bool, derived: bool) -> (Vec<&'static str>, Vec<&'static str>) {
-    if derived {
-        let mut locked = LOCKED_ALWAYS.to_vec();
-        locked.extend_from_slice(LOCKED_FROZEN);
-        return (locked, EDITABLE_DERIVED.to_vec());
-    }
+fn locked_editable(frozen: bool) -> (Vec<&'static str>, Vec<&'static str>) {
     if frozen {
         let mut locked = LOCKED_ALWAYS.to_vec();
         locked.extend_from_slice(LOCKED_FROZEN);
@@ -487,8 +493,9 @@ fn locked_editable(frozen: bool, derived: bool) -> (Vec<&'static str>, Vec<&'sta
 struct PlanPatch {
     plan_name: Option<String>,
     plan_kind: Option<String>,
-    use_category: Option<String>,
+    plan_family: Option<String>,
     annual_price_cents: Option<i64>,
+    monthly_settle_cents: Option<i64>,
     sub_account_quota: Option<i64>,
     bandwidth_committed: Option<bool>,
     bandwidth_up_mbps: Option<i64>,
@@ -527,9 +534,9 @@ fn diff_plan(cur: &PlanRow, patch: &PlanPatch) -> PlanDiff {
             d.always_hits.push("plan_kind".to_string());
         }
     }
-    if let Some(c) = patch.use_category.as_deref() {
-        if cur.use_category.as_deref().map(str::trim) != Some(c) {
-            d.always_hits.push("use_category".to_string());
+    if let Some(c) = patch.plan_family.as_deref() {
+        if cur.plan_family.as_deref().map(str::trim) != Some(c) {
+            d.always_hits.push("plan_family".to_string());
         }
     }
 
@@ -538,6 +545,11 @@ fn diff_plan(cur: &PlanRow, patch: &PlanPatch) -> PlanDiff {
             d.hits.push("annual_price_cents".to_string());
         }
     }
+    if let Some(v) = patch.monthly_settle_cents {
+        if as_i64(cur.monthly_settle_cents.as_deref()) != Some(v) {
+            d.hits.push("monthly_settle_cents".to_string());
+        }
+    }
     if let Some(v) = patch.sub_account_quota {
         if as_i64(cur.sub_account_quota.as_deref()) != Some(v) {
             d.hits.push("sub_account_quota".to_string());
@@ -625,6 +637,51 @@ fn check_price(v: Option<i64>) -> Result<i64, BosError> {
     Ok(p)
 }
 
+/// 月结算标准(分,选填):填了须 > 0 且不超上限;未填=`NULL`(⛔ 默认按年价/12 入库)。
+fn check_monthly(v: Option<i64>) -> Result<Option<i64>, BosError> {
+    match v {
+        None => Ok(None),
+        Some(m) if m > 0 && m <= MAX_AMOUNT_CENTS => Ok(Some(m)),
+        Some(m) => Err(BosError::bad_params(format!(
+            "monthly_settle_cents 须在 1~{MAX_AMOUNT_CENTS} 分之间(收到 {m})"
+        ))),
+    }
+}
+
+/// D-15/D-18 交付形态形状守卫(新增与编辑共用):
+/// `link` ⇒ 分账号额度必须 > 0,带宽按承诺位三键校验;
+/// `addon` ⇒ 额度必须为 0,且带宽三键**一律不传**(带宽随所挂跨境链路,⛔ 附加项自带带宽)。
+pub(crate) fn family_shape_guard(
+    family: &str,
+    quota: i64,
+    committed: Option<bool>,
+    up: Option<i64>,
+    down: Option<i64>,
+) -> Result<(bool, Option<i64>, Option<i64>), String> {
+    match family {
+        "link" => {
+            if quota <= 0 {
+                return Err("link 档的分账号额度必须 > 0(D-15;附加档才允许 0)".to_string());
+            }
+            let committed = committed.unwrap_or(true);
+            check_bandwidth(committed, up, down).map_err(|e| e.to_string()).map(|(u, d)| (committed, u, d))
+        }
+        _ => {
+            if quota != 0 {
+                return Err("addon 档的分账号额度必须为 0(D-15)".to_string());
+            }
+            if committed.unwrap_or(false) || up.is_some() || down.is_some() {
+                return Err(
+                    "addon 档不设带宽(D-18):bandwidth_committed/bandwidth_up_mbps/bandwidth_down_mbps 一律不传"
+                        .to_string(),
+                );
+            }
+            Ok((false, None, None))
+        }
+    }
+}
+
+
 /// 下属分账号额度(§3.2:非负、**允许 0**、上界 9999)。
 fn check_quota(v: Option<i64>) -> Result<i64, BosError> {
     let q = v.ok_or_else(|| BosError::bad_params("请填写分账号额度,可为 0"))?;
@@ -789,8 +846,7 @@ fn validate_cost_items(items: &[CostItemReq]) -> Result<Vec<CleanCostItem>, Cata
 /// 在册列给真值,缺册列([`COLUMNS_PENDING`])给 `null`。
 fn plan_json(r: PlanRow, referred: i64) -> Value {
     let frozen = frozen_of(r.first_referred_at.as_deref());
-    let derived = derived_of(r.derived_from_contract_item_id.as_deref());
-    let (locked, editable) = locked_editable(frozen, derived);
+    let (locked, editable) = locked_editable(frozen);
     let cost = month_cost_readout();
     let monthly_settle = bos_invariant::monthly_settle_of(
         as_i64(r.monthly_settle_cents.as_deref()),
@@ -806,7 +862,7 @@ fn plan_json(r: PlanRow, referred: i64) -> Value {
         "status": r.status,
         "created_at": r.created_at,
         "updated_at": r.updated_at,
-        "use_category": r.use_category,
+        "plan_family": r.plan_family,
         "sub_account_quota": as_opt_num(r.sub_account_quota.as_deref()),
         "bandwidth_committed": as_bool(r.bandwidth_committed.as_deref()),
         "bandwidth_up_mbps": as_opt_num(r.bandwidth_up_mbps.as_deref()),
@@ -818,10 +874,13 @@ fn plan_json(r: PlanRow, referred: i64) -> Value {
         "line_exits": jsonb_value(r.line_exits.as_deref()),
         "line_exit_key": r.line_exit_key,
         "first_referred_at": r.first_referred_at,
-        "derived_from_contract_item_id": r.derived_from_contract_item_id,
+        "created_by": r.created_by,
+        "created_by_name": r.created_by_name,
+        "created_team_id": r.created_team_id,
+        "created_team_name": r.created_team_name,
         "frozen": frozen,
         "referred_count": Value::from(referred),
-        "source_label": source_label(derived),
+        "source_label": source_label(),
         // §3.1 月成本三态:`null` + `unconfigured`(⛔ 塌成 0/⛔ 省掉状态键)
         "plan_cost_cents": month_cost_cents_json(&cost),
         "plan_cost_state": cross_state(&cost),
@@ -861,7 +920,7 @@ fn plan_snapshot(r: &PlanRow) -> Value {
         "plan_name": r.plan_name.clone(),
         "plan_desc": r.plan_desc.clone(),
         "plan_kind": r.plan_kind.clone(),
-        "use_category": r.use_category.clone(),
+        "plan_family": r.plan_family.clone(),
         "annual_price_cents": as_num(&r.annual_price_cents),
         "sub_account_quota": as_opt_num(r.sub_account_quota.as_deref()),
         "bandwidth_committed": as_bool(r.bandwidth_committed.as_deref()),
@@ -1298,7 +1357,12 @@ async fn do_create(
     auth: &bos_scope::AuthContext,
     b: &CatalogCreateReq,
 ) -> Result<Value, CatalogErr> {
-    gate_entry(auth)?;
+    // D-16:合同录入角色(`Ops`)可就地新建 **custom** 档(`fixed` 仍只认 Admin,
+    // 由下面的 `gate_kind_role` 按 kind 再判)。其余读写入口仍只放 Admin/OpsMain。
+    auth.require_roles(&[RoleCode::Admin, RoleCode::OpsMain, RoleCode::Ops])
+        .map_err(|_| {
+            BosError::forbidden_role("套餐档位新增仅总运营/运营主账号/合同录入可用(03 章 §3.4)")
+        })?;
 
     let kind = norm(b.plan_kind.as_deref());
     let kind = match kind.as_deref() {
@@ -1319,23 +1383,31 @@ async fn do_create(
 
     let name = check_name(b.plan_name.as_deref())?;
     let desc = check_desc(b.plan_desc.as_deref())?;
-    let cat = norm(b.use_category.as_deref());
+    let cat = norm(b.plan_family.as_deref());
     let cat = match cat.as_deref() {
-        Some(c) if USE_CATEGORIES.contains(&c) => c.to_string(),
+        Some(c) if PLAN_FAMILIES.contains(&c) => c.to_string(),
         other => {
-            _ = bos_invariant::UseCategory::parse(other.unwrap_or_default());
             return Err(BosError::bad_params(format!(
-                "use_category 只接受 {},收到:{}",
-                USE_CATEGORIES.join("/"),
+                "plan_family 只接受 {},收到:{}",
+                PLAN_FAMILIES.join("/"),
                 other.unwrap_or("(缺)")
             ))
             .into())
         }
     };
     let price = check_price(b.annual_price_cents)?;
+    let monthly = check_monthly(b.monthly_settle_cents)?;
     let quota = check_quota(b.sub_account_quota)?;
-    let committed = b.bandwidth_committed.unwrap_or(true);
-    let (bw_up, bw_down) = check_bandwidth(committed, b.bandwidth_up_mbps, b.bandwidth_down_mbps)?;
+    // D-15/D-18 三段校验:`link` 额度>0;`addon` 额度=0 且不带任何带宽值;
+    // 带宽只在 `link` 档校验(附加档不设带宽列)。
+    let (committed, bw_up, bw_down) = family_shape_guard(
+        &cat,
+        quota,
+        b.bandwidth_committed,
+        b.bandwidth_up_mbps,
+        b.bandwidth_down_mbps,
+    )
+    .map_err(BosError::bad_params)?;
 
     let cid = norm(b.customer_id.as_deref());
     if kind == "custom" && cid.is_none() {
@@ -1378,7 +1450,12 @@ async fn do_create(
 
     let seq = listq::next_seq(state.db.as_ref(), "catalog_plan", "catalog_plan", year_now()?).await?;
     let plan_id = format!("P-{seq:06}");
-    let operator = auth.subject.subject_id.clone();
+    // D-17:`created_by` =鉴权账号 ID;`created_team_id` =建档时的团队快照
+    // (`ent_team`/`ops_team` 才取 `subject_id`,`hq`/`bos_user` 留 NULL)。
+    let created_team = match auth.subject.subject_type.as_str() {
+        "ent_team" | "ops_team" => Some(auth.subject.subject_id.clone()),
+        _ => None,
+    };
 
     let mut p = Params::default();
     let phs = vec![
@@ -1387,6 +1464,7 @@ async fn do_create(
         push_opt_str(&mut p, desc),
         p.push(Value::String(kind.clone())),
         p.push(Value::from(price)),
+        push_opt_i64(&mut p, monthly),
         p.push(Value::String(cat.clone())),
         p.push(Value::from(quota)),
         p.push(Value::from(committed)),
@@ -1394,13 +1472,15 @@ async fn do_create(
         push_opt_i64(&mut p, bw_down),
         push_opt_str(&mut p, cid.clone()),
         p.push(Value::from(ROW_VERSION_INIT)),
-        p.push(Value::String(operator.clone())),
+        p.push(Value::String(auth.user_id.clone())),
+        push_opt_str(&mut p, created_team),
     ];
     let mut stmts = vec![DmlStatement::new(
         format!(
             "INSERT INTO catalog_plan (plan_id, plan_name, plan_desc, plan_kind, annual_price_cents, \
-             use_category, sub_account_quota, bandwidth_committed, bandwidth_up_mbps, \
-             bandwidth_down_mbps, customer_id, row_version, created_by) VALUES ({})",
+             monthly_settle_cents, plan_family, sub_account_quota, bandwidth_committed, \
+             bandwidth_up_mbps, bandwidth_down_mbps, customer_id, row_version, created_by, \
+             created_team_id) VALUES ({})",
             phs.join(", ")
         ),
         p.values().to_vec(),
@@ -1468,26 +1548,12 @@ async fn do_update(
 
     // ② 冻结闸门(§3.6:服务端按载荷 diff 判定,⛔ 靠前端置灰)
     let frozen = frozen_of(cur.first_referred_at.as_deref());
-    let derived = derived_of(cur.derived_from_contract_item_id.as_deref());
-    if derived {
-        return Err(CatalogErr::WithData(
-            BosError::klt(
-                KltCode::K204,
-                "该档位由合同的服务构成条目生成,请到合同管理修改条目(03 章 §3.6)",
-            ),
-            json!({
-                "derived": true,
-                "derived_from_contract_item_id": cur.derived_from_contract_item_id,
-                "referred_count": Value::from(referred_count(state.db.as_ref(), &plan_id).await?),
-                "editable_fields": EDITABLE_DERIVED,
-            }),
-        ));
-    }
     let patch = PlanPatch {
         plan_name: norm(b.plan_name.as_deref()),
         plan_kind: norm(b.plan_kind.as_deref()),
-        use_category: norm(b.use_category.as_deref()),
+        plan_family: norm(b.plan_family.as_deref()),
         annual_price_cents: b.annual_price_cents,
+        monthly_settle_cents: b.monthly_settle_cents,
         sub_account_quota: b.sub_account_quota,
         bandwidth_committed: b.bandwidth_committed,
         bandwidth_up_mbps: b.bandwidth_up_mbps,
@@ -1511,7 +1577,7 @@ async fn do_update(
     }
     if frozen && !diff.hits.is_empty() {
         let n = referred_count(state.db.as_ref(), &plan_id).await?;
-        let (locked, editable) = locked_editable(true, false);
+        let (locked, editable) = locked_editable(true);
         return Err(CatalogErr::WithData(
             BosError::klt(
                 KltCode::K204,
@@ -1551,6 +1617,25 @@ async fn do_update(
     let bw_present = b.bandwidth_committed.is_some()
         || b.bandwidth_up_mbps.is_some()
         || b.bandwidth_down_mbps.is_some();
+    // D-18:`plan_family` 建档后不可改(diff 已把改形态拦在 `always_hits`),
+    // 但编辑仍须按**库里形态**复核——`addon` 档不设带宽、额度恒 0,
+    // ⛔ 不许在编辑里补带宽或把额度从 0 改成正数。
+    if cur.plan_family.as_deref() == Some("addon") {
+        if let Some(q) = b.sub_account_quota {
+            if q != 0 {
+                return Err(BosError::bad_params(
+                    "addon 档的分账号额度必须为 0(D-15;席位只属跨境链路)",
+                )
+                .into());
+            }
+        }
+        if bw_present {
+            return Err(BosError::bad_params(
+                "addon 档不设带宽(D-18):bandwidth_committed/bandwidth_up_mbps/bandwidth_down_mbps 一律不传",
+            )
+            .into());
+        }
+    }
     let (bw_up, bw_down) = if bw_present {
         let up_eff = b
             .bandwidth_up_mbps
@@ -1562,11 +1647,11 @@ async fn do_update(
     } else {
         (None, None)
     };
-    if let Some(c) = patch.use_category.as_deref() {
-        if !USE_CATEGORIES.contains(&c) {
+    if let Some(c) = patch.plan_family.as_deref() {
+        if !PLAN_FAMILIES.contains(&c) {
             return Err(BosError::bad_params(format!(
-                "use_category 只接受 {},收到:{c}",
-                USE_CATEGORIES.join("/")
+                "plan_family 只接受 {},收到:{c}",
+                PLAN_FAMILIES.join("/")
             ))
             .into());
         }
@@ -1617,7 +1702,7 @@ async fn do_update(
             // 契约 `KLT-K204`/60205:这是**引用/占用锁定**,⛔ 走参数校验码 `60004`
             // (前端要按码分支提示「改额度请新建档位/升降配」)。文案同 03 章 §3.6。
             let n = referred_count(state.db.as_ref(), &plan_id).await?;
-            let (locked, editable) = locked_editable(frozen, false);
+            let (locked, editable) = locked_editable(frozen);
             return Err(CatalogErr::WithData(
                 BosError::klt(
                     KltCode::K204,
@@ -1654,7 +1739,7 @@ async fn do_update(
 
     let mut p = Params::default();
     let pid = p.push(Value::String(plan_id.clone()));
-    let by = p.push(Value::String(auth.subject.subject_id.clone()));
+    let by = p.push(Value::String(auth.user_id.clone()));
     let mut sets: Vec<String> = vec![
         "updated_at = NOW()".to_string(),
         format!("updated_by = {by}"),
@@ -1676,6 +1761,11 @@ async fn do_update(
         sets.push(format!("annual_price_cents = {ph}"));
         dirty = true;
     }
+    if let Some(m) = check_monthly(b.monthly_settle_cents)? {
+        let ph = p.push(Value::from(m));
+        sets.push(format!("monthly_settle_cents = {ph}"));
+        dirty = true;
+    }
     if let Some(v) = b.sub_account_quota {
         let ph = p.push(Value::from(v));
         sets.push(format!("sub_account_quota = {ph}"));
@@ -1984,7 +2074,7 @@ fn preds(
     plan_kind: Option<&str>,
     status: Option<&str>,
     customer_id: Option<&str>,
-    use_category: Option<&str>,
+    plan_family: Option<&str>,
 ) -> Vec<String> {
     let mut v = Vec::new();
     if let Some(k) = p.push_like(keyword) {
@@ -1999,8 +2089,8 @@ fn preds(
     if let Some(c) = p.push_eq(customer_id) {
         v.push(format!("p.customer_id = {c}::text"));
     }
-    if let Some(u) = p.push_eq(use_category) {
-        v.push(format!("p.use_category = {u}::text"));
+    if let Some(u) = p.push_eq(plan_family) {
+        v.push(format!("p.plan_family = {u}::text"));
     }
     v
 }
@@ -2012,11 +2102,11 @@ pub async fn get_list(
 ) -> Response {
     // §3.1:用途分类过滤**只对自定义档提供**
     if body.plan_kind.as_deref().map(str::trim) == Some("fixed")
-        && norm(body.use_category.as_deref()).is_some()
+        && norm(body.plan_family.as_deref()).is_some()
     {
         return fail(fields_err(
             "固定档列表不提供用途分类过滤(03 章 §3.1)",
-            vec![field_entry("use_category", None, "该检索项只对自定义套餐提供")],
+            vec![field_entry("plan_family", None, "该检索项只对自定义套餐提供")],
         ));
     }
     let mut p = Params::default();
@@ -2026,7 +2116,7 @@ pub async fn get_list(
         body.plan_kind.as_deref(),
         body.status.as_deref(),
         body.customer_id.as_deref(),
-        body.use_category.as_deref(),
+        body.plan_family.as_deref(),
     );
     // §3.1/§3.4:固定档⛔ 带客户谓词;自定义档必须带可见客户集合(越权的行**不出现**)
     match customer_scope_pred(&state, &auth, &mut p, "p.customer_id").await {
@@ -2201,7 +2291,7 @@ mod tests {
             annual_price_cents: "120000".to_string(),
             status: "active".to_string(),
             created_at: "2026-11-09 10:00:00+08".to_string(),
-            use_category: Some("office".to_string()),
+            plan_family: Some("link".to_string()),
             sub_account_quota: Some("5".to_string()),
             bandwidth_committed: Some("true".to_string()),
             bandwidth_up_mbps: Some("100".to_string()),
@@ -2213,9 +2303,12 @@ mod tests {
             line_exit_key: None,
             monthly_settle_cents: None,
             first_referred_at: None,
-            derived_from_contract_item_id: None,
             sort_no: Some("0".to_string()),
             updated_at: None,
+            created_by: Some("U-000001".to_string()),
+            created_by_name: Some("总运营".to_string()),
+            created_team_id: Some("OPS-000001".to_string()),
+            created_team_name: Some("平台运维一组".to_string()),
         }
     }
 
@@ -2236,9 +2329,7 @@ mod tests {
         assert!(!frozen_of(None));
         assert!(!frozen_of(Some("   ")));
         assert!(frozen_of(Some("2026-11-01 09:00:00+08")));
-        assert!(derived_of(Some("CI-0001")));
-        assert!(!derived_of(Some("")));
-        assert_eq!(source_label(true), "合同条目派生");
+        assert_eq!(source_label(), "人工建档");
     }
 
     #[test]
@@ -2252,16 +2343,13 @@ mod tests {
     }
 
     #[test]
-    fn 锁定与可改清单三形态() {
-        let (l, e) = locked_editable(false, false);
+    fn 锁定与可改清单两形态() {
+        let (l, e) = locked_editable(false);
         assert_eq!(l, LOCKED_ALWAYS);
         assert_eq!(e, EDITABLE_THAWED);
-        let (l, e) = locked_editable(true, false);
+        let (l, e) = locked_editable(true);
         assert!(l.contains(&"annual_price_cents") && l.contains(&"customer_id"));
         assert_eq!(e, EDITABLE_ALWAYS);
-        let (l, e) = locked_editable(false, true);
-        assert!(l.contains(&"use_category") && l.contains(&"bandwidth_up_mbps"));
-        assert!(e.is_empty());
     }
 
     #[test]
@@ -2288,13 +2376,13 @@ mod tests {
             &row(),
             &PlanPatch {
                 plan_kind: Some("custom".to_string()),
-                use_category: Some("live".to_string()),
+                plan_family: Some("live".to_string()),
                 annual_price_cents: Some(1),
                 customer_id: Some("C-9".to_string()),
                 ..Default::default()
             },
         );
-        assert_eq!(d.always_hits, vec!["plan_kind", "use_category"]);
+        assert_eq!(d.always_hits, vec!["plan_kind", "plan_family"]);
         assert_eq!(d.hits, vec!["annual_price_cents", "customer_id"]);
         assert!(d.customer_change);
     }
@@ -2332,7 +2420,7 @@ mod tests {
         assert_eq!(check_desc(Some("   ")).unwrap(), None::<String>);
         assert_eq!(check_desc(Some(" 报价口径 ")).unwrap().unwrap(), "报价口径");
         // 用例说明 05 的冻结口径=「仍可修改的只有三项:套餐名称、套餐说明、随附成本项」。
-        let (locked, editable) = locked_editable(true, false);
+        let (locked, editable) = locked_editable(true);
         assert_eq!(editable, vec!["plan_name", "plan_desc", "cost_items"]);
         assert!(!locked.contains(&"plan_desc"), "说明不进 §3.6 冻结清单");
         assert!(locked.contains(&"annual_price_cents"));
@@ -2359,6 +2447,35 @@ mod tests {
         assert_eq!(check_bandwidth(false, None, None).unwrap(), (None, None));
     }
 
+    #[test]
+    fn 形态形状守卫_附加档不设带宽且额度必为0() {
+        // link:额度必须 > 0;承诺带宽走两格,开关关闭两格不传
+        assert!(family_shape_guard("link", 0, Some(false), None, None).is_err());
+        assert_eq!(
+            family_shape_guard("link", 5, Some(false), None, None).unwrap(),
+            (false, None, None)
+        );
+        assert_eq!(
+            family_shape_guard("link", 5, Some(true), Some(100), Some(50)).unwrap(),
+            (true, Some(100), Some(50))
+        );
+        assert!(family_shape_guard("link", 5, Some(true), Some(100), None).is_err());
+
+        // addon:额度必须 0,且带宽三键一律不传(D-18)
+        assert_eq!(family_shape_guard("addon", 0, None, None, None).unwrap(), (false, None, None));
+        let e = family_shape_guard("addon", 3, None, None, None).unwrap_err();
+        assert!(e.contains("额度必须为 0"), "{e}");
+        for (c, u, d) in [
+            (Some(true), None, None),
+            (None, Some(100), None),
+            (None, None, Some(50)),
+            (Some(false), Some(100), Some(50)),
+        ] {
+            let e = family_shape_guard("addon", 0, c, u, d).unwrap_err();
+            assert!(e.contains("不设带宽"), "c={c:?} u={u:?} d={d:?} → {e}");
+        }
+    }
+
     #[test]
     fn 只读键出现即拒() {
         let mut m = HashMap::new();
@@ -2411,18 +2528,20 @@ mod tests {
     }
 
     #[test]
-    fn 出参带三态与派生标识() {
+    fn 出参带三态与建档归属() {
         let mut r = row();
         r.first_referred_at = Some("2026-11-02 08:00:00+08".to_string());
-        r.derived_from_contract_item_id = Some("CI-0007".to_string());
         let v = plan_json(r, 3);
         assert_eq!(v["frozen"], json!(true));
         assert_eq!(v["referred_count"], json!(3));
-        assert_eq!(v["source_label"], json!("合同条目派生"));
+        assert_eq!(v["source_label"], json!("人工建档"));
+        assert_eq!(v["created_by_name"], json!("总运营"));
+        assert_eq!(v["created_team_name"], json!("平台运维一组"));
         assert_eq!(v["plan_cost_state"], json!("unconfigured"));
         assert_eq!(v["plan_cost_cents"], Value::Null);
         assert!(v.get("plan_cost_note").is_some());
-        assert_eq!(v["editable_fields"].as_array().map(|a| a.len()), Some(0));
+        // 引用冻结 ⇒ 名称/说明/成本项仍可改(§3.6),不再是曾经的「派生档整单拒改」。
+        assert_eq!(v["editable_fields"], json!(EDITABLE_ALWAYS));
         // 人工档年价 120000 ⇒ 月结算 floor(120000/12)
         assert_eq!(plan_json(row(), 0)["monthly_settle_cents"], json!(10000));
     }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 165 - 484
src/modules/account/src/handlers/contract.rs


+ 123 - 15
src/modules/account/src/handlers/sub_provision.rs

@@ -121,22 +121,24 @@ impl SeatOutcome {
     }
 }
 
-/// 额度目标 → 分账号档案对齐(**只补不删**)。
+/// 某份订阅的额度目标 → 该订阅名下的分账号档案对齐(**只补不删**)。
 ///
-/// 入参 `target` =调用方的应占席位数(订阅§5.6 唯一求和结果)。⛔ 在本函数里再数一遍订阅。
+/// 入参 `target` =该订阅的应占席位数(=`subscription.quota_slots`,一份订阅一份席位包)。
+/// D-15 后账号归属按**订阅**(`sub_account.subscription_id`)而非客户汇总:同一客户可以同时
+/// 有 3 席与 6 席两份订阅,各自补建,互不吞并。
 ///
 /// 失败一律吞进 [`SeatOutcome::failed`](⛔ `Err`):调用点是订阅**已提交**之后,
 /// 返回 Err 会让接口把「订阅已保存」误报成失败,比留一条如实的缺口更糟(口径同交付工单生成)。
-pub(crate) async fn align_sub_accounts(state: &AppState, customer_id: &str, target: i64) -> SeatOutcome {
+pub(crate) async fn align_seats_of(state: &AppState, subscription_id: &str, target: i64) -> SeatOutcome {
     let mut out = SeatOutcome {
         target,
         ..Default::default()
     };
-    match try_align(state, customer_id, target, &mut out).await {
+    match try_align(state, subscription_id, target, &mut out).await {
         Ok(()) => out,
         Err(e) => {
             let msg = e.to_string();
-            tracing::warn!(customer_id, target, "分账号补建中断:{msg}");
+            tracing::warn!(subscription_id, target, "分账号补建中断:{msg}");
             out.failed = Some(match out.failed.take() {
                 Some(prev) => format!("{prev};末次错误={msg}"),
                 None => msg,
@@ -146,13 +148,34 @@ pub(crate) async fn align_sub_accounts(state: &AppState, customer_id: &str, targ
     }
 }
 
+/// 该订阅的归属客户(席位补建仍要主账号登录名作前缀)。
+async fn subscription_customer(state: &AppState, subscription_id: &str) -> Result<Option<String>, BosError> {
+    let mut p = Params::default();
+    let s = p.push(Value::String(subscription_id.to_string()));
+    let rows = state
+        .db
+        .query_all::<Value>(
+            &format!("SELECT customer_id AS v FROM subscription WHERE subscription_id = {s}::text"),
+            p.values(),
+        )
+        .await?;
+    Ok(rows.first().and_then(|r| cell(r, "v")))
+}
+
 async fn try_align(
     state: &AppState,
-    customer_id: &str,
+    subscription_id: &str,
     target: i64,
     out: &mut SeatOutcome,
 ) -> Result<(), BosError> {
-    out.before = seat_count(state, customer_id).await?;
+    out.before = seat_count(state, subscription_id).await?;
+    let Some(customer_id) = subscription_customer(state, subscription_id).await? else {
+        out.skipped = Some(format!(
+            "订阅 {subscription_id} 不在册 ⇒ 无法确定归属客户,本次不补建"
+        ));
+        return Ok(());
+    };
+    let customer_id = customer_id.as_str();
     // 口径 2:额度 0 且一个席位都没有 ⇒ 本来就没得建(开户只订线路不配额度的场景)。
     if target <= 0 && out.before == 0 {
         out.skipped = Some(format!(
@@ -206,7 +229,16 @@ async fn try_align(
             seq += 1;
         };
         let sub_account_id = issue_seat_id(state).await?;
-        create_seat(state, customer_id, &sub_account_id, &username, seq).await.map_err(|e| {
+        create_seat(
+            state,
+            customer_id,
+            subscription_id,
+            &sub_account_id,
+            &username,
+            seq,
+        )
+        .await
+        .map_err(|e| {
             // 已建成功的席位如实带出,便于人工核对缺口(⛔ 只报最后一错)。
             BosError::internal(format!(
                 "第 {seq} 席({username})建号未成功:{e}。本次已建 {} 席,缺口将在下一次额度对齐时\
@@ -220,13 +252,13 @@ async fn try_align(
     Ok(())
 }
 
-/// 该客户的分账号档案数(⛔ 只数在用:缩减⛔ 删号 ⇒ 未开通/停用同样占位)。
-async fn seat_count(state: &AppState, customer_id: &str) -> Result<i64, BosError> {
+/// 该订阅名下的分账号档案数(⛔ 只数在用:缩减⛔ 删号 ⇒ 未开通/停用同样占位)。
+async fn seat_count(state: &AppState, subscription_id: &str) -> Result<i64, BosError> {
     let mut p = Params::default();
-    let c = p.push(Value::String(customer_id.to_string()));
+    let s = p.push(Value::String(subscription_id.to_string()));
     total(
         state.db.as_ref(),
-        &format!("FROM sub_account s WHERE s.customer_id = {c}::text"),
+        &format!("FROM sub_account s WHERE s.subscription_id = {s}::text"),
         p.values(),
     )
     .await
@@ -364,6 +396,7 @@ async fn seat_id_taken(state: &AppState, sub_account_id: &str) -> Result<bool, B
 async fn create_seat(
     state: &AppState,
     customer_id: &str,
+    subscription_id: &str,
     sub_account_id: &str,
     username: &str,
     seq: u32,
@@ -416,12 +449,14 @@ async fn create_seat(
             vec![Value::String(user_id.clone())],
         ),
         DmlStatement::new(
-            "INSERT INTO sub_account (sub_account_id, customer_id, user_id, display_name, purpose, \
-             net_account, status) VALUES ($1::text, $2::text, $3::int8, NULL, NULL, NULL, \
-             'not_opened')".to_string(),
+            "INSERT INTO sub_account (sub_account_id, customer_id, subscription_id, user_id, \
+             display_name, purpose, net_account, status) \
+             VALUES ($1::text, $2::text, $3::text, $4::int8, NULL, NULL, NULL, 'not_opened')"
+                .to_string(),
             vec![
                 Value::String(sub_account_id.to_string()),
                 Value::String(customer_id.to_string()),
+                Value::String(subscription_id.to_string()),
                 Value::String(user_id),
             ],
         ),
@@ -440,3 +475,76 @@ async fn create_seat(
     }
     Ok(())
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn 席位尾号只认主账号前缀后的纯数字() {
+        // 正常形态:`lg-3` ⇒ 3(序号从 1 起)
+        assert_eq!(seat_seq(Some("lg-3")), Some(3));
+        assert_eq!(seat_seq(Some("clkj-12")), Some(12));
+        // 0/空/非数字/缺尾号 ⇒ 不猜
+        assert_eq!(seat_seq(Some("lg-0")), None);
+        assert_eq!(seat_seq(Some("lg-")), None);
+        assert_eq!(seat_seq(Some("lg-3a")), None);
+        assert_eq!(seat_seq(Some("lg")), None);
+        assert_eq!(seat_seq(None), None);
+    }
+
+    #[test]
+    fn 席位昵称按占位口径不给真实姓名() {
+        assert_eq!(seat_nickname(1), "席位 1");
+        assert_eq!(seat_nickname(9), "席位 9");
+    }
+
+    #[test]
+    fn 补建结果三种口径不塌成空话() {
+        let made = SeatOutcome {
+            target: 5,
+            before: 2,
+            created: vec!["lg-3".into(), "lg-4".into(), "lg-5".into()],
+            ..Default::default()
+        };
+        assert!(made.note().contains("补建 3 个"));
+        let j = made.to_json();
+        assert_eq!(j["quota_seats_target"], 5);
+        assert_eq!(j["seats_before"], 2);
+        assert_eq!(j["seats_created"], 3);
+        assert_eq!(j["created_usernames"][0], "lg-3");
+
+        // 额度目标 0/主账号未定稿 ⇒ 说明原因,⛔ 说成「已补齐」
+        let skipped = SeatOutcome { target: 5, before: 0, skipped: Some("主账号登录名未定稿".into()), ..Default::default() };
+        assert!(skipped.note().contains("未补建"));
+        assert_eq!(skipped.to_json()["skipped_reason"], "主账号登录名未定稿");
+
+        // 中断 ⇒ 已建部分保留、如实写失败原因(无新建时 note 直说未完成)
+        let failed = SeatOutcome {
+            target: 5,
+            before: 0,
+            failed: Some("平台建号失败".into()),
+            ..Default::default()
+        };
+        assert!(failed.note().contains("未完成"));
+        assert_eq!(failed.to_json()["failed_reason"], "平台建号失败");
+        // 部分建成:note 先说补了几席(已建部分是完整三件套,⛔ 回滚)
+        let partial = SeatOutcome {
+            target: 5,
+            before: 0,
+            created: vec!["lg-1".into()],
+            failed: Some("平台建号失败".into()),
+            ..Default::default()
+        };
+        assert!(partial.note().contains("补建 1 个"));
+        assert_eq!(partial.to_json()["failed_reason"], "平台建号失败");
+    }
+
+    #[test]
+    fn LIKE转义不把下划线当通配() {
+        assert_eq!(like_escape("lg_1"), "lg\\_1");
+        assert_eq!(like_escape("100%"), "100\\%");
+        assert_eq!(like_escape("a\\b"), "a\\\\b");
+        assert_eq!(like_escape("clkj"), "clkj");
+    }
+}

+ 132 - 197
src/modules/account/src/handlers/subscription.rs

@@ -11,7 +11,7 @@
 //!   读侧⛔ 现取 `catalog_plan`(`to_json` 的 `plan_name` 走快照列)。
 //! * 金额与状态一律走 [`bos_invariant`]:`monthly_settle_of`=月结算唯一折算点、
 //!   `subscription_status_of`=状态唯一判据、`in_use_quota_sum_batch`=额度求和唯一实现、
-//!   `check_i6_subscription`=I6 唯一实现(违规即 `KLT-M224` 并带那份订阅的定位)。
+//!   I6 已于 2026-11-19 停用(D-15:`sub_mode` 不再派生),码位 `KLT-M224` 保留不复用。
 //!
 //! ## 写侧事务落点(§5.2 六步)
 //!
@@ -33,10 +33,10 @@ use bos_api::AppState;
 use bos_core::page::PageQuery;
 use bos_core::{BosError, KltCode, RoleCode};
 use bos_invariant::{
-    check_i12b_same_customer, check_i13_trial_months, check_i6_subscription, check_plan_available,
+    check_i12b_same_customer, check_i13_trial_months, check_plan_available,
     check_subscription_deletable, contracts_opened, in_use_quota_sum_batch, monthly_settle_of,
-    normalize_line_exits, sub_mode_of, subscription_status_of, ActiveSubscriptionRow, CrossRead,
-    NormalizedExits, Opened, OpenedProbe, PlanRef, SubMode, SubscriptionBlocks, UseCategory,
+    normalize_line_exits, subscription_status_of, CrossRead,
+    NormalizedExits, Opened, OpenedProbe, PlanFamily, PlanRef, SubscriptionBlocks,
     MAX_AMOUNT_CENTS,
 };
 use bos_platform::clients::uds::{de, DmlStatement};
@@ -60,7 +60,7 @@ const TERMS: [&str; 3] = ["yearly", "quarterly", "monthly"];
 pub(crate) const IN_USE_STATUS: [&str; 2] = ["pending", "active"];
 
 /// 六项只读派生列+变更链指针:新建载荷出现即 `11103`(§5.2 段 3/4、§2.3)。
-const CREATE_READ_ONLY: [&str; 8] = [
+const CREATE_READ_ONLY: [&str; 9] = [
     "annual_price_cents",
     "monthly_settle_cents",
     "end_date",
@@ -69,6 +69,8 @@ const CREATE_READ_ONLY: [&str; 8] = [
     "order_no",
     "actual_opened_at",
     "replaces_subscription_id",
+    // D-15:`item_family` 随所引合同条目带入并冻结(合同侧载荷已拒传),订阅侧⛔ 再收一份。
+    "item_family",
 ];
 
 /// 升降配额外只读项:⛔ 换客户(`customer_id` 只做一致性校验),用途分类跟着新档位走
@@ -76,7 +78,7 @@ const CREATE_READ_ONLY: [&str; 8] = [
 /// 契约(`openapi.yaml` `/subscription/change@v1`)列为必填「新合同/新条目」,此前误入拒收表
 /// ⇒ 前端按契约提交必吃 `KLT-S20004`,升降配在界面与接口两侧都不可用(P5-D1)。
 const CHANGE_READ_ONLY: [&str; 8] = [
-    "use_category",
+    "plan_family",
     "annual_price_cents",
     "monthly_settle_cents",
     "end_date",
@@ -107,16 +109,17 @@ pub(crate) const TICKET_UNCONFIGURED_NOTE: &str = "开户工单只读口本轮
 
 /// 统一取列(写侧回读、列表、详情、I6 取数共用一份列集=⛔ 三处漂移)。
 const SELECT_COLS: &str = "SELECT s.subscription_id, s.customer_id, s.contract_id, s.contract_item_id, \
-     s.plan_id, s.plan_name, s.plan_kind, s.plan_owner_customer_id, s.status, s.use_category, s.sub_mode, \
+     s.plan_id, s.plan_name, s.plan_kind, s.plan_owner_customer_id, s.status, s.plan_family, s.sub_mode, \
      s.line_exits, s.line_exit_key, s.start_date, s.end_date, s.term, s.trial_months, \
      s.discount_monthly_cents, s.annual_price_cents, s.monthly_settle_cents, s.quota_slots, \
      s.quantity, s.replaces_subscription_id, s.order_no, s.actual_opened_at, s.effective_date, \
      s.expire_date, s.created_at, s.row_version";
 
-/// 档位取列(`p`=`catalog_plan`)。
+/// 档位取列(`p`=`catalog_plan`)。`plan_family` 是条目/订阅形态的**唯一来源**;
+/// 派生档整链已删(D-15)⇒ 不再有 `derived_from_contract_item_id`。
 const PLAN_COLS: &str = "SELECT p.plan_id, p.plan_name, p.plan_kind, p.customer_id, p.status, \
-     p.use_category, p.sub_account_quota, p.annual_price_cents, \
-     p.monthly_settle_cents, p.line_exits, p.derived_from_contract_item_id, p.first_referred_at";
+     p.plan_family, p.sub_account_quota, p.annual_price_cents, \
+     p.monthly_settle_cents, p.line_exits, p.first_referred_at";
 
 // ───────────────────────── 入参 ─────────────────────────
 
@@ -135,8 +138,8 @@ pub struct SubscriptionCreateReq {
     pub start_date: Option<String>,
     /// 唯一可录的周期入参;缺省按年(§5.2)。
     pub term: Option<String>,
-    /// 仅当所选档位未预置用途分类(合同条目派生档)时必录(§5.2)。
-    pub use_category: Option<String>,
+    /// 交付形态(只读确认位):只能与所选档位的 `plan_family` 相同,不同即 `11103`。
+    pub plan_family: Option<String>,
     pub trial_months: Option<i64>,
     pub discount_monthly_cents: Option<i64>,
     /// 档位份数(2026-11-17):缺省 1;仅可叠加档(叠加增值)允许 > 1,其余档给 > 1 即拒。
@@ -444,7 +447,8 @@ pub(crate) struct SubRow {
     #[serde(deserialize_with = "de::as_string")]
     pub(crate) status: String,
     #[serde(deserialize_with = "de::as_opt_string")]
-    pub(crate) use_category: Option<String>,
+    pub(crate) plan_family: Option<String>,
+    /// 历史值:三分类收敛后新行恒 `NULL`(I6 停用),读侧只做只读回显。
     #[serde(deserialize_with = "de::as_opt_string")]
     pub(crate) sub_mode: Option<String>,
     pub(crate) line_exits: Option<Value>,
@@ -524,7 +528,7 @@ fn to_json(
         "plan_owner_customer_id": r.plan_owner_customer_id,
         "status": r.status,
         "status_display": { "key": key, "label": label, "note": note },
-        "use_category": r.use_category,
+        "plan_family": r.plan_family,
         "sub_mode": r.sub_mode,
         "line_exits": exits_json(r.line_exits.as_ref()),
         "line_exit_key": r.line_exit_key,
@@ -638,7 +642,7 @@ pub(crate) async fn subs_of_customer(state: &AppState, customer_id: &str) -> Res
     state.db.query_all::<SubRow>(&sql, p.values()).await
 }
 
-/// 档位行(含可用区间与派生链)。`succession` 公共层读同一形态 ⇒ 字段 `pub(crate)`。
+/// 档位行(含可用区间与首次引用打点)。`succession` 公共层读同一形态 ⇒ 字段 `pub(crate)`。
 #[derive(Deserialize)]
 pub(crate) struct PlanRow {
     #[serde(deserialize_with = "de::as_string")]
@@ -651,8 +655,9 @@ pub(crate) struct PlanRow {
     pub(crate) customer_id: Option<String>,
     #[serde(deserialize_with = "de::as_string")]
     pub(crate) status: String,
+    /// 交付形态 `link`/`addon`:条目与订阅的形态**只从这里来**(库上 `ck_plan_family` 兜底)。
     #[serde(deserialize_with = "de::as_opt_string")]
-    pub(crate) use_category: Option<String>,
+    pub(crate) plan_family: Option<String>,
     #[serde(deserialize_with = "de::as_opt_string")]
     pub(crate) sub_account_quota: Option<String>,
     #[serde(deserialize_with = "de::as_string")]
@@ -660,20 +665,30 @@ pub(crate) struct PlanRow {
     #[serde(deserialize_with = "de::as_opt_string")]
     pub(crate) monthly_settle_cents: Option<String>,
     pub(crate) line_exits: Option<Value>,
-    #[serde(deserialize_with = "de::as_opt_string")]
-    pub(crate) derived_from_contract_item_id: Option<String>,
     /// 首次引用打点:`Some` ⇒ 该档已被引用过(§5.2「已引用过的档位⛔ 下架」同源)。
     #[serde(deserialize_with = "de::as_opt_string")]
     pub(crate) first_referred_at: Option<String>,
 }
 
 impl PlanRow {
+    /// 交付形态(库上 `ck_plan_family` 已保证只有两值;缺失/脏值按 `link` 处理并落读侧告警)。
+    pub(crate) fn family(&self) -> PlanFamily {
+        match self.plan_family.as_deref().map(PlanFamily::parse) {
+            Some(Ok(f)) => f,
+            _ => {
+                tracing::warn!(plan_id = %self.plan_id, raw = ?self.plan_family, "档位交付形态缺失/非法,按 link 处理");
+                PlanFamily::Link
+            }
+        }
+    }
+
     pub(crate) fn to_ref(&self) -> PlanRef {
         PlanRef {
             plan_id: self.plan_id.clone(),
             plan_name: self.plan_name.clone(),
             plan_kind: self.plan_kind.clone(),
             owner_customer_id: opt_trim(self.customer_id.as_ref()).map(str::to_string),
+            plan_family: self.family(),
             sub_account_quota: self
                 .sub_account_quota
                 .as_deref()
@@ -756,31 +771,26 @@ pub(crate) async fn contract_row(state: &AppState, contract_id: &str) -> Result<
     state.db.query_one::<ContractRow>(&sql, p.values()).await
 }
 
-/// 合同服务构成条目(`custom_spec`=合同条目派生档的来源)。`succession` 共用 ⇒ 字段 `pub(crate)`。
+/// 合同服务构成条目(`plan_id` 必填:条目只剩「档位 × 份数」)。`succession` 共用 ⇒ 字段 `pub(crate)`。
 #[derive(Deserialize)]
 pub(crate) struct ItemRow {
     #[serde(deserialize_with = "de::as_string")]
     pub(crate) item_id: String,
     #[serde(deserialize_with = "de::as_string")]
     pub(crate) contract_id: String,
-    #[serde(deserialize_with = "de::as_string")]
-    pub(crate) item_kind: String,
     #[serde(deserialize_with = "de::as_opt_string")]
     pub(crate) plan_id: Option<String>,
-    /// 套餐式条目的档位份数(2026-11-17:随条目带入订阅 `subscription.quantity`)。
+    /// 档位份数(2026-11-17:随条目带入订阅 `subscription.quantity`)。
     #[serde(deserialize_with = "de::as_opt_string")]
     pub(crate) quantity: Option<String>,
+    /// 交付形态(落库列;=所引档位的 `plan_family`,应用层已校验一致)。
     #[serde(deserialize_with = "de::as_opt_string")]
-    pub(crate) derived_plan_id: Option<String>,
-    #[serde(deserialize_with = "de::as_opt_string")]
-    pub(crate) use_category: Option<String>,
-    #[serde(deserialize_with = "de::as_opt_string")]
-    pub(crate) annual_price_cents: Option<String>,
+    pub(crate) item_family: Option<String>,
     pub(crate) line_exits: Option<Value>,
 }
 
-const ITEM_COLS: &str = "SELECT i.item_id, i.contract_id, i.item_kind, i.plan_id, i.quantity, \
-     i.derived_plan_id, i.use_category, i.annual_price_cents, i.line_exits";
+const ITEM_COLS: &str = "SELECT i.item_id, i.contract_id, i.plan_id, i.quantity, \
+     i.item_family, i.line_exits";
 
 pub(crate) async fn items_of_contracts(
     state: &AppState,
@@ -852,8 +862,8 @@ async fn opened_map_for(
 
 /// `POST /subscription/plan_options@v1`。
 ///
-/// 两段候选=本客户自定义档(**含合同条目派生档**)+全部固定档,⛔ 他客户自定义档;
-/// 每行带只读 `sub_mode`(`sub_mode_of(用途分类)`)与可选性/不可选原因。
+/// 两段候选=本客户自定义档 + 全部固定档,⛔ 他客户自定义档;
+/// 每行带只读 `plan_family`(交付形态)与可选性/不可选原因。
 pub async fn plan_options(
     State(state): State<AppState>,
     RequireAuth(auth): RequireAuth,
@@ -900,24 +910,13 @@ pub async fn plan_options(
         .map(|o| {
             let pr = o.to_ref();
             let (available, reason) = plan_selectability(&pr, &cid);
-            let derived = o.derived_from_contract_item_id.is_some();
-            let sub_mode = match opt_trim(o.use_category.as_ref()) {
-                Some(uc) => UseCategory::parse(uc)
-                    .ok()
-                    .map(|c| sub_mode_of(c).as_str().to_string()),
-                None => None,
-            };
             let rc = referred.get(&o.plan_id).copied().unwrap_or(0);
             json!({
                 "plan_id": o.plan_id,
                 "plan_name": o.plan_name,
                 "plan_kind": o.plan_kind,
                 "owner_customer_id": o.customer_id,
-                "derived": derived,
-                "source_label": if derived { Some("合同条目派生") } else { None },
-                "derived_from_contract_item_id": o.derived_from_contract_item_id,
-                "use_category": o.use_category,
-                "sub_mode": sub_mode,
+                "plan_family": pr.plan_family.as_str(),
                 "annual_price_cents": as_num(&o.annual_price_cents),
                 "monthly_settle_cents": as_num(&o.monthly().to_string()),
                 "sub_account_quota": as_opt_num(o.sub_account_quota.as_deref()),
@@ -934,8 +933,8 @@ pub async fn plan_options(
         "items": items,
         "total": items.len(),
         "notes": [
-            "「订阅方式」由用途分类经 sub_mode_of 折算,前端不重实现;派生自定义档未预置用途分类时\
-             sub_mode=null,新订时由运营必录用途分类。",
+            "「交付形态」(link/addon)与额度、带宽、出口一并随档位,前端不重实现;\
+             附加项额度恒 0,条目/订阅份数 ≥1;跨境链路份数恒 1。",
             TICKET_UNCONFIGURED_NOTE,
         ],
         "columns_pending": COLUMNS_PENDING,
@@ -970,7 +969,7 @@ pub(crate) struct SubAuditView {
     status: String,
     plan_id: Option<String>,
     plan_name: Option<String>,
-    use_category: Option<String>,
+    plan_family: Option<String>,
     sub_mode: Option<String>,
     line_exits: Option<Value>,
     term: Option<String>,
@@ -994,7 +993,7 @@ impl SubAuditView {
             status: r.status.clone(),
             plan_id: r.plan_id.clone(),
             plan_name: r.plan_name.clone(),
-            use_category: r.use_category.clone(),
+            plan_family: r.plan_family.clone(),
             sub_mode: r.sub_mode.clone(),
             line_exits: r.line_exits.clone(),
             term: r.term.clone(),
@@ -1018,7 +1017,7 @@ impl SubAuditView {
             "status": self.status,
             "plan_id": self.plan_id,
             "plan_name": self.plan_name,
-            "use_category": self.use_category,
+            "plan_family": self.plan_family,
             "sub_mode": self.sub_mode,
             "line_exits": self.line_exits,
             "term": self.term,
@@ -1203,11 +1202,7 @@ pub async fn contract_options(
             Err(e) => return json_err(e),
         }
     }
-    let plan_ids: Vec<String> = items
-        .iter()
-        .flat_map(|i| [i.plan_id.clone(), i.derived_plan_id.clone()])
-        .flatten()
-        .collect();
+    let plan_ids: Vec<String> = items.iter().filter_map(|i| i.plan_id.clone()).collect();
     let plans = match plan_rows(&state, &plan_ids).await {
         Ok(v) => v,
         Err(e) => return json_err(e),
@@ -1219,7 +1214,7 @@ pub async fn contract_options(
             .iter()
             .filter(|i| i.contract_id == c.contract_id && !referenced.contains(&i.item_id))
             .map(|i| {
-                let pid = opt_trim(i.derived_plan_id.as_ref()).or_else(|| opt_trim(i.plan_id.as_ref()));
+                let pid = opt_trim(i.plan_id.as_ref());
                 let pr = pid.and_then(|id| plan_by_id.get(id)).map(|r| r.to_ref());
                 let (available, reason) = match pr.as_ref() {
                     Some(pr) => plan_selectability(pr, &cid),
@@ -1227,18 +1222,13 @@ pub async fn contract_options(
                 };
                 json!({
                     "item_id": i.item_id,
-                    "item_kind": i.item_kind,
                     "plan_id": pid,
                     "plan_name": pr.as_ref().map(|p| p.plan_name.clone()),
-                    "derived": i.item_kind == "custom_spec",
-                    "source_label": if i.item_kind == "custom_spec" { Some("合同条目派生") } else { None },
-                    "use_category": i.use_category,
-                    // 套餐式条目⛔ 存价(02 册 §2.2「价格随所引档位,条目上⛔ 不另存」)⇒ 库里是
-                    // NULL,这里从所引档位取;自定义式条目=业主录入值照实投影(P-47 入库口径)。
-                    "annual_price_cents": match i.annual_price_cents.as_deref() {
-                        Some(_) => as_opt_num(i.annual_price_cents.as_deref()),
-                        None => json!(pr.as_ref().map(|p| p.annual_price_cents)),
-                    },
+                    "item_family": i.item_family,
+                    // 份数仍在条目上(订阅 `quantity` 由它带入;`addon` 可 > 1,`link` 恒 1)。
+                    "quantity": i.quantity,
+                    // 价格随所引档位(条目上不再有价格列)⇒ 一律从档位投影。
+                    "annual_price_cents": pr.as_ref().map(|p| p.annual_price_cents),
                     "line_exits": exits_json(i.line_exits.as_ref()),
                     "available": available,
                     "unavailable_reason": reason,
@@ -1289,30 +1279,22 @@ fn push_in_owned(p: &mut Params, col: &str, ids: &[String]) -> Result<String, Bo
 
 // ───────────────────────── 写侧:共用折算 ─────────────────────────
 
-/// 用途分类:由套餐带入(⛔ 改写);派生自定义档未预置时由运营必录(§5.2)。
-fn category_of(payload: Option<&String>, plan: &PlanRow) -> Result<UseCategory, BosError> {
-    match opt_trim(plan.use_category.as_ref()) {
-        Some(v) => {
-            let plan_cat = UseCategory::parse(v)?;
-            if let Some(raw) = opt_trim(payload) {
-                let got = UseCategory::parse(raw)?;
-                if got != plan_cat {
-                    return Err(BosError::bad_params(format!(
-                        "use_category 由套餐用途分类带入({}),不改写为 {}",
-                        plan_cat.as_str(),
-                        got.as_str()
-                    )));
-                }
-            }
-            Ok(plan_cat)
+/// 交付形态:**只读档位**(D-15:条目/订阅都不再是第二来源)。
+///
+/// 载荷里带了不同值 ⇒ `11103`(⛔ 静默改写);带了同值=确认回显,放行。
+fn family_of(payload: Option<&String>, plan: &PlanRow) -> Result<PlanFamily, BosError> {
+    let plan_family = plan.family();
+    if let Some(raw) = opt_trim(payload) {
+        let got = PlanFamily::parse(raw)?;
+        if got != plan_family {
+            return Err(BosError::bad_params(format!(
+                "plan_family 由套餐带入({}),不改写为 {}",
+                plan_family.as_str(),
+                got.as_str()
+            )));
         }
-        None => match opt_trim(payload) {
-            Some(v) => UseCategory::parse(v),
-            None => Err(BosError::bad_params(
-                "use_category 必录:所选档位未预置用途分类(合同条目派生档),由运营选定后带入订阅方式",
-            )),
-        },
     }
+    Ok(plan_family)
 }
 
 /// 周期与价格的派生结果(§5.2 段 3/4)。`succession` 公共层共用 ⇒ 字段 `pub(crate)`。
@@ -1367,35 +1349,6 @@ pub(crate) fn derive_exits(item: Option<&ItemRow>, plan: &PlanRow) -> Result<Nor
     normalize_line_exits(&raw)
 }
 
-/// I6 取数:该客户全部订阅(判据在 `check_i6_subscription` 内部,本处⛔ 预筛状态)。
-pub(crate) async fn i6_rows(state: &AppState, customer_id: &str, exclude: Option<&str>) -> Result<Vec<SubRow>, BosError> {
-    Ok(subs_of_customer(state, customer_id)
-        .await?
-        .into_iter()
-        .filter(|r| Some(r.subscription_id.as_str()) != exclude)
-        .collect())
-}
-
-pub(crate) fn i6_borrow(rows: &[SubRow]) -> Vec<ActiveSubscriptionRow<'_>> {
-    rows.iter()
-        .map(|r| ActiveSubscriptionRow {
-            subscription_id: r.subscription_id.as_str(),
-            customer_id: r.customer_id.as_str(),
-            plan_name: r.plan_name.as_deref().unwrap_or_default(),
-            use_category: r.use_category.as_deref().unwrap_or_default(),
-            line_exit_key: r.line_exit_key.as_deref().unwrap_or_default(),
-            sub_mode: r.sub_mode.as_deref().unwrap_or_default(),
-            status: r.status.as_str(),
-            start_date: r.start_date.as_deref().unwrap_or_default(),
-            end_date: r
-                .end_date
-                .as_deref()
-                .or(r.expire_date.as_deref())
-                .unwrap_or_default(),
-        })
-        .collect()
-}
-
 /// 额度对齐目标(§5.6 唯一求和实现=`in_use_quota_sum_batch`,⛔ 本口另实现一套计数)。
 ///
 /// `extra_plan` = 本次要写入/要摘除的订阅所引档位:`Some` 计入(新订、升降配),
@@ -1506,7 +1459,7 @@ pub(crate) async fn align_quota_for_customers(
     let in_s: Vec<String> = IN_USE_STATUS.iter().map(|s| s.to_string()).collect();
     let in_s = push_in(&mut p, "s.status", &in_s, "text");
     let sql = format!(
-        "SELECT s.customer_id, s.plan_id FROM subscription s \
+        "SELECT s.customer_id, s.plan_id, s.subscription_id, s.quota_slots FROM subscription s \
          WHERE {in_c} AND {in_s} AND s.plan_id IS NOT NULL"
     );
     #[derive(Deserialize)]
@@ -1515,6 +1468,10 @@ pub(crate) async fn align_quota_for_customers(
         customer_id: String,
         #[serde(deserialize_with = "de::as_string")]
         plan_id: String,
+        #[serde(deserialize_with = "de::as_string")]
+        subscription_id: String,
+        #[serde(deserialize_with = "de::as_string")]
+        quota_slots: String,
     }
     let sub_rows = state.db.query_all::<SubPlanRow>(&sql, p.values()).await?;
 
@@ -1567,12 +1524,18 @@ pub(crate) async fn align_quota_for_customers(
                 continue;
             }
         };
-        // D-41(需求§4.2):额度目标一旦算出就顺手把分账号**补建**到位——⛔ 只在「额度发生
-        // 变化」时才补(主账号晚于订阅开通、上一轮补建失败的客户,都靠这里在后续轮次收敛),
-        // 且**只补不删**(缩减侧只记说明)。失败⛔ 影响额度结论,单独记一条等下一轮继续补。
-        let seats = super::sub_provision::align_sub_accounts(state, cid, target).await;
-        if let Some(reason) = &seats.failed {
-            out.failed.push((cid.clone(), format!("分账号补建:{reason}")));
+        // D-41(需求§4.2)+M4:席位按**订阅**补建(同一客户多份订阅各管各的席位包)。
+        // ⛔ 只在「额度发生变化」时才补(主账号晚于订阅开通、上一轮补建失败的订阅,都靠这里
+        // 在后续轮次收敛),且**只补不删**(缩减侧只记说明)。失败⛔ 影响额度结论。
+        for r in sub_rows.iter().filter(|r| r.customer_id == *cid) {
+            let t = r.quota_slots.trim().parse::<i64>().unwrap_or(0);
+            let seats = super::sub_provision::align_seats_of(state, &r.subscription_id, t).await;
+            if let Some(reason) = &seats.failed {
+                out.failed.push((
+                    cid.clone(),
+                    format!("订阅 {} 分账号补建:{reason}", r.subscription_id),
+                ));
+            }
         }
         if before == target {
             continue;
@@ -1609,7 +1572,7 @@ pub(crate) fn insert_stmt(v: &NewValues) -> DmlStatement {
         "plan_name",
         "plan_kind",
         "plan_owner_customer_id",
-        "use_category",
+        "plan_family",
         "sub_mode",
         "line_exits",
         "line_exit_key",
@@ -1633,8 +1596,8 @@ pub(crate) fn insert_stmt(v: &NewValues) -> DmlStatement {
             v.plan_owner_customer_id.clone().map(Value::String).unwrap_or(Value::Null),
             "text",
         ),
-        ph(&mut p, Value::String(v.use_category.clone()), "text"),
-        ph(&mut p, Value::String(v.sub_mode.clone()), "text"),
+        ph(&mut p, Value::String(v.plan_family.clone()), "text"),
+        ph(&mut p, v.sub_mode.clone().map(Value::String).unwrap_or(Value::Null), "text"),
         ph(&mut p, v.line_exits.clone(), "text::jsonb"),
         ph(&mut p, Value::String(v.line_exit_key.clone()), "text"),
         ph(&mut p, Value::String(v.term.clone()), "text"),
@@ -1705,8 +1668,9 @@ pub(crate) struct NewValues {
     pub(crate) plan_name: String,
     pub(crate) plan_kind: String,
     pub(crate) plan_owner_customer_id: Option<String>,
-    pub(crate) use_category: String,
-    pub(crate) sub_mode: String,
+    pub(crate) plan_family: String,
+    /// 历史列:三分类收敛后新行恒 `None`(I6 停用,不再派生订阅方式)。
+    pub(crate) sub_mode: Option<String>,
     pub(crate) line_exits: Value,
     pub(crate) line_exit_key: String,
     pub(crate) term: String,
@@ -1904,7 +1868,7 @@ pub async fn create(
         None => None,
     };
     if let Some(i) = item {
-        if let Some(ip) = opt_trim(i.plan_id.as_ref()).or_else(|| opt_trim(i.derived_plan_id.as_ref())) {
+        if let Some(ip) = opt_trim(i.plan_id.as_ref()) {
             if ip != pid {
                 return json_err(BosError::klt(
                     KltCode::M228,
@@ -1952,7 +1916,7 @@ pub async fn create(
         Ok(v) => v,
         Err(e) => return json_err(e),
     };
-    let category = match category_of(body.use_category.as_ref(), &plan) {
+    let family = match family_of(body.plan_family.as_ref(), &plan) {
         Ok(v) => v,
         Err(e) => return json_err(e),
     };
@@ -1963,40 +1927,19 @@ pub async fn create(
         Ok(v) => v,
         Err(e) => return json_err(e),
     };
-    // 档位份数(2026-11-17):缺省 1;只有可叠加档(用途分类=叠加增值)允许 > 1,
-    // 其余档(仅可升降配/单独约定)份数恒 1 —— 一份条目一份订阅,数量不是条目数。
-    let sub_mode = sub_mode_of(category);
+    // 份数(D-8 `ck_sub_qty`):`link` 恒 1(一条链路=一份),`addon` 1~9999。
     let quantity = match body.quantity {
         None => 1,
-        Some(q) if q >= 1 => q,
-        Some(q) => {
-            return json_err(BosError::bad_params(format!(
-                "quantity 必须是正整数(11103),收到 {q}"
-            )))
-        }
+        Some(q) => q,
     };
-    if quantity > 1 && sub_mode != SubMode::Stackable {
+    if !family.quantity_ok(quantity) {
         return json_err(BosError::bad_params(format!(
-            "档位 {} 的订阅方式为「{}」,份数必须为 1(收到 {quantity}):只有可叠加档(叠加增值)可按份叠加",
+            "档位 {} 的交付形态为「{}」,份数必须是{}(收到 {quantity})",
             plan.plan_id,
-            sub_mode.as_str()
+            family.as_str(),
+            if family == PlanFamily::Link { " 1" } else { " 1~9999" }
         )));
     }
-    // ⑤ I6 ⇒ KLT-M224(带那份订阅的定位)
-    let actives = match i6_rows(&state, &cid, None).await {
-        Ok(v) => v,
-        Err(e) => return json_err(e),
-    };
-    if let Err(e) = check_i6_subscription(
-        &cid,
-        category,
-        &exits.line_exit_key,
-        &period.start,
-        &period.end,
-        &i6_borrow(&actives),
-    ) {
-        return json_err(e);
-    }
     let id = match new_subscription_id(&state).await {
         Ok(v) => v,
         Err(e) => return json_err(e),
@@ -2009,8 +1952,8 @@ pub async fn create(
         plan_name: plan.plan_name.clone(),
         plan_kind: plan.plan_kind.clone(),
         plan_owner_customer_id: opt_trim(plan.customer_id.as_ref()).map(str::to_string),
-        use_category: category.as_str().to_string(),
-        sub_mode: sub_mode.as_str().to_string(),
+        plan_family: family.as_str().to_string(),
+        sub_mode: None,
         line_exits: Value::Array(exits.line_exits.iter().cloned().map(Value::String).collect()),
         line_exit_key: exits.line_exit_key.clone(),
         term: period.term.clone(),
@@ -2028,7 +1971,10 @@ pub async fn create(
         replaces_subscription_id: None,
     };
     // 额度对齐目标=在册在用行 + 本行
-    let mut for_quota = actives.clone();
+    let mut for_quota = match subs_of_customer(&state, &cid).await {
+        Ok(v) => v,
+        Err(e) => return json_err(e),
+    };
     for_quota.push(SubRowPlaceholder::for_new(&id, &nv));
     let target = match quota_target(&state, &cid, &for_quota).await {
         Ok(v) => v,
@@ -2107,7 +2053,7 @@ pub async fn create(
     // D-41(需求§4.2/客户册§5.2):订阅保存=额度变更落点,分账号由系统按套餐额度**自动补建**
     //   (⛔ 手工新增)。与交付工单同一形态:订阅主档先提交,补建在其后同步执行,失败⛔ 回滚
     //   已提交的订阅,只把原因如实写回 `notes`+审计 `detail_json.sub_accounts`(⛔ 静默)。
-    let seats = super::sub_provision::align_sub_accounts(&state, &cid, target).await;
+    let seats = super::sub_provision::align_seats_of(&state, &id, nv.quota_slots).await;
     notes.push(seats.note());
     // 后置审计 `subscription.create`(08 册 §8.1 CU-17/§8.3):此前该动作在 `bos_audit_log` 里
     //   0 行=D-25。`before_json` 新增时为空;额度前后、两个金额与折算来源、order_no 冻结事实照记。
@@ -2116,7 +2062,7 @@ pub async fn create(
         "layout": "multi",
         "plan_id": nv.plan_id,
         "plan_name_snapshot": nv.plan_name,
-        "use_category": nv.use_category,
+        "plan_family": nv.plan_family,
         "sub_mode": nv.sub_mode,
         "line_exits": nv.line_exits,
         "line_exit_key": nv.line_exit_key,
@@ -2170,7 +2116,7 @@ pub async fn create(
                 "annual_price_cents": period.annual,
                 "monthly_settle_cents": period.monthly,
                 "line_exit_key": exits.line_exit_key,
-                "sub_mode": sub_mode_of(category).as_str(),
+                "plan_family": family.as_str(),
             },
         }),
     )
@@ -2331,7 +2277,7 @@ pub async fn change(
     let item = match opt_trim(body.contract_item_id.as_ref()) {
         Some(iid) => match items.iter().find(|i| i.item_id == iid) {
             Some(i) => {
-                let bound = opt_trim(i.plan_id.as_ref()).or_else(|| opt_trim(i.derived_plan_id.as_ref()));
+                let bound = opt_trim(i.plan_id.as_ref());
                 if let Some(ip) = bound {
                     if ip != pid {
                         return json_err(BosError::klt(
@@ -2349,26 +2295,10 @@ pub async fn change(
                 ))
             }
         },
-        None => items.iter().find(|i| {
-            opt_trim(i.plan_id.as_ref()) == Some(pid.as_str())
-                || opt_trim(i.derived_plan_id.as_ref()) == Some(pid.as_str())
-        }),
-    };
-    // 升降配下派生档必须已有用途分类(载荷⛔ 带 use_category)。
-    let category = match opt_trim(plan.use_category.as_ref()) {
-        Some(v) => match UseCategory::parse(v) {
-            Ok(c) => c,
-            Err(e) => return json_err(e),
-        },
-        None => {
-            return json_err(BosError::klt(
-                KltCode::M228,
-                format!(
-                    "档位不可选:派生自定义档 {pid} 未预置用途分类,而升降配不录入 use_category(请先在第 1 步把分类带入档位)"
-                ),
-            ))
-        }
+        None => items.iter().find(|i| opt_trim(i.plan_id.as_ref()) == Some(pid.as_str())),
     };
+    // 交付形态只读档位(载荷⛔ 带 plan_family)。
+    let family = plan.family();
     if let Err(e) = check_i13_trial_months(body.trial_months, body.discount_monthly_cents) {
         return json_err(e);
     }
@@ -2406,9 +2336,6 @@ pub async fn change(
         Err(e) => return json_err(e),
     };
     let planned_once = std::slice::from_ref(&planned);
-    if let Err(e) = super::succession::check_i6_final(&cid, &existing, planned_once, &[]) {
-        return json_err(e);
-    }
     let nv = planned.new.clone();
     let period = planned.period.clone();
     let prev_end = planned.prev_end.clone();
@@ -2425,9 +2352,16 @@ pub async fn change(
         Err(e) => return json_err(e),
     };
     let mut stmts: Vec<DmlStatement> = super::succession::change_dml(&planned);
-    if before != target {
+    let has_quota = before != target;
+    if has_quota {
         stmts.push(quota_stmt(&cid, target));
     }
+    // M4:席位先改挂到新订阅(0 行=原订阅本就没有席位,属正常)——放在断言语句之后,
+    // ⛔ 计入 `assert_batch` 的期望行数。
+    stmts.push(super::succession::seat_migration_stmt(
+        &planned.orig.subscription_id,
+        &planned.new.subscription_id,
+    ));
     let results = match state.db.dml_batch(&stmts).await {
         Ok(r) => r,
         Err(e) => return json_err(e),
@@ -2436,7 +2370,7 @@ pub async fn change(
         .iter()
         .map(|s| (*s, 1))
         .collect();
-    if stmts.len() > 3 {
+    if has_quota {
         want.push(("客户额度对齐", 1));
     }
     if let Err(e) = assert_batch(&results, &want) {
@@ -2506,7 +2440,7 @@ pub async fn change(
     notes.push(delivery.note.clone());
     // D-41(需求§4.2):升降配=额度变更落点。升配侧按新额度补建席位;降配侧**只补不删**,
     //   超出的席位⛔ 删号(随到期停机转停用),差异如实写回 `notes`+审计 `detail_json.sub_accounts`。
-    let seats = super::sub_provision::align_sub_accounts(&state, &cid, target).await;
+    let seats = super::sub_provision::align_seats_of(&state, &id, nv.quota_slots).await;
     notes.push(seats.note());
     // 后置审计 `subscription.replace`(08 册 §8.1 CU-17/§8.3=`pair` 版式:原订阅 `end_date`
     //   与 `status` 记原值→新值,另记原/新合同编号)。此前升降配全程 0 行审计。
@@ -2555,7 +2489,7 @@ pub async fn change(
                 "annual_price_cents": period.annual,
                 "monthly_settle_cents": period.monthly,
                 "line_exit_key": exits.line_exit_key,
-                "sub_mode": sub_mode_of(category).as_str(),
+                "plan_family": family.as_str(),
                 "contract_id": contract_id,
                 "contract_item_id": nv.contract_item_id,
             },
@@ -2579,8 +2513,8 @@ impl SubRowPlaceholder {
             plan_kind: Some(v.plan_kind.clone()),
             plan_owner_customer_id: v.plan_owner_customer_id.clone(),
             status: v.status.clone(),
-            use_category: Some(v.use_category.clone()),
-            sub_mode: Some(v.sub_mode.clone()),
+            plan_family: Some(v.plan_family.clone()),
+            sub_mode: v.sub_mode.clone(),
             line_exits: None,
             line_exit_key: Some(v.line_exit_key.clone()),
             start_date: Some(v.start_date.clone()),
@@ -2928,7 +2862,7 @@ pub async fn delete(
     ];
     // D-41(需求§4.2):删除订阅=额度缩减侧 ⇒ 分账号**只补不删**,超出的席位一行不删(随到期
     //   停机转停用),只把「为什么不删」如实写回 `notes`+审计 `detail_json.sub_accounts`。
-    let seats = super::sub_provision::align_sub_accounts(&state, &r.customer_id, target).await;
+    let seats = super::sub_provision::align_seats_of(&state, &r.subscription_id, 0).await;
     notes.push(seats.note());
     // 后置审计 `subscription.delete`(08 册 §8.1 CU-19/§8.3):真删 ⇒ `before_json` 记完整关键字段
     //   快照、`after_json` 为空;额度前后/释放值、账单口径未接线声明、打点不回滚声明照记。
@@ -3378,7 +3312,7 @@ pub async fn get(
         },
         "amount": money_json(&r),
         "exits": {
-            "use_category": r.use_category,
+            "plan_family": r.plan_family,
             "sub_mode": r.sub_mode,
             "line_exits": exits_json(r.line_exits.as_ref()),
             "line_exit_key": r.line_exit_key,
@@ -3655,7 +3589,7 @@ mod tests {
 
     #[test]
     fn 新建载荷的只读派生列逐列点名拒收() {
-        let m = map(r#"{"annual_price_cents":1,"line_exits":["美国"],"sub_mode":"upgrade","end_date":"2027-01-01","order_no":"X","actual_opened_at":"2026-01-01","monthly_settle_cents":2,"term":"monthly"}"#);
+        let m = map(r#"{"annual_price_cents":1,"line_exits":["美国"],"sub_mode":"upgrade","end_date":"2027-01-01","order_no":"X","actual_opened_at":"2026-01-01","monthly_settle_cents":2,"term":"monthly","item_family":"addon"}"#);
         let e = reject_read_only(&m, &CREATE_READ_ONLY).unwrap_err();
         let s = format!("{e}");
         for k in [
@@ -3666,6 +3600,8 @@ mod tests {
             "sub_mode",
             "order_no",
             "actual_opened_at",
+            // D-15:条目形态随条目带入,订阅载荷⛔ 再收
+            "item_family",
         ] {
             assert!(s.contains(k), "未点名 {k}:{s}");
         }
@@ -3702,8 +3638,8 @@ mod tests {
             plan_kind: Some("fixed".to_string()),
             plan_owner_customer_id: None,
             status: status.to_string(),
-            use_category: Some("office".to_string()),
-            sub_mode: Some("upgrade".to_string()),
+            plan_family: Some("link".to_string()),
+            sub_mode: None,
             line_exits: None,
             line_exit_key: Some("中国香港".to_string()),
             start_date: start.map(str::to_string),
@@ -3793,7 +3729,6 @@ mod tests {
             !src.contains(concat!(".me", "ssage()")),
             "BosError 不提供该访问器"
         );
-        assert!(src.contains("check_i6_subscription"), "I6 判据必须走不变量库");
         assert!(src.contains("check_subscription_deletable"), "删除阻塞必须走不变量库(M227/M230 同源)");
     }
 }

+ 107 - 176
src/modules/account/src/handlers/succession.rs

@@ -3,16 +3,18 @@
 //! ## 为什么单独成层
 //!
 //! 升降配从「先建合同、再到订阅台账手动承接」改成「合同新建页逐条判定并同事务写入」后,
-//! 同一个客户在一次合同提交里可能出现**多条**替换。I6(同客户×同分类×同出口至多一份)
-//! 与额度(按在用行集求和)都必须按「全部截原+全部新建」之后的**最终行集**判一次;
-//! 逐条各判一次会互相漏判(A 顶掉 B 的原行、B 又顶掉 A 的原行,两条分别看都「合规」)。
+//! 同一个客户在一次合同提交里可能出现**多条**替换。额度(按在用行集求和)必须按
+//! 「全部截原+全部新建」之后的**最终行集**算一次;逐条各算一次会漏掉互相顶替的部分
+//! (A 顶掉 B 的原行、B 又顶掉 A 的原行)。
+//!
+//! I6(同客户 × 同形态 × 同出口至多一份)已于 2026-11-19 停用(D-15)——三分类收敛后
+//! `sub_mode` 不再派生,判据失去输入;码位 `M224` 保留不复用。
 //!
 //! ## 本层对外
 //!
 //! * [`derive_period_of`]:`term` → 起止+年费/月结算的唯一折算点(⛔ 手工填价)。
-//! * [`plan_change`]:状态、已替换次数、档位可取性、分类、出口、期间、I6 预演、新行构造。
+//! * [`plan_change`]:状态、已替换次数、档位可取性、形态、出口、期间、新行构造。
 //! * [`change_dml`]:截原 UPDATE + 新订阅 INSERT + `first_referred_at` 打点,**顺序固定**。
-//! * [`check_i6_final`]:最终行集复检 I6(一次性剔除全部原订阅,再逐条加入新订阅)。
 //! * [`quota_target_final`]:最终行集算一次额度目标。
 //! * [`replacement_candidates`]:`POST /subscription/replacement_candidates@v1`,候选过滤与
 //!   保存期校验**同源**([`candidate_filter`]),避免前端自造判据。
@@ -25,9 +27,9 @@ use bos_api::extract::{json_err, json_ok, DataBody, RequireAuth};
 use bos_api::AppState;
 use bos_core::{BosError, KltCode, RoleCode};
 use bos_invariant::{
-    check_i13_trial_months, check_i6_subscription, check_plan_available, monthly_settle_of,
-    normalize_line_exits, sub_mode_of, subscription_status_of, NormalizedExits, PlanRef,
-    UseCategory, MAX_AMOUNT_CENTS,
+    check_i13_trial_months, check_plan_available, monthly_settle_of,
+    normalize_line_exits, subscription_status_of, NormalizedExits, PlanFamily, PlanRef,
+    MAX_AMOUNT_CENTS,
 };
 use bos_platform::clients::uds::{de, DmlStatement};
 use chrono::NaiveDate;
@@ -38,7 +40,7 @@ use super::listq::{push_in, Params};
 use super::subscription::{
     add_months_clamped, annual_by_term, contract_row, contracts_of_customer, date_text,
     derive_exits, exits_of,
-    i6_borrow, insert_stmt, opt_trim, parse_date, plan_row, plan_selectability, quota_target,
+    insert_stmt, opt_trim, parse_date, plan_row, plan_selectability, quota_target,
     replacement_count, req_field, require_customer, status_display, subs_of_customer,
     term_months, ContractRow, ItemRow, NewValues, Period, PlanRow, SubRow, SubRowPlaceholder,
     IN_USE_STATUS,
@@ -194,8 +196,8 @@ mod tests {
             plan_name: "标准档".to_string(),
             plan_kind: "fixed".to_string(),
             plan_owner_customer_id: None,
-            use_category: "office".to_string(),
-            sub_mode: "upgrade".to_string(),
+            plan_family: "link".to_string(),
+            sub_mode: None,
             line_exits: json!(["中国香港"]),
             line_exit_key: "中国香港".to_string(),
             term: "yearly".to_string(),
@@ -265,7 +267,7 @@ mod tests {
         // 新合同 2027 年起 ⇒ 只有 2027 那份相交;2026 那份是「到期续签」
         let picked = candidate_filter(
             "C1",
-            UseCategory::Office,
+            PlanFamily::Link,
             "中国香港",
             "2027-01-01",
             Some("2027-12-31"),
@@ -276,7 +278,7 @@ mod tests {
         assert_eq!(picked[0].subscription_id, "SUB-NEW");
         let skipped = candidate_skipped(
             "C1",
-            UseCategory::Office,
+            PlanFamily::Link,
             "中国香港",
             "2027-01-01",
             Some("2027-12-31"),
@@ -290,7 +292,7 @@ mod tests {
         // 新合同 2026 年内 ⇒ 2026 那份相交,2027 那份「本合同结束后才生效」
         let skipped = candidate_skipped(
             "C1",
-            UseCategory::Office,
+            PlanFamily::Link,
             "中国香港",
             "2026-06-01",
             Some("2026-12-31"),
@@ -302,66 +304,58 @@ mod tests {
         assert_eq!(skipped[0].1, "starts_after_contract_end");
     }
 
-    fn shape(kind: &str, plan: Option<&str>, exits: &str) -> ServiceShape {
+    fn shape(plan: Option<&str>, family: &str, exits: &str) -> ServiceShape {
         ServiceShape {
-            kind: kind.to_string(),
             plan_id: plan.map(str::to_string),
-            use_category: Some("office".to_string()),
+            item_family: Some(family.to_string()),
             quantity: 1,
-            account_count: 5,
-            bw_up: Some(50),
-            bw_down: Some(100),
             line_exit_key: Some(exits.to_string()),
         }
     }
 
     #[test]
     fn 续签服务内容未变_逐条同一口径() {
-        // 同档同份同席位同带宽同出口 ⇒ 未变(价格不在比对列里 ⇒ 改价也算未变)
-        let old = vec![shape("plan_based", Some("P1"), "hk")];
-        let new = vec![shape("plan_based", Some("P1"), "hk")];
+        // 同档同形态同份数同出口 ⇒ 未变(价格不在比对列里 ⇒ 改价也算未变)
+        let old = vec![shape(Some("P1"), "link", "hk")];
+        let new = vec![shape(Some("P1"), "link", "hk")];
         assert!(service_unchanged(&old, &new));
         // 档位变了 ⇒ 变了
-        assert!(!service_unchanged(&old, &[shape("plan_based", Some("P2"), "hk")]));
+        assert!(!service_unchanged(&old, &[shape(Some("P2"), "link", "hk")]));
+        // 交付形态变了 ⇒ 变了
+        assert!(!service_unchanged(&old, &[shape(Some("P1"), "addon", "hk")]));
         // 出口变了 ⇒ 变了
-        assert!(!service_unchanged(&old, &[shape("plan_based", Some("P1"), "jp")]));
+        assert!(!service_unchanged(&old, &[shape(Some("P1"), "link", "jp")]));
         // 份数变了 ⇒ 变了
-        let mut more = shape("plan_based", Some("P1"), "hk");
+        let mut more = shape(Some("P1"), "link", "hk");
         more.quantity = 2;
         assert!(!service_unchanged(&old, &[more]));
         // 增删条目 ⇒ 条数不同 ⇒ 变了
         assert!(!service_unchanged(&old, &[]));
         assert!(!service_unchanged(
             &old,
-            &[shape("plan_based", Some("P1"), "hk"), shape("plan_based", Some("P1"), "hk")]
+            &[shape(Some("P1"), "link", "hk"), shape(Some("P1"), "link", "hk")]
         ));
     }
 
     #[test]
-    fn 续签服务内容未变_自定义式看席位与带宽() {
-        let old = vec![shape("custom_spec", None, "hk")];
-        let mut same = shape("custom_spec", None, "hk");
-        assert!(service_unchanged(&old, &[same.clone()]));
-        // 带宽变了 ⇒ 变了(自定义式没有档位主键可依赖)
-        same.bw_down = Some(200);
-        assert!(!service_unchanged(&old, &[same.clone()]));
-        same.bw_down = Some(100);
-        same.account_count = 6;
-        assert!(!service_unchanged(&old, &[same.clone()]));
-        same.account_count = 5;
-        same.use_category = Some("game".to_string());
-        assert!(!service_unchanged(&old, &[same]));
+    fn 续签服务内容未变_附加项也按档位比对() {
+        // 附加项(单独境外 IP 这类):档位/份数/出口照比,额度与带宽不再逐条比(随档位)
+        let old = vec![shape(Some("P5"), "addon", "hk")];
+        assert!(service_unchanged(&old, &[shape(Some("P5"), "addon", "hk")]));
+        let mut more = shape(Some("P5"), "addon", "hk");
+        more.quantity = 6;
+        assert!(!service_unchanged(&old, &[more]));
     }
 }
 
 // ═══════════════════════════ 替换计划 ═══════════════════════════
 
-/// 替换匹配口径:候选/保存是否要求「原订阅与条目同分类同出口」。
+/// 替换匹配口径:候选/保存是否要求「原订阅与条目同出口且双方均 `link`」。
 #[derive(Clone, Copy, PartialEq, Eq)]
 pub(crate) enum MatchMode {
-    /// 合同新建页的逐条替换:原订阅必须与条目**同分类、同出口、非增值**(§5.3 新口径)。
+    /// 合同新建页的逐条替换:原订阅必须与条目**同出口且双方均 `link`**(§5.3 新口径)。
     SameCategoryAndExit,
-    /// 订阅台账的单订阅快捷入口:沿用旧行为(分类与出口均随档位变,⛔ 一致性校验)。
+    /// 订阅台账的单订阅快捷入口:沿用旧行为(形态与出口均随档位变,⛔ 一致性校验)。
     FollowPlan,
 }
 
@@ -397,7 +391,8 @@ fn item_quantity(item: Option<&ItemRow>) -> i64 {
 pub(crate) struct PlannedChange {
     pub(crate) orig: SubRow,
     pub(crate) new: NewValues,
-    pub(crate) use_category: UseCategory,
+    #[allow(dead_code)] // 形态已由「双方均 link」候选判据兜住;保留供回执/审计取用
+    pub(crate) plan_family: PlanFamily,
     pub(crate) exits: NormalizedExits,
     pub(crate) period: Period,
     /// 原订阅截原结束日(新生效日前一天,且不早于原生效日)。
@@ -453,29 +448,23 @@ pub(crate) async fn plan_change(
         ));
     }
     check_plan_available(Some(&pr), customer_id)?;
-    // 分类:派生自定义档必须已预置用途分类(⛔ 升降配录入 use_category)。
-    let category = match opt_trim(p.plan.use_category.as_ref()) {
-        Some(v) => UseCategory::parse(v)?,
-        None => {
-            return Err(point(format!(
-                "档位 {} 未预置用途分类,无法判定替换归属(自定义档请先把分类带入档位)",
-                p.plan.plan_id
-            )))
-        }
-    };
+    // 交付形态**只读档位**(条目/订阅都不是第二来源;库上 `ck_plan_family` 兜底两值)。
+    let family = p.plan.family();
     check_i13_trial_months(p.trial_months, p.discount_monthly_cents)?;
     let exits = derive_exits(p.item, p.plan)?;
     if p.mode == MatchMode::SameCategoryAndExit {
-        let orig_cat = opt_trim(orig.use_category.as_ref()).unwrap_or_default();
-        if orig_cat == UseCategory::ValueAdd.as_str() {
+        // 替换判据(D-15 收敛):同客户 × 同出口 × **双方均 `link`**。
+        // `addon`(附加项)不参与替换——它是叠加在链路上的附加能力,没有「被顶掉」的语义。
+        if family != PlanFamily::Link {
             return Err(point(format!(
-                "原订阅 {rid} 属增值服务(value_add),不参与升降配替换"
+                "条目所引档位 {} 的交付形态为 addon(附加项):附加项不参与升降配替换",
+                p.plan.plan_id
             )));
         }
-        if orig_cat != category.as_str() {
+        let orig_family = opt_trim(orig.plan_family.as_ref()).unwrap_or_default();
+        if orig_family != PlanFamily::Link.as_str() {
             return Err(point(format!(
-                "原订阅 {rid} 用途分类={orig_cat},与条目分类 {} 不同:替换须同分类(§5.3)",
-                category.as_str()
+                "原订阅 {rid} 交付形态={orig_family},非跨境链路(link):替换只承接 link 订阅(§5.3)"
             )));
         }
         let orig_key = opt_trim(orig.line_exit_key.as_ref()).unwrap_or_default();
@@ -532,8 +521,8 @@ pub(crate) async fn plan_change(
         plan_name: p.plan.plan_name.clone(),
         plan_kind: p.plan.plan_kind.clone(),
         plan_owner_customer_id: opt_trim(p.plan.customer_id.as_ref()).map(str::to_string),
-        use_category: category.as_str().to_string(),
-        sub_mode: sub_mode_of(category).as_str().to_string(),
+        plan_family: family.as_str().to_string(),
+        sub_mode: None,
         line_exits: Value::Array(exits.line_exits.iter().cloned().map(Value::String).collect()),
         line_exit_key: exits.line_exit_key.clone(),
         term: period.term.clone(),
@@ -581,7 +570,7 @@ pub(crate) async fn plan_change(
     Ok(PlannedChange {
         orig: orig.clone(),
         new,
-        use_category: category,
+        plan_family: family,
         exits,
         period,
         prev_end,
@@ -650,6 +639,22 @@ pub(crate) fn change_dml(plan: &PlannedChange) -> Vec<DmlStatement> {
     ]
 }
 
+/// 替换落库时把席位从原订阅改挂到新订阅(M4:席位归属按订阅,⛔ 按客户汇总)。
+///
+/// ⚠️ 允许 0 行(原订阅一个席位都没有)⇒ 调用方**不计入** `assert_batch` 的期望行数。
+pub(crate) fn seat_migration_stmt(old_id: &str, new_id: &str) -> DmlStatement {
+    let mut p = Params::default();
+    let n = p.push(Value::String(new_id.to_string()));
+    let o = p.push(Value::String(old_id.to_string()));
+    DmlStatement::new(
+        format!(
+            "UPDATE sub_account SET subscription_id = {n}::text, updated_at = NOW() \
+             WHERE subscription_id = {o}::text"
+        ),
+        p.values().to_vec(),
+    )
+}
+
 /// [`change_dml`] 三条语句的断言标签(顺序一一对应)。
 pub(crate) const CHANGE_DML_LABELS: [&str; 3] = [
     "原订阅截原",
@@ -666,7 +671,8 @@ pub(crate) const CHANGE_DML_LABELS: [&str; 3] = [
 #[derive(Clone)]
 pub(crate) struct PlannedFresh {
     pub(crate) new: NewValues,
-    pub(crate) use_category: UseCategory,
+    #[allow(dead_code)] // 与 `PlannedChange` 同形,回执/审计按需取用
+    pub(crate) plan_family: PlanFamily,
     #[allow(dead_code)] // 与 `PlannedChange` 同形,回执/审计按需取用
     pub(crate) exits: NormalizedExits,
 }
@@ -679,7 +685,6 @@ pub(crate) fn plan_fresh(
     today: &str,
     err_prefix: &str,
 ) -> Result<PlannedFresh, BosError> {
-    let point = |msg: String| BosError::klt(KltCode::L222, format!("{err_prefix}{msg}"));
     let pr: PlanRef = p.plan.to_ref();
     if let (_, Some(reason)) = plan_selectability(&pr, customer_id) {
         return Err(BosError::klt(
@@ -688,17 +693,7 @@ pub(crate) fn plan_fresh(
         ));
     }
     check_plan_available(Some(&pr), customer_id)?;
-    let category = match opt_trim(p.plan.use_category.as_ref())
-        .or_else(|| p.item.and_then(|i| opt_trim(i.use_category.as_ref())))
-    {
-        Some(v) => UseCategory::parse(v)?,
-        None => {
-            return Err(point(format!(
-                "档位 {} 未预置用途分类,无法判定订阅归属(自定义档请先把分类带入档位)",
-                p.plan.plan_id
-            )))
-        }
-    };
+    let family = p.plan.family();
     let exits = derive_exits(p.item, p.plan)?;
     let ce = p.contract_end.ok_or_else(|| {
         BosError::klt(
@@ -725,8 +720,8 @@ pub(crate) fn plan_fresh(
         plan_name: p.plan.plan_name.clone(),
         plan_kind: p.plan.plan_kind.clone(),
         plan_owner_customer_id: opt_trim(p.plan.customer_id.as_ref()).map(str::to_string),
-        use_category: category.as_str().to_string(),
-        sub_mode: sub_mode_of(category).as_str().to_string(),
+        plan_family: family.as_str().to_string(),
+        sub_mode: None,
         line_exits: Value::Array(exits.line_exits.iter().cloned().map(Value::String).collect()),
         line_exit_key: exits.line_exit_key.clone(),
         term: period.term.clone(),
@@ -737,14 +732,14 @@ pub(crate) fn plan_fresh(
         quota_slots: pr.sub_account_quota,
         // 份数随条目带入(2026-11-17):一份条目只生一份订阅,但这条订阅可带「几份」。
         // 非套餐式条目没有份数概念 ⇒ 恒 1;可叠加档(叠加增值)才允许 > 1。
-        quantity: item_quantity(p.item),
+        quantity: if family == PlanFamily::Link { 1 } else { item_quantity(p.item) },
         contract_id: Some(p.contract_id.to_string()),
         contract_item_id: p.item.map(|i| i.item_id.clone()),
         trial_months: p.trial_months,
         discount_monthly_cents: p.discount_monthly_cents,
         replaces_subscription_id: None,
     };
-    Ok(PlannedFresh { new, use_category: category, exits })
+    Ok(PlannedFresh { new, plan_family: family, exits })
 }
 
 /// 续签新开的落库语句:新订阅 INSERT + `first_referred_at` 打点(⛔ 无截原)。
@@ -760,45 +755,30 @@ pub(crate) const FRESH_DML_LABELS: [&str; 2] = ["新订阅 INSERT(续签)",
 
 // ═══════════════ 续签「服务内容未变 ⇒ 不派工」判据(2026-11-17 定案) ═══════════════
 
-/// 条目「服务内容」口径:**只收会派工的列**(形式、档位、份数、席位、带宽、线路出口)。
+/// 条目「服务内容」口径:**只收会派工的列**(档位、交付形态、份数、线路出口)。
 ///
 /// ⛔ 价格/账期/合同金额:续签改价是商务变更,没有施工动作;
-/// ⛔ `item_id`/`derived_plan_id`:本合同的发号结果,续签必然不同(`custom_spec` 每次新建
-/// 都会派生一份新档)⇒ 用它们比对会让「未变」永远不成立。
+/// ⛔ `item_id`:本合同的发号结果,续签必然不同 ⇒ 用它比对会让「未变」永远不成立。
+/// 2026-11-19(D-15):条目只剩「档位 × 份数」,席位与带宽随档位 ⇒ 不再逐条比它们。
 #[derive(Debug, Clone, PartialEq, Eq)]
 pub(crate) struct ServiceShape {
-    /// `plan_based`/`custom_spec`
-    pub(crate) kind: String,
-    /// 套餐式条目的目录档位(自定义式=`None`:其「档位」由分类/席位/带宽/出口表达)
+    /// 所引档位(`plan_id NOT NULL` 后恒有值:一条目必有档位)
     pub(crate) plan_id: Option<String>,
-    pub(crate) use_category: Option<String>,
+    /// 交付形态(落库列 `item_family`,应用层已校验=档位的 `plan_family`)
+    pub(crate) item_family: Option<String>,
     pub(crate) quantity: i64,
-    pub(crate) account_count: i64,
-    pub(crate) bw_up: Option<i64>,
-    pub(crate) bw_down: Option<i64>,
     /// 归一化出口集合的摘要键(复用 `normalize_line_exits` 唯一算式,⛔ 第二套归一化);
     /// `None`=该条目的出口取不到(空集/非法值)——按「无可比出口」参与比对,⛔ 报错。
     pub(crate) line_exit_key: Option<String>,
 }
 
 impl ServiceShape {
-    /// 逐条比对:套餐式看档位,自定义式看分类/席位/带宽;份数与出口两者都看。
+    /// 逐条比对:档位、形态、份数、出口四项全等才算「服务内容未变」。
     pub(crate) fn same_service(&self, other: &Self) -> bool {
-        if self.kind != other.kind
-            || self.quantity != other.quantity
-            || self.line_exit_key != other.line_exit_key
-        {
-            return false;
-        }
-        match self.kind.as_str() {
-            "plan_based" => self.plan_id == other.plan_id,
-            _ => {
-                self.use_category == other.use_category
-                    && self.account_count == other.account_count
-                    && self.bw_up == other.bw_up
-                    && self.bw_down == other.bw_down
-            }
-        }
+        self.plan_id == other.plan_id
+            && self.item_family == other.item_family
+            && self.quantity == other.quantity
+            && self.line_exit_key == other.line_exit_key
     }
 }
 
@@ -856,48 +836,6 @@ pub(crate) fn final_rows(
     rows
 }
 
-/// I6 按**最终行集**复检:一次性剔除全部原订阅,再逐条加入新订阅并复检。
-///
-/// 逐条各判一次会互相漏判(A 顶掉 B 的原行、B 又顶掉 A 的原行,分别看都「合规」)。
-pub(crate) fn check_i6_final(
-    customer_id: &str,
-    existing: &[SubRow],
-    planned: &[PlannedChange],
-    fresh: &[PlannedFresh],
-) -> Result<(), BosError> {
-    if planned.is_empty() && fresh.is_empty() {
-        return Ok(());
-    }
-    let rows = final_rows(existing, planned, fresh);
-    let check = |id: &str, category: UseCategory, key: &str, start: &str, end: &str| {
-        let others: Vec<SubRow> = rows
-            .iter()
-            .filter(|r| r.subscription_id != id)
-            .cloned()
-            .collect();
-        check_i6_subscription(customer_id, category, key, start, end, &i6_borrow(&others))
-    };
-    for p in planned {
-        check(
-            &p.new.subscription_id,
-            p.use_category,
-            &p.exits.line_exit_key,
-            &p.new.start_date,
-            &p.new.end_date,
-        )?;
-    }
-    for p in fresh {
-        check(
-            &p.new.subscription_id,
-            p.use_category,
-            &p.exits.line_exit_key,
-            &p.new.start_date,
-            &p.new.end_date,
-        )?;
-    }
-    Ok(())
-}
-
 /// 额度目标(最终行集算一次;⛔ 逐条各算一次)。
 pub(crate) async fn quota_target_final(
     state: &AppState,
@@ -912,29 +850,29 @@ pub(crate) async fn quota_target_final(
 
 // ═══════════════════════════ 候选探测 ═══════════════════════════
 
-/// 候选过滤(与保存期校验**同源**):同客户 × 同分类 × 同出口、在用、非增值、未被替换过,
-/// **且期间与新订阅相交**。
+/// 候选过滤(与保存期校验**同源**):同客户 × 同出口 × **双方均 `link`**、在用、未被替换过,
+/// **且期间与新订阅相交**。附加项(`addon`)不参与替换 ⇒ 直接空集。
 ///
 /// 期间判据是 2026-11-17 新增的一半:原订阅在新合同开始之前就到期 ⇒ 不存在替换关系,
 /// 前端⛔ 自动显示替换(否则一份 2027 年起的合同会把 2026-12 到期的旧订阅「替换」掉,
 /// 截原日还会落到旧行到期之后)。这类行由调用方以「已到期、按续签」单列回前端。
 pub(crate) fn candidate_filter<'a>(
     customer_id: &str,
-    category: UseCategory,
+    family: PlanFamily,
     line_exit_key: &str,
     new_start: &str,
     new_end: Option<&str>,
     rows: &'a [SubRow],
     replaced: &HashSet<String>,
 ) -> Vec<&'a SubRow> {
-    if category == UseCategory::ValueAdd {
+    if family != PlanFamily::Link {
         return Vec::new();
     }
     rows.iter()
         .filter(|r| {
             r.customer_id == customer_id
                 && matches!(r.status.as_str(), "active" | "pending")
-                && opt_trim(r.use_category.as_ref()) == Some(category.as_str())
+                && opt_trim(r.plan_family.as_ref()) == Some(PlanFamily::Link.as_str())
                 && opt_trim(r.line_exit_key.as_ref()) == Some(line_exit_key)
                 && !replaced.contains(&r.subscription_id)
                 && period_hits(
@@ -953,21 +891,21 @@ pub(crate) fn candidate_filter<'a>(
 /// `starts_after_contract_end`(原订阅要等本合同结束之后才生效)。两条都⛔ 参与替换。
 pub(crate) fn candidate_skipped<'a>(
     customer_id: &str,
-    category: UseCategory,
+    family: PlanFamily,
     line_exit_key: &str,
     new_start: &str,
     new_end: Option<&str>,
     rows: &'a [SubRow],
     replaced: &HashSet<String>,
 ) -> Vec<(&'a SubRow, &'static str)> {
-    if category == UseCategory::ValueAdd {
+    if family != PlanFamily::Link {
         return Vec::new();
     }
     rows.iter()
         .filter(|r| {
             r.customer_id == customer_id
                 && matches!(r.status.as_str(), "active" | "pending")
-                && opt_trim(r.use_category.as_ref()) == Some(category.as_str())
+                && opt_trim(r.plan_family.as_ref()) == Some(PlanFamily::Link.as_str())
                 && opt_trim(r.line_exit_key.as_ref()) == Some(line_exit_key)
                 && !replaced.contains(&r.subscription_id)
                 && !period_hits(
@@ -1031,9 +969,9 @@ pub struct ReplacementCandidatesReq {
 #[derive(Deserialize)]
 pub struct ReplacementProbeReq {
     pub index: Option<i64>,
-    pub item_kind: Option<String>,
     pub plan_id: Option<String>,
-    pub use_category: Option<String>,
+    /// 交付形态:给了就用(可选),否则取档位的 `plan_family`;`addon` 一律空候选。
+    pub plan_family: Option<String>,
     pub line_exits: Option<Value>,
 }
 
@@ -1062,7 +1000,7 @@ fn probe_exits(
 
 /// `POST /subscription/replacement_candidates@v1`(只读)。
 ///
-/// 后端统一解析分类(`use_category` 优先,否则取档位)并做候选过滤,前端⛔ 自造判据。
+/// 后端统一解析交付形态(`plan_family` 优先,否则取档位)并做候选过滤,前端⛔ 自造判据。
 pub async fn replacement_candidates(
     State(state): State<AppState>,
     RequireAuth(auth): RequireAuth,
@@ -1131,23 +1069,17 @@ pub async fn replacement_candidates(
             },
             None => None,
         };
-        let category = match opt_trim(probe.use_category.as_ref()) {
-            Some(v) => match UseCategory::parse(v) {
-                Ok(c) => c,
+        let family = match opt_trim(probe.plan_family.as_ref()) {
+            Some(v) => match PlanFamily::parse(v) {
+                Ok(f) => f,
                 Err(e) => return json_err(e),
             },
-            None => match plan
-                .as_ref()
-                .and_then(|p| opt_trim(p.use_category.as_ref()))
-            {
-                Some(v) => match UseCategory::parse(v) {
-                    Ok(c) => c,
-                    Err(e) => return json_err(e),
-                },
+            None => match plan.as_ref() {
+                Some(p) => p.family(),
                 None => {
                     return json_err(BosError::klt(
                         KltCode::L222,
-                        format!("{label} 无法判定用途分类(use_category 与档位均未给出)"),
+                        format!("{label} 无法判定交付形态(plan_family 与档位均未给出)"),
                     ))
                 }
             },
@@ -1162,7 +1094,7 @@ pub async fn replacement_candidates(
         };
         let picked = candidate_filter(
             &cid,
-            category,
+            family,
             &exits.line_exit_key,
             &new_start,
             new_end.as_deref(),
@@ -1173,7 +1105,7 @@ pub async fn replacement_candidates(
         // (否则前端只剩「0 候选」,运营看不懂为什么旧订阅不见了)。
         let skipped: Vec<Value> = candidate_skipped(
             &cid,
-            category,
+            family,
             &exits.line_exit_key,
             &new_start,
             new_end.as_deref(),
@@ -1224,9 +1156,8 @@ pub async fn replacement_candidates(
             .collect();
         out.push(json!({
             "index": idx,
-            "item_kind": probe.item_kind,
             "plan_id": probe.plan_id,
-            "use_category": category.as_str(),
+            "plan_family": family.as_str(),
             "line_exit_key": exits.line_exit_key,
             "line_exits": exits.line_exits,
             "start_date": new_start,
@@ -1298,7 +1229,7 @@ pub(crate) async fn original_sub(
         subscription_id: orig.subscription_id.clone(),
         plan_name: orig.plan_name.clone().unwrap_or_default(),
         plan_kind: orig.plan_kind.clone().unwrap_or_default(),
-        use_category: orig.use_category.clone().unwrap_or_default(),
+        plan_family: orig.plan_family.clone().unwrap_or_default(),
         line_exits: exits_of(orig.line_exits.as_ref(), "原订阅 line_exits").unwrap_or_default(),
         quota_slots: orig.quota_slots.trim().parse::<i64>().unwrap_or(0),
         start_date: orig.start_date.clone(),

+ 1 - 1
src/modules/account/src/job_center.rs

@@ -1366,7 +1366,7 @@ async fn run_sub_eff(state: &AppState, biz_date: NaiveDate) -> Result<RunReport,
                     "object_type": "subscription",
                     "object_id": id,
                     "customer_id": customer,
-                    "reason": "条件更新命中 0 行:并发下已被其他路径翻转,或撞 uq_i6_active,本行不翻转",
+                    "reason": "条件更新命中 0 行:并发下已被其他路径翻转,本行不翻转",
                 }));
             }
             Err(e) => {

+ 1 - 1
src/modules/ops/src/handlers/open_gen.rs

@@ -135,7 +135,7 @@ pub struct OriginalSub {
     pub subscription_id: String,
     pub plan_name: String,
     pub plan_kind: String,
-    pub use_category: String,
+    pub plan_family: String,
     pub line_exits: Vec<String>,
     pub quota_slots: i64,
     pub start_date: Option<String>,

+ 1 - 1
src/modules/ops/src/handlers/read.rs

@@ -1693,7 +1693,7 @@ async fn detail_inner(
             .db
             .query_one::<Value>(
                 "SELECT s.subscription_id::text AS subscription_id, s.customer_id, s.plan_name, \
-                 s.plan_kind, s.use_category, s.sub_mode, s.line_exits, s.order_no, s.term, \
+                 s.plan_kind, s.plan_family, s.sub_mode, s.line_exits, s.order_no, s.term, \
                  s.start_date::text AS start_date, s.status, \
                  s.actual_opened_at::text AS actual_opened_at \
                  FROM subscription s WHERE s.subscription_id = $1::text LIMIT 1",

+ 73 - 45
src/openapi.yaml

@@ -3347,7 +3347,7 @@ paths:
   /catalog/create@v1:
     post:
       summary: 新建套餐档位
-      description: 新建固定/自定义档位。拒收 monthly_settle_cents、sub_mode、first_referred_at。自定义档必填 customer_id。
+      description: 新建固定/自定义档位。拒收 sub_mode、first_referred_at。自定义档必填 customer_id。Ops 角色只能建自定义档(D-16);created_by=鉴权账号、created_team_id=建档团队快照(D-17)。
       operationId: catalog_create
       tags:
       - 套餐档位
@@ -3381,18 +3381,24 @@ paths:
                     plan_desc:
                       type: string
                       description: 套餐说明(报价单权益口径,可空;去首尾空白后 ≤512 字符,超长报 11103)。引用冻结后仍可改(与名称、随附成本项同档)
-                    use_category:
+                    plan_family:
                       type: string
-                      description: 用途分类:office/live/ai/value_add/customized
+                      description: 交付形态:link=跨境链路(份数恒 1);addon=附加项(份数≥1,不设带宽列)
+                      enum:
+                      - link
+                      - addon
                     annual_price_cents:
                       type: integer
                       description: 年价(分)
+                    monthly_settle_cents:
+                      type: integer
+                      description: 月结算标准(分,可选,1~上限);可录入(2026-11-19 起由只读列改为可写)
                     sub_account_quota:
                       type: integer
-                      description: 分账号配额
+                      description: 分账号额度(非负,上限 9999):link 档必须 > 0;addon 档必须为 0(D-15)
                     bandwidth_committed:
                       type: boolean
-                      description: 是否承诺带宽(界面「是否承诺带宽」开关):true=承诺(缺省,同列 DEFAULT TRUE);false=该档「不承诺带宽」,此时上行/下行两字段一律不传
+                      description: 是否承诺带宽:仅 link 档可传(缺省 true);addon 档一律不传(D-18)
                     bandwidth_up_mbps:
                       type: integer
                       description: 上行带宽(Mbps,整数 1~1000);bandwidth_committed=true 时必填。不再有单值 total_bandwidth_mbps(2026-11-05 D8 关闭=该列退役,「总带宽」只是显示列名)
@@ -3405,7 +3411,7 @@ paths:
                   required:
                   - plan_kind
                   - plan_name
-                  - use_category
+                  - plan_family
                   - annual_price_cents
               required:
               - data
@@ -3415,7 +3421,7 @@ paths:
   /catalog/update@v1:
     post:
       summary: 编辑套餐档位
-      description: 编辑档位;use_category 建后不可改;被订阅引用冻结后多数字段只读。
+      description: 编辑档位;plan_kind/plan_family 建后不可改(K204);被订阅引用冻结后多数字段只读。
       operationId: catalog_update
       tags:
       - 套餐档位
@@ -3449,9 +3455,12 @@ paths:
                     annual_price_cents:
                       type: integer
                       description: 年价(分)
+                    monthly_settle_cents:
+                      type: integer
+                      description: 月结算标准(分,可选,1~上限);可录入(2026-11-19 起由只读列改为可写)
                     sub_account_quota:
                       type: integer
-                      description: 分账号配额
+                      description: 分账号额度(非负,上限 9999):link 档必须 > 0;addon 档必须为 0(D-15)
                     bandwidth_committed:
                       type: boolean
                       description: 是否承诺带宽:true=承诺(缺省);false=该档「不承诺带宽」,上下行两字段一律不传
@@ -3474,7 +3483,7 @@ paths:
   /catalog/get_list@v1:
     post:
       summary: 套餐档位列表
-      description: 按 plan_kind 等条件筛选档位列表。
+      description: 按 plan_kind/plan_family 等条件筛选档位列表。每行回 plan_family、use_purpose、created_by/created_team_id 及读侧名称 created_by_name/created_team_name(D-17)。
       operationId: catalog_get_list
       tags:
       - 套餐档位
@@ -3513,9 +3522,12 @@ paths:
                     plan_kind:
                       type: string
                       description: 档位类型筛选:fixed/custom
-                    use_category:
+                    plan_family:
                       type: string
-                      description: 用途分类筛选
+                      description: 交付形态筛选:link/addon(仅自定义档可筛,固定档带此参报错)
+                      enum:
+                      - link
+                      - addon
                     customer_id:
                       type: string
                       description: 自定义档客户筛选
@@ -3890,24 +3902,18 @@ paths:
                         type: object
                         description: 服务条目
                         properties:
-                          item_kind:
-                            type: string
-                            description: 条目类型:plan_based/custom_spec
                           plan_id:
                             type: string
-                            description: 档位 ID(plan_based)
+                            description: 档位 ID(必填;2026-11-19 D-15 起条目只能引用目录档位)
                           quantity:
                             type: integer
-                            description: 数量
-                          account_count:
-                            type: integer
-                            description: 账号数(custom_spec)
-                          bandwidth_up_mbps:
-                            type: integer
-                            description: 上行带宽(Mbps,整数 1~1000,custom_spec);与下行至少填一侧,只填一侧时按上下行对称填同一值
-                          bandwidth_down_mbps:
-                            type: integer
-                            description: 下行带宽(Mbps,整数 1~1000,custom_spec);两值原样投影到派生自定义档,不折算(2026-11-05 D8 关闭)
+                            description: 份数:link 档恒 1;addon 档≥1
+                          item_family:
+                            type: string
+                            description: 交付形态(只读确认位,可缺省):只能与所引档位的 plan_family 相同,不同即 KLT-L216
+                            enum:
+                            - link
+                            - addon
                           line_exits:
                             type: array
                             maxItems: 1
@@ -3924,9 +3930,9 @@ paths:
                               契约内逐条替换(升降配,2026-11-17):本条目的新订阅顶替哪份原订阅。
                               **仅在新建合同受理**,编辑合同出现即 KLT-L222。只接受三键;
                               价格、状态、row_version 等只读派生列出现即 KLT-L222 点名。
-                              校验:原订阅属本客户、status ∈ active/pending、use_category 与条目一致、
-                              line_exit_key 相等、非 value_add、未被替换过(已被指向 ⇒ KLT-M226);
-                              同一 replaces_subscription_id 在本请求内至多一次;plan_based 条目 quantity 须为 1。
+                              校验:原订阅属本客户、status ∈ active/pending、双方均 plan_family=link、
+                              line_exit_key 相等、未被替换过(已被指向 ⇒ KLT-M226);
+                              同一 replaces_subscription_id 在本请求内至多一次;link 条目 quantity 须为 1。
                               **期间必须与原订阅相交**(2026-11-17 定案):原订阅在新订阅开始前已到期
                               ⇒ 不是替换而是到期续签,服务端**忽略本键**、按续签新开(不截原、不挂替换边、
                               不出第七类工单),回执行 mode=renewed。
@@ -3944,7 +3950,7 @@ paths:
                                   **结束日恒取合同止期**(2026-11-17 口径统一,登记总则 §18)。
                               term:
                                 type: string
-                                description: 订阅方式(yearly/quarterly/monthly);缺省按档位与用途分类派生
+                                description: 订阅方式(yearly/quarterly/monthly);缺省按档位与账期派生
                             required:
                             - replaces_subscription_id
                     renew_from_contract_id:
@@ -4044,6 +4050,28 @@ paths:
                         原样回传,改成 1 个或其它值即按改动判定。
                       items:
                         type: object
+                        properties:
+                          item_id:
+                            type: string
+                            description: 既有条目主键(三向对比:带=UPDATE/不带=INSERT/库有载荷无=DELETE)
+                          plan_id:
+                            type: string
+                            description: 档位 ID
+                          quantity:
+                            type: integer
+                            description: 份数:link 档恒 1;addon 档≥1
+                          item_family:
+                            type: string
+                            description: 交付形态(只读确认位,可缺省):与档位 plan_family 不同即 KLT-L216
+                            enum:
+                            - link
+                            - addon
+                          line_exits:
+                            type: array
+                            maxItems: 1
+                            description: 线路出口(单选,长度 1)
+                            items:
+                              type: string
                   required:
                   - contract_id
                   - row_version
@@ -4355,9 +4383,12 @@ paths:
                     monthly_settle_cents:
                       type: integer
                       description: 月结算金额(分)
-                    use_category:
+                    plan_family:
                       type: string
-                      description: 派生档用途分类(需要时填写)
+                      description: 交付形态(只读确认位,可缺省):只能与所选档位的 plan_family 相同,不同即 11103
+                      enum:
+                      - link
+                      - addon
                     term:
                       type: string
                       description: 账期(三态:yearly/quarterly/monthly)
@@ -4441,9 +4472,12 @@ paths:
                     monthly_settle_cents:
                       type: integer
                       description: 月结算金额(分)
-                    use_category:
+                    plan_family:
                       type: string
-                      description: 派生档用途分类(需要时填写)
+                      description: 交付形态(只读确认位,可缺省):只能与所选档位的 plan_family 相同,不同即 11103
+                      enum:
+                      - link
+                      - addon
                     term:
                       type: string
                       description: 账期(三态:yearly/quarterly/monthly)
@@ -4481,8 +4515,8 @@ paths:
       summary: 替换候选探测(只读)
       description: >-
         合同新建页逐条判定「是否已有可替换的原订阅」(契约内逐条替换=升降配,2026-11-17)。
-        后端统一解析用途分类(use_category 优先,否则取档位)、按「同客户 × 同分类 × 同出口 × **期间相交**」过滤
-        (status ∈ active/pending、排除 value_add、排除已被指过的 replaces_subscription_id),
+        交付形态唯一取档位 `plan_family`(D-15)、按「同客户 × 同出口 × 双方均 link × **期间相交**」过滤
+        (status ∈ active/pending、排除 addon 档、排除已被指过的 replaces_subscription_id),
         与 `/contract/create@v1` 的保存期校验是**同一份函数**(succession::candidate_filter),
         前端⛔ 自造候选范围。index 与 service_items 的 0 基下标对齐。
         2026-11-17 二轮:期间判据入候选——原订阅在新订阅开始前已到期(新合同 2027 起、旧订阅 2026-12-31 止)
@@ -4528,15 +4562,9 @@ paths:
                           index:
                             type: integer
                             description: 0 基条目下标(缺省=数组位置)
-                          item_kind:
-                            type: string
-                            description: 条目类型:plan_based/custom_spec
                           plan_id:
                             type: string
-                            description: 档位 ID(plan_based;用途分类可由档位带出)
-                          use_category:
-                            type: string
-                            description: 用途分类(custom_spec;缺省时回落档位的 use_category)
+                            description: 档位 ID(交付形态由档位带出)
                           line_exits:
                             type: array
                             maxItems: 1
@@ -4553,15 +4581,15 @@ paths:
       responses:
         "200":
           description: >-
-            成功。data.probes[] 每项回 index/item_kind/plan_id/use_category(后端解析结果)/
+            成功。data.probes[] 每项回 index/plan_id/plan_family(后端按档位解析)/
             line_exit_key/line_exits/start_date/end_date/candidates[]/skipped[];候选行含
             subscription_id/plan_id/plan_name/plan_kind/contract_id/contract_no/start_date/
             end_date/status/annual_price_cents/monthly_settle_cents/customized(true=定制档,
-            须用户显式勾选确认后才允许替换)。skipped[] 是同客户同分类同出口但**期间不相交**的行
+            须用户显式勾选确认后才允许替换)。skipped[] 是同客户同出口但**期间不相交**的行
             (subscription_id/plan_name/contract_no/start_date/end_date/status/reason,
             reason=ended_before_start=到期续签、starts_after_contract_end=本合同结束后才生效),
             只用于解释、⛔ 可被选为替换对象。
-            用途分类或出口判定不出 ⇒ KLT-L222 点名 probes[i]。
+            档位或出口判定不出 ⇒ KLT-L222 点名 probes[i]。
   /subscription/stack@v1:
     post:
       summary: 订阅叠加或白名单更新

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio