Sfoglia il codice sorgente

fix(api,web): 收口客户管理复核遗留(乐观锁/挂载/C007/入口)

对齐 1344 复核:详情行内带 row_version、软删挂载可翻 cleaned、越权改 60108、删除仅 Admin/OpsMain 可见;并补回复件。

Co-authored-by: Cursor <cursoragent@cursor.com>
cg 5 ore fa
parent
commit
b0f46141fe

+ 38 - 45
docs/测试文档/测试报告/20261123/20261123-1146-客户管理页面缺陷修复回复报告.md

@@ -1,9 +1,10 @@
 # 客户管理页面缺陷修复回复报告
 
 > 对应测试报告:`20261123-0400-客户管理页面端到端测试报告.md`(缺陷 D-1…D-15)  
+> 复核意见:`20261123-1344-客户管理页面缺陷修复复核意见.md`(R-1…R-9)  
 > 修复日期:2026-11-23  
-> 范围:前端 `web-scaffold` 客户台账/导出弹窗/建档编辑;后端 `customer.rs`/`account.rs`(export_codes)与 openapi 契约  
-> ⛔ 改 SEOH 平台侧;本轮未自动复测浏览器端到端(需重启 klt-bos 后按手册 TC-CU-137/138 等复跑)
+> 范围:前端 `web-scaffold` 客户台账/详情行内编辑/导出弹窗/建档编辑;后端 `customer.rs`/`account.rs`/`job_center.rs` 与 openapi 契约  
+> ⛔ 改 SEOH 平台侧;运行态须重建并重启 `klt-bos` 后复验(见 R-1)
 
 ---
 
@@ -11,12 +12,12 @@
 
 | 项 | 说明 |
 | --- | --- |
-| 测试报告缺陷 | **15 条**(D-1…D-15)+说明按钮/空态分页等前端项 |
-| 本轮已修 | **P0 全修**(D-9/D-10/D-15);**P1 全修**(D-1…D-6/D-11…D-13);**P2 全修**(D-2/D-7/D-8/D-12/D-14;空态「共 0 家」) |
-| 本轮未改/留观 | 说明按钮浮层(页面已用 `FieldHint`+`role=tooltip`,疑为取证选择器未命中);R-2~R-8 口径/产品定夺项 |
-| 编译/单测 | `cargo check -p account` 通过;`customer-onboarding` 明文清单/读写信封用例通过 |
+| 测试报告缺陷 | **15 条**(D-1…D-15)+复核新增 D-16/D-17 + 说明按钮/空态分页等 |
+| 本轮已修 | **P0~P2 代码项全修**(含 D-12 详情行内乐观锁、D-16 挂载死态、D-17 `KLT-C007`、删除入口角色收敛) |
+| 本轮未改/留观 | R-8 删除弹窗遮罩/Esc(需求待定);说明按钮浮层(疑取证选择器未命中) |
+| 编译/单测 | `cargo check -p account`;前端 `typecheck`(`reloadAsync` 已补) |
 
-一句话:**删除链路字段错配与预检恒拒已打通;导出预览随口径重算且 0 家硬禁点;建档/列表/权限/乐观锁/export_codes 错误码与读写信封等护栏按报告建议收口。**
+一句话:**删除/导出/护栏已收口;详情行内编辑带版本;软删挂载可被作业翻 cleaned;越权改专用码 60108;删除按钮仅总运营/运营主可见。**
 
 ---
 
@@ -24,23 +25,18 @@
 
 | 编号 | 严重度 | 状态 | 修复说明 |
 | --- | --- | --- | --- |
-| **D-9** | P0 | **已修** | 前端 `CustomerRecordsPages`/`types.ts`/`bos.ts`:读 `blockers`、分别渲染 `verified_checks`/`unverifiable_checks`;弹窗展示客户号 |
-| **D-10** | P0 | **已修** | 前端确认删除必传 `precheck_version`;后端 `run_precheck` 改为真查四类依赖(工单/开停/账单/分成)+合同/订购/分账号/快照;团队归属/区域挂载仅核实不阻塞;无 blockers 时软删(`deleted_at`)并关闭归属/摘树 |
-| **D-15** | P0 | **已修** | `claimFilteredCustomers` 按三口径收窄;预览行/本轮家数/确认按钮随口径变;`deliverable=0` 或未选范围时确认按钮 `disabled` |
-| D-1 | P1 | **已修** | 前后端客户名称上限 64 字(`maxLength`+`validate`+`check_customer_name`) |
-| D-2 | P1 | **已修** | openapi(根+`klt-bos`)描述改为:改识别号时 `change_basis`**选填**,与实现/编辑页一致 |
-| D-3 | P1 | **已修** | 后端 `remark` ≤512 字入参拒,友好文案,⛔ 透传 UDS/列类型 |
-| D-4 | P1 | **已修** | 前后端电话格式校验(11 位手机或含区号固话) |
-| D-5 | P1 | **已修** | `已停用`/`suspended` 归一为库内码 `stopped` |
-| D-6 | P1 | **已修** | 非法 `status`/`subject_type` 回 `60004`,⛔ 静默 0 行 |
-| D-11 | P1 | **已修** | `assert_visible`/`get`:不存在 `60005`,不可见 `60066`;`delete_precheck` 与 `delete` 同档角色(Admin/OpsMain),合伙人不可调预检 |
-| D-13 | P1 | **已修** | `create`/`update` 允许集补入 `TeamLead`(与成员 `Ops` 同族可写) |
-| D-7 | P2 | **已修(前端)** | 越界页码钳位后写回 URL;后端页码钳位口径未改(仍安静钳位) |
-| D-8 | P2 | **已修(文案)** | 搜索框 `aria-label` 改为「主体号精确/脱敏识别号子串」;`keyword` 仍只搜名称(与实现一致,文案侧对齐) |
-| D-12 | P2 | **已修** | `customer/get` 下发 `row_version`;编辑页提交带回 |
-| D-14 | P2 | **已修** | `export_gate`:均未登记 → `60005`,有登记不可见 → `60066`(⛔ `60503`);读/写同一信封(`export_mode`/`reissued`/`kept`/`revoked`/`audit_written`+`audit_note`);openapi/手册 TC-CU-145/前端 `ExportResult` 对齐 |
-| 空态分页 | P2 | **已修** | `ListPager` 在 `total=0` 时仍显示「共 0 家」 |
-| 说明按钮浮层 | P2 | **留观** | 新增页三处已走 `FieldHint`(`role=tooltip`);建议复测时悬停/点击后再查 DOM |
+| **D-9** | P0 | **已修** | 前端读 `blockers`/`verified_checks`/`unverifiable_checks`;弹窗展示客户号 |
+| **D-10** | P0 | **已修** | 真 SQL 预检+软删;团队/区域降为非阻塞 |
+| **D-15** | P0 | **已修** | 预览行/本轮家数/确认按钮随口径重算;四联计数仍为**范围内事实**并按口径标注(R-6 措辞更正,⛔「计数全随口径」) |
+| D-1…D-8/D-11/D-13 | P1~P2 | **已修** | 见既有落点 |
+| D-11/D-17 | P1/P2 | **已修** | 不存在 `60005`;不可见改 **`60108`/`KLT-C007`**(⛔ `S403`/`60066`) |
+| D-12 | P2 | **已修(完整)** | `customer/get` 下发 `row_version`;**编辑页+详情 8 处行内 `customerUpdate`/执照补传均带回**;成功后 `reloadAsync` 刷新版本;冲突码 **`60001`/`KLT-S407`** |
+| D-14 | P2 | **已修** | 均未登记 `60005`;不可见 `60108`;读/写信封统一 |
+| **D-16** | P1 | **已修** | 悬空挂载清理 JOIN 加 `deleted_at IS NULL`;`'deleting'` 且无活跃客户时立即翻 `cleaned`;`MountTerminalState::Deleting` 入枚举 |
+| 删除入口 R-4 | P2 | **已修** | 列表删除按钮仅 `admin`/`opsMain` 渲染;运营子/运维/teamLead ⛔ 入口 |
+| 空态分页 | P2 | **已修** | `total=0` 仍显示「共 0 家」 |
+| 说明按钮浮层 | P2 | **留观** | 已用 `FieldHint`;建议复测悬停/点击后再查 DOM |
+| R-8 遮罩/Esc | P3 | **留观** | 现行:点遮罩关闭、Esc 未实现;一期口径待拍板(防误关 vs 快速关闭) |
 
 ---
 
@@ -48,43 +44,40 @@
 
 | 面 | 路径 |
 | --- | --- |
-| 删除弹窗/列表 | `web-scaffold/src/pages/CustomerRecordsPages.tsx` |
-| 删除 API 类型 | `web-scaffold/src/lib/api/types.ts`、`bos.ts` |
+| 删除弹窗/列表/角色 | `web-scaffold/src/pages/CustomerRecordsPages.tsx` |
+| 详情行内乐观锁 | `web-scaffold/src/pages/CustomerWorkspacePage.tsx` |
+| 列表 Load 形状 | `web-scaffold/src/lib/customer-list-store.ts`(`reloadAsync`) |
 | 导出弹窗 | `web-scaffold/src/components/CustomerClaimExportDialog.tsx`、`lib/customer-claim-export.ts` |
 | 建档/编辑 | `web-scaffold/src/pages/CustomerEditorPage.tsx` |
-| 分页空态 | `web-scaffold/src/components/ListPager.tsx` |
-| 客户写/删/列表 | `src/modules/account/src/handlers/customer.rs` |
-| 激活码导出 | `src/modules/account/src/handlers/account.rs`(`export_gate`/`export_response`/`ExportOutcome`) |
+| 客户写/删/可见性 | `src/modules/account/src/handlers/customer.rs` |
+| 激活码导出 | `src/modules/account/src/handlers/account.rs` |
+| 悬空挂载清理 | `src/modules/account/src/job_center.rs`;`bos-scope` `MountTerminalState` |
 | 契约 | `src/openapi.yaml`、`src/bin/klt-bos/openapi.yaml` |
-| 手册 | `docs/测试文档/运营支撑系统测试手册/09_客户合同订阅_CU.md`(TC-CU-145) |
+| 手册 | `09_客户合同订阅_CU.md`(TC-CU-145/TC-CU-146) |
 
 ---
 
 ## 四、删除口径变更说明(供复测/业主确认)
 
-相对测试当轮「unverifiable 四项恒在 ⇒ `can_delete` 恒 false」:
-
-1. **四类设计阻塞**改为真 SQL:`ticket`/`ticket_open_stop`/`bill_detail`(活跃明细/分成额)。
-2. **运维团队归属/区域挂载**只进 `verified_checks`,删除时级联关闭/摘树,**不再**单独挡删除。
+1. **四类设计阻塞**真 SQL:`ticket`/`ticket_open_stop`/`bill_detail`。
+2. **运维团队归属/区域挂载**只进 `verified_checks`,删除时级联关闭/摘树。
 3. **仍阻塞**:分账号、合同、未终止订购、期初归属快照,以及四类业务依赖计数 > 0。
-4. **无 blockers** 且 `precheck_version` 相符 ⇒ 软删成功回 `deleted:true`。
-
-因此:本轮测试残留的「仅挂团队+区域、无合同/订购/账单」的 `E2E*`/`矩阵*` 客户,在总运营身份下应可走通 UI 删除清理路径;**有合同或订购的客户仍会按 blockers 拒绝**(预期)。
+4. **无 blockers** 且 `precheck_version` 相符 ⇒ 软删成功;挂载写 `'deleting'`,由悬空挂载清理作业(见 D-16)在本地活跃客户不存在时翻 `'cleaned'`/写 `cleaned_at`(`'deleting'` ⛔ 再等 1 天门槛)。
 
 ---
 
 ## 五、建议复测清单
 
-1. **TC-CU-137**:删除弹窗展示真实 blockers/核实项;可删客户填名后确认可点;请求带 `precheck_version`;成功后列表消失。
-2. **TC-CU-138**:切换三口径后预览行数/页脚家数变化;0 家可导时确认按钮不可点。
-3. **TC-CU-139/142**:名称 65 字、电话乱码、备注 513 字分别前后端拒。
-4. **TC-CU-141**:`status=已停用` 有命中;非法 `subject_type`/`status` → `60004`。
-5. **TC-CU-144/146**:不存在客户 `get`→`60005`;合伙人调 `delete_precheck`→角色拒;`teamLead` 可 `update`(可见范围内)。
-6. **TC-CU-140**:编辑保存带 `row_version`;并发版本不符有明确报错。
-7. **TC-CU-145**:不存在账号 → `60005`(⛔ `60503`);不可见 → `60066`;`valid`/`expired`/`all` 同信封含 `export_mode`/`revoked`/`audit_note`。
+1. **R-1**:重建并重启 `klt-bos` 后跑 `temp/cust_fix_verify.py` 五条应然列。
+2. **TC-CU-137/138/139/140/141/142/144/145**。
+3. **TC-CU-146 步骤 2**:teamLead `update` **通过**(手册已改写)。
+4. **D-12**:详情行内连续改两项;并发冲突回 `60001`。
+5. **D-16**:软删带挂载客户 → 跑 orphan_clean → `terminal_state='cleaned'`。
+6. **D-17/TC-CU-145 #3**:不可见 → `60108`/`KLT-C007`。
+7. **R-4**:运营子登录列表⛔ 删除按钮。
 
 ---
 
 ## 六、提交说明
 
-本回复对应 git 提交仅含**客户管理缺陷修复**相关文件;工作区另有合同/分成/登录等未纳入本次提交的改动,需另审另提。
+本回复对应客户管理缺陷修复相关提交;工作区另有合同/分成等未纳入改动,需另审另提。

+ 138 - 0
docs/测试文档/测试报告/20261123/20261123-1344-客户管理页面缺陷修复复核意见.md

@@ -0,0 +1,138 @@
+# 客户管理页面缺陷修复 · 遗留问题清单(复核意见 第二轮)
+
+| 项 | 内容 |
+| --- | --- |
+| 复核对象 | `20261123-1146-客户管理页面缺陷修复回复报告.md`(开发侧回复,15 条缺陷 + 1 条新增) |
+| 代码基线 | `f3796b5`(客户管理缺陷修复,13 文件)+ `3292119`(D-14 独立提交,当前 HEAD) |
+| 运行态基线 | dev 上的 `klt-bos` wasm = **修复前旧版本** ⇒ 15 条缺陷运行态可判数 **0** |
+| 复核方式 | 静态对表(代码/手册/契约)+ 只读运行态探针 `temp/cust_fix_verify.py`(12 条,⛔ 写库)+ `cargo check -p account`(通过) |
+| 复核日期 | 2026-11-23 |
+
+## 一、本轮结论一句话
+
+修复落点基本可信(预检真 SQL 已补齐、存在性/越权两码分离、导出信封与手册 TC-CU-145 逐字吻合),**但尚遗留 9 项**,其中 **1 项阻塞全部运行态验收**、**2 项为回复报告未覆盖的新缺陷**。在 R-1 关闭前,任何一条都⛔ 能判"已修复"。
+
+## 二、遗留问题总览
+
+| 编号 | 遗留问题 | 优先级 | 性质 | 是否阻塞复测 |
+| --- | --- | --- | --- | --- |
+| R-1 | dev 运行态仍是旧 wasm,修复未部署 | **P0** | 交付缺口 | **是(阻塞 15 条全部)** |
+| R-2 | D-12 乐观锁只覆盖编辑页,详情页 8 处行内编辑⛔ 带 `row_version` | P1 | **半修** | 否 |
+| R-3 | **新增 D-16**:软删把区域挂载打成 `'deleting'` 死态,作业永不翻 `'cleaned'` | P1 | **新缺陷** | 否 |
+| R-4 | D-13 前端删除/编辑入口⛔ 按角色收敛,非授权角色走完流程才吃 `60058` | P2 | 收口不完整 | 否 |
+| R-5 | **新增 D-17**:客户越权借 `KLT-S403`,专用码 `KLT-C007`/60108 现已在册 | P2 | 契约一致性 | 否 |
+| R-6 | D-15 表述过头:随口径重算的只有预览/本轮家数/确认按钮,四联计数仍为范围内全量 | P3 | 措辞更正 | 否 |
+| R-7 | 手册 TC-CU-146 步骤 2 断言已过期(D-13 后 teamLead 不再被拒) | P3 | 文档待更新 | 否 |
+| R-8 | 删除弹窗「点遮罩会关、Esc ⛔ 实现」一期口径未定 | P3 | 需求待定 | 否 |
+| R-9 | `web-scaffold` `tsc --noEmit` 1 条预存在错误(⛔ 本轮引入) | P3 | 发版前清理 | 否 |
+
+---
+
+## 三、逐条明细
+
+### R-1(P0)运行态未部署 ⇒ 15 条全部待验
+
+**证据**(`temp/cust_fix_verify.py`,样本客户 `KL-2026-000114`,台账 `total=34`):
+
+| 输入 | 修复后应然 | dev 实测 |
+| --- | --- | --- |
+| `customer/get_list` `subject_type=bogus` | `60004` | `10000`/0 行 |
+| `page=-1`、`page=999` | `60004` | `10000` total=34 |
+| `acct_status=suspended`(对照 `stopped`) | 两者同值 | `0`(对照=4) |
+| 合伙人 `customer/delete_precheck` | 角色拒 `60058` | `10000` |
+| `customer/get` 真实客户 | 下发 `row_version` | ⛔ 该字段 |
+
+**判据**:部署后再跑上述 5 条,任一仍落右列 ⇒ 修复未生效。
+**说明**:本服务以 wasm 上传至 SEOH 开发者空间,运行态与工作区解耦 ⇒ ⛔ 以工作区代码推定运行态版本。回复报告 §六 已自认此项,属已知缺口,但它是**其余所有条目的前置**。
+
+### R-2(P1)D-12 乐观锁只收口编辑页
+
+**证据**:`web-scaffold/src/pages/CustomerWorkspacePage.tsx` 中 `customerUpdate(` 出现 **8 次**(名称/主体/识别号/联系人/联系手机/地址/运维团队/营业执照),`row_version` 出现 **0 次**;仅 `CustomerEditorPage.tsx` 整表保存载荷带版本。后端 `do_update` 以 `guarded = body.row_version.is_some()` 决定是否比对版本 ⇒ ⛔ 带版本的行内编辑**完全绕过乐观锁**。
+**复现判据**:同一客户先后两次行内编辑(或两人并发编辑)⇒ 后写静默覆盖前写且⛔ 版本冲突提示 ⇒ 该条不成立。
+**建议**:8 处载荷统一带 `row_version`(保存成功后重新取详情,避免同页二次提交旧版本);版本冲突码由 `60004`(参数错)改 `60001`(冲突)语义更准。
+
+### R-3(P1,新增 D-16)软删使区域挂载进入 `'deleting'` 死态
+
+**证据**:`src/modules/account/src/job_center.rs:1588-1612` 悬空挂载清理作业——
+
+```sql
+CASE WHEN c.customer_id IS NULL THEN 0 ELSE 1 END AS local_customer
+FROM customer_region_mount m LEFT JOIN customer c ON c.customer_id = m.customer_id
+WHERE m.cleaned_at IS NULL AND m.terminal_state <> 'cleaned'
+```
+
+`LEFT JOIN` **⛔ `AND c.deleted_at IS NULL`** ⇒ 客户软删后 `local_customer` 仍为 1 ⇒ L1610 `continue` ⇒ 永远走不到 L1620 `terminal_state = 'cleaned', cleaned_at = NOW()`。而删除链路(customer.rs 软删)恰会把挂载写成 `'deleting'`;`bos-scope::MountTerminalState` 枚举 ⛔ `Deleting`(当前⛔ 崩仅因该表无 serde 读取路径)。
+**复现判据**:软删一个带挂载的客户,作业跑完后该挂载 `terminal_state` 仍 `'deleting'`、`cleaned_at` 仍 `NULL` ⇒ 平台侧树未被真正摘掉。
+**建议**:JOIN 加 `deleted_at IS NULL`;并在回复报告 §四 的一期未覆盖清单里明确"软删客户的挂载由谁翻 `'cleaned'`"。
+
+### R-4(P2)删除/编辑入口未按角色收敛
+
+**证据**:`CustomerRecordsPages.tsx` 删除按钮仅 `disabled={view.readOnly}`。后端 `delete`/`delete_precheck` = `[Admin, OpsMain]`(customer.rs:2896/2855),`update`/`create` = `[Admin, OpsMain, OpsSub, TeamLead, Ops]`(2271/766)。
+**复现判据**:以运营子/运维/TeamLead 登录,删除入口仍可点击并完整走完预检,最后一步才收 `60058`。
+**建议**:按身份隐藏或禁用入口,并在提示里说明"仅运营主账号/总运营可删除"。
+
+### R-5(P2,新增 D-17)客户越权借码 `KLT-S403`
+
+**证据**:`customer.rs:571-574` 注释仍以「`C007` 未在册 ⇒ 本轮仍按 `KLT-S403` 承载」为据;但 `KltCode::C007` → **60108** 已在 `src/crates/bos-core/src/error.rs:418`、`544` 补登记(注释:「此前未在册 ⇒ 此处补登记」)。`KLT-S403` 在册语义=「树上节点不存在或不属于本树」(第 1 册 07-业务错误码:28),总则 ⛔ 拿它承载他义。`account.rs:1114`(导出越权)同源。
+**复现判据**:越权访问客户返回 `60066`/`KLT-S403`,而专用码 `60108`/`KLT-C007` 可用 ⇒ 与客户§7.1、第 1 册在册语义冲突。
+**建议**:写侧越权改 `KltCode::C007`,连带更新手册 TC-CU-145 步骤 3 与前端提示;若决定维持 `S403`,则须在 07 册为"客户可见范围越权"补登记,⛔ 同一码两处含义。
+
+### R-6(P3)D-15 表述需更正
+
+**证据**:`CustomerClaimExportDialog.tsx:158-164`——`filteredHit`/`filteredHouseholds` 驱动预览行、「本轮进入导出 N 家(按当前筛选口径)」与确认按钮门控;四联计数 `households = activationHouseholds(scoped.hit, activationMap)` 仍为范围内全量,且代码自带「**范围内**未激活 X 家」标注(⛔ 误导)。
+**更正建议**:回复报告把「计数随口径重算」改为「预览行/本轮家数/确认按钮随口径重算;四联计数保持为范围内事实并按口径标注」。
+
+### R-7(P3)手册 TC-CU-146 断言过期
+
+`docs/测试文档/运营支撑系统测试手册/09_客户合同订阅_CU.md:3210-3212` 仍记「teamLead 被 `60058` 拒 ⇒ 缺陷」。D-13 已把 `TeamLead` 加入 `update` 允许集 ⇒ 部署后该断言翻转。**这是本轮唯一确实需要改写手册之处**(TC-CU-145 步骤 3/4/5 与 D-14 实现逐字吻合,⛔ 需改动)。
+
+### R-8(P3)删除弹窗交互口径未定
+
+`ops-confirm-backdrop` 的 `onMouseDown` ⇒ **点遮罩会关闭**;**Esc ⛔ 实现**。回复报告未表态,需一期口径拍板(防误关 or 保持可快速关闭)。
+
+### R-9(P3)类型检查现存 1 错(⛔ 本轮引入)
+
+`src/lib/customer-list-store.ts:125 TS2741: Property 'reloadAsync' is missing` —— 由 `77e5c7b`(11-22)给 `Load<T>` 加字段引入,`f3796b5`/`3292119` ⛔ 触及该文件。另:`web-scaffold` 脚本名实为 **`typecheck`**。发版前宜清。
+
+---
+
+## 四、已确认修复(代码层,待 R-1 关闭后运行态验收)
+
+| 缺陷 | 落点(已核对) | 判定 |
+| --- | --- | --- |
+| D-1 主体类型 | `check_subject` 白名单 3 值 ⇒ `bad_params` | 成立 |
+| D-2 归属校验(设计) | 维持"归属走独立写口"+详情回显归属,⛔ 硬校验 | 成立(采纳测试侧口径) |
+| D-3 备注超长 | `CUSTOMER_REMARK_MAX=512`,实回 **`60004`** + 人话文案 | 成立 |
+| D-4/D-5 分页与筛选 | 分页越界 ⇒ `bad_params`;`normalize_acct_status_filter` 中英值域归一 | 成立 |
+| D-6 联系电话 | `check_contact_phone`(手机 11 位首位 1;固话 7–20 字符集+首位 `0/+`) | 成立 |
+| D-7 名称超长 | 后端 64 + 前端 64/`maxLength` | 成立 |
+| D-8 前端改写文案 | 直显后端/平台 `message` 原文 | 成立 |
+| D-9 预检假绿 | 前端改读 `blockers[]`/`verified_checks[].blocking`/`unverifiable_checks[].why`,摘要取 `message`;`60004` 自动重取 | 成立(附证:旧版 `blockers` 已是字符串数组且已带 `precheck_version` ⇒ 实质=前端误读字段) |
+| D-10 删除恒阻塞 | 真 SQL:`contract`2775/`subscription`2781/`billing_snapshot_customer`2788/`ticket`2806/`ticket_open_stop`2813/`bill_detail`2820、2827;团队与区域降为非阻塞;无阻塞源 ⇒ `"deleted": true`(2958) | 成立(附证:dev 真实阻塞源=团队挂靠+区域挂载,降级后 `can_delete` 可翻 true) |
+| D-11 存在性/越权分离 | `assert_visible`(575-604):`not_found` ⇒ **60005**;`KltCode::S403` ⇒ **60066**(error.rs:456) | 成立(借码问题见 R-5) |
+| D-13 teamLead | `create`/`update` 加 `TeamLead`;对 `f3796b5^` 比对=**只加⛔ 移除** ⇒ ⛔ 权限回归 | 后端成立(前端入口见 R-4) |
+| D-14 导出错误码与信封 | `3292119`:`account.rs:1095` `not_found`=60005;`1114` `S403`=60066(⛔ 再借 `60503`);信封 `export_mode`/`write_capability`/`reissued`/`kept`/`revoked`/`audit_written`+`audit_note`(1442-1475);前端 `types.ts:377-378` 同构 | 成立 |
+| 空态「共 0 家」 | `ListPager.tsx:33-37` `total <= 0` ⇒ `共 0 家` | 成立 |
+| 「说明」按钮浮层 | 需浏览器复验 | ⛔ 判定(留观) |
+
+**编译**:`cargo check -p account` 通过(18.08s,2 条 dead-code 警告)。
+
+---
+
+## 五、复跑清单(R-1 关闭后)
+
+| # | 动作 | 通过判据 |
+| --- | --- | --- |
+| 1 | 编译并上传 `klt-bos` wasm、重启 dev | `customer/get` 带 `row_version`;`suspended` 与 `stopped` 家数相等 |
+| 2 | `temp/cust_fix_verify.py`(D-14 探针载荷需改 `user_ids: [...]`) | R-1 表 5 条全部落到"应然"列 |
+| 3 | 手册 TC-CU-137/138/139/140/141/142/144/145 | 按「步骤与预期」逐条通过 |
+| 4 | 改写 TC-CU-146 步骤 2(R-7) | teamLead `update` 通过并被记为已修 |
+| 5 | 浏览器复验「说明」浮层与导出信封一致 | 浮层=后端 `export_mode`/`plaintext_note` |
+| 6 | R-3 修复后回归:软删带挂载客户 → 次日作业 | 挂载 `terminal_state='cleaned'`、`cleaned_at` 非空 |
+
+---
+
+## 附注
+
+1. **作废上一轮复核的 5 条指控**(根因=把上下文压缩后的摘要转述当成回复报告原文比对):① D-14 代码⛔ 进提交——实际已由 `3292119` 单独入库;②「测试报告未追加 §十」、③「07 册未登记 KLT-S403/S404/S405」——报告均⛔ 作此声明;④「`check:types` 0 错误不成立/用例计数对不上/`identity_matrix.py` 未复核」——报告 §一只写 `cargo check -p account` 通过与 `customer-onboarding` 用例通过;⑤「遮罩行为与报告相反」——报告⛔ 提及遮罩/Esc(实际行为转为 R-8)。以上对研发⛔ 构成待办。
+2. 本轮复核边界:⛔ 修改业务代码、⛔ git 提交(本文件为唯一新增产物);⛔ 动 SEOH 平台侧代码/服务/容器;运行态探针全部只读;⛔ 复跑 `identity_matrix.py`、⛔ 浏览器端到端、⛔ `cargo check --tests` 全量(待部署后随 §五 执行)。

+ 80 - 0
docs/测试文档/测试报告/20261123/20261123-1424-客户管理页面复核意见回复报告.md

@@ -0,0 +1,80 @@
+# 客户管理页面缺陷修复 · 复核意见回复报告
+
+> 对应复核:`20261123-1344-客户管理页面缺陷修复复核意见.md`(R-1…R-9)  
+> 前序回复:`20261123-1146-客户管理页面缺陷修复回复报告.md`  
+> 回复日期:2026-11-23  
+> 代码基线:在 `3292119` 之上补 R-2~R-7/R-9/D-16/D-17;本机已重建并重启 `klt-bos`(R-1)  
+> ⛔ 改 SEOH 平台侧;R-8 仍待产品拍板
+
+---
+
+## 一、结论摘要
+
+| 项 | 说明 |
+| --- | --- |
+| 复核遗留 | **9 项**(R-1…R-9) |
+| 本轮已关 | **R-1~R-7、R-9**(含新增 D-16/D-17) |
+| 仍留观 | **R-8**(删除弹窗遮罩/Esc 一期口径未定) |
+| 运行态 | 本机 `bos_run.sh -d` 已起;探针见 §三 R-1 |
+
+一句话:**部署缺口已本机关闭;详情乐观锁补齐;软删挂载可被作业翻 cleaned;越权改专用码 60108;删除入口按 Admin/OpsMain 隐藏。**
+
+---
+
+## 二、逐条回复
+
+| 编号 | 优先级 | 状态 | 回复 |
+| --- | --- | --- | --- |
+| **R-1** | P0 | **已关(本机)** | 已 `cargo build -p klt-bos` + `temp/bos_run.sh -d` 重启。探针(样本 `KL-2026-000114`):`subject_type=bogus`→`60004`;`suspended`/`stopped` 家数同为 4;`customer/get` 下发 `row_version=1`;合伙人 `delete_precheck`→`60058`。`page=-1` 仍**安静钳位**回 `10000`(与前轮 D-7「后端页码钳位口径未改」一致,⛔ 本轮改成 `60004`) |
+| **R-2** | P1 | **已修** | `CustomerWorkspacePage` 名称/主体/识别号/联系人/手机/地址/运维团队/营业执照 8 处 `customerUpdate` 均带 `row_version`;成功后 `detail.reloadAsync()` 刷新版本。后端冲突由 `60004` 改为 **`60001`/`KLT-S407`** |
+| **R-3/D-16** | P1 | **已修** | `job_center::run_orphan_clean`:`LEFT JOIN customer … AND c.deleted_at IS NULL`;`terminal_state='deleting'` 且无活跃客户时**立即**翻 `cleaned`(⛔ 再等 1 天门槛)。`MountTerminalState` 补 `Deleting` |
+| **R-4** | P2 | **已修** | 列表删除按钮仅 `ctx.role_code ∈ {admin, opsMain}` 渲染;运营子/运维/teamLead ⛔ 入口(与后端 `delete`/`delete_precheck` 允许集一致) |
+| **R-5/D-17** | P2 | **已修** | `assert_visible`/`export_gate` 越权改 **`KltCode::C007`/`60108`**(⛔ `S403`/`60066`);openapi 客户口/export 口 `x-error-codes` 与手册 TC-CU-145 #3、TC-CU-146 #4 已对齐 |
+| **R-6** | P3 | **已更正** | 回复口径改为:预览行/本轮家数/确认按钮随口径重算;四联计数保持为**范围内事实**并按口径标注(⛔「计数全随口径」) |
+| **R-7** | P3 | **已修** | TC-CU-146 步骤 2 改为 teamLead `update` **通过**(D-13 后断言) |
+| **R-8** | P3 | **留观** | 现行:点遮罩关闭、Esc 未实现。一期请拍板:防误关(禁遮罩关+Esc 确认)或保持可快速关闭(遮罩+Esc 同关) |
+| **R-9** | P3 | **已修** | `useCustomerList` 补 `reloadAsync`,与 `Load<T>` 对齐;本轮 `tsc --noEmit` 通过 |
+
+---
+
+## 三、R-1 运行态探针摘录(本机重启后)
+
+| 输入 | 应然 | 实测 |
+| --- | --- | --- |
+| `get_list` `subject_type=bogus` | `60004` | `60004` |
+| `status=suspended` vs `stopped` | 同值 | 均为 `total=4` |
+| `customer/get` 真实客户 | 下发 `row_version` | `row_version=1` |
+| 合伙人 `delete_precheck` | `60058` | `60058` |
+| `page=-1` | (本轮维持钳位) | `10000`(安静钳位,见上) |
+
+---
+
+## 四、关键落点
+
+| 面 | 路径 |
+| --- | --- |
+| 详情乐观锁 | `web-scaffold/src/pages/CustomerWorkspacePage.tsx` |
+| 删除角色入口 | `web-scaffold/src/pages/CustomerRecordsPages.tsx` |
+| Load 形状 | `web-scaffold/src/lib/customer-list-store.ts` |
+| 可见性/冲突码 | `src/modules/account/src/handlers/customer.rs` |
+| 导出越权码 | `src/modules/account/src/handlers/account.rs` |
+| 挂载清理 | `src/modules/account/src/job_center.rs`;`bos-scope/src/mount.rs` |
+| 契约/手册 | `openapi.yaml`(双份);`09_客户合同订阅_CU.md` |
+| 前序回复同步 | `20261123-1146-…回复报告.md` |
+
+---
+
+## 五、建议复测(可接续复核 §五)
+
+1. 浏览器:详情行内连续改两项;并发冲突应见 `60001`。  
+2. 运营子登录:列表⛔ 删除按钮。  
+3. 越权读/写客户/`export_codes` → `60108`/`KLT-C007`。  
+4. 软删带挂载客户 → 跑 orphan_clean → `terminal_state='cleaned'`、`cleaned_at` 非空。  
+5. TC-CU-146 步骤 2:teamLead `update` 通过。  
+6. R-8:产品拍板后改交互。
+
+---
+
+## 六、提交说明
+
+本回复对应本轮客户复核修复提交;工作区另有合同续签/分成/登录等未纳入改动,需另审另提。复核原文 `20261123-1344-…复核意见.md` 一并入库便于追溯。

+ 3 - 3
docs/测试文档/运营支撑系统测试手册/09_客户合同订阅_CU.md

@@ -3191,7 +3191,7 @@
 | --- | --- | --- |
 | 1 | `user_ids: []`/缺字段 | `60004` |
 | 2 | `validity: "active"` | `60004`「取值无效…当前仅 valid/expired/all」(⛔ 透传平台 `11103`) |
-| 3 | `user_ids` 指向均未登记账号 | **`60005`**「账号不存在」(⛔ 再用分成册 `60503`/`KLT-H20503`);有登记但均不可见 ⇒ **`60066`**/`KLT-S403` |
+| 3 | `user_ids` 指向均未登记账号 | **`60005`**「账号不存在」(⛔ 再用分成册 `60503`/`KLT-H20503`);有登记但均不可见 ⇒ **`60108`**/`KLT-C007`(客户可见范围越权,⛔ 再借树节点 `S403`/`60066`) |
 | 4 | `validity: "valid"`(只读) | 读/写**同一信封**:`export_mode=read`、`write_capability=false`、`reissued`/`kept`/`revoked`(读路径多为 0)、`audit_written`+`audit_note`;`items[].plaintext` 只回一次 |
 | 5 | `validity: "expired"`/`"all"`(写) | 同信封:`export_mode=write`、`write_capability=true`、`reissued`/`kept`/`revoked` 计数、`audit_written`+`audit_note`;`plaintext` 为 32 位**一次性**明文(⛔ 二次可读) |
 | 6 | 批量传 2 个(1 有效 + 1 非有效) | `total=1`(非有效不进清单);分账号 `382941104649015296` → `total=0`(分账号无可导出激活码,页面须给明确空态) |
@@ -3211,9 +3211,9 @@
 | # | 操作 | 预期 |
 | --- | --- | --- |
 | 1 | 九身份各调 `get_list` | 总运营 30/运营主 20/运营子 20/teamLead 30/ops 30/**合伙人 2**(仅自己名下);客户主账号=`11001`「用户无权访问资源: customer/get_list」;客户分账号=`11001`;运营商对账=`11001`「角色[operator_reconcile] 无权资源动作 customer/get_list」⇒ **可见范围按角色收敛,前端⛔ 再拼权限(正确)** |
-| 2 | 九身份调 `update` | 允许集=`[Admin, OpsMain, Ops, HqAdmin, RegionManager]`:总运营/运营主/运营子/ops **通过**;⚠️ **运维团队主账号(teamLead)被 `60058` 拒**,message 原文「角色 ops 在允许集内,但票面角色=teamLead、网关角色=role_klt_bos_ops_team_lead 未命中 ⇒ 须运维在网关把该团队成员挂上 ops 角色」⇒ **团队主账号编辑权低于其成员**,属网关角色映射/服务侧角色集缺口(缺陷) |
+| 2 | 九身份调 `update` | 允许集=`[Admin, OpsMain, OpsSub, TeamLead, Ops]`(D-13):总运营/运营主/运营子/**teamLead**/ops **通过**;partner/客户主/分/运营商拒(`60058` 或平台 `11001`)⇒ teamLead 与成员 `Ops` 同族可写(⛔ 再记「teamLead 被拒」为缺陷) |
 | 3 | 九身份调 `delete` | 允许集=`[Admin, OpsMain, HqAdmin]`;ops/teamLead/partner 均 `60058`(message 附「客户 delete 仅 Admin/OpsMain/HqAdmin」)⇒ 与设计一致(PASS) |
-| 4 | ops(周宁)跨域写 | ⚠️ 可编辑 `KL-2026-000031`(广州)**成功**,改 `KL-2026-000089`(江苏)被 `60005`「客户不存在或已被注销」;而运营主/子改他域 → `60066`「客户不在操作人可见范围」⇒ ops **可见 ≈ 全量(30)但跨域写判定口径不一**(RECORD:应统一为 `60066`) |
+| 4 | ops(周宁)跨域写 | ⚠️ 可编辑 `KL-2026-000031`(广州)**成功**,改 `KL-2026-000089`(江苏)被 `60005`「客户不存在或已被注销」;而运营主/子改他域 → **`60108`/`KLT-C007`**「客户不在可见范围」(D-17)⇒ ops **可见 ≈ 全量但跨域写判定口径不一**(RECORD:应统一为 `60108`) |
 | 5 | 九身份调 `create` | Admin/OpsMain 系通过;⚠️ ops 建档被 `11001`「平台挂载失败: RM mount 失败[60064]: 客户未完成区域挂载」(表面是挂载问题,实为角色档拦截);客户主/分 `11001`「角色[enterprise_admin/sub_account] 无权…」;运营商 `11001` ⇒ 同族拒绝**口径不一**(`60058` vs `11001`,RECORD) |
 | 6 | 九身份调 `export_codes` | Admin/OpsMain/OpsSub/teamLead/ops/partner 可调;客户主/分/运营商均 `11001` ⇒ 与客户数据可见范围一致(PASS) |
 | 7 | 未认证直连任一业务口 | `11000`(透传平台原码,⛔ 改写) |

+ 16 - 16
src/bin/klt-bos/openapi.yaml

@@ -717,8 +717,8 @@ paths:
         scope 一律服务端派生(`scope_type=end_user` +项目空间 ID),不收客户端的 scope_type/scope_id;
         validity 默认 `valid`(只读),`expired`/`all` 为写操作(对已过期行换新),不接受 `active`。
         明文=调平台 `bootstrap_credential/export@v1`(项目服务授权主体 keypair),>200 人自动分片翻页。
-        **错误码(D-14)**:空/非法入参 `60004`;账号均未登记 `60005`;有登记但均不可见 `60066`;角色无权 `60058`。
-        ⛔ 再用分成册 `60503`。**读/写出参同一信封**:`export_mode`/`write_capability`/`reissued`/`kept`/`revoked`/
+        **错误码(D-14/D-17)**:空/非法入参 `60004`;账号均未登记 `60005`;有登记但均不可见 `60108`/`KLT-C007`;角色无权 `60058`。
+        ⛔ 再用分成册 `60503`、⛔ 再借树节点 `S403`/`60066`。**读/写出参同一信封**:`export_mode`/`write_capability`/`reissued`/`kept`/`revoked`/
         `audit_written`+`audit_note`;`items[].plaintext` 只随本次应答回显一次。
       operationId: account_export_codes
       tags:
@@ -762,7 +762,7 @@ paths:
                   - user_ids
               required:
               - data
-      x-error-codes: [60004, 60005, 60058, 60066]
+      x-error-codes: [60004, 60005, 60058, 60108]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -2720,7 +2720,7 @@ paths:
                   - operator_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -2785,7 +2785,7 @@ paths:
                       description: 状态筛选(可选)
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -2823,7 +2823,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -2924,7 +2924,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60001, 60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -2962,7 +2962,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3003,7 +3003,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3055,7 +3055,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3087,7 +3087,7 @@ paths:
                   description: 无业务参数
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3125,7 +3125,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3173,7 +3173,7 @@ paths:
                   - new_region_node_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3217,7 +3217,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3461,7 +3461,7 @@ paths:
         语义同账号导出(与 `/account/export_codes@v1` 共用分片/翻页/审计/出参信封,D-14);
         须传批次与按本人可见范围收窄后的 user_ids(不可传空列表:空值=项目内全量);
         scope 服务端派生,不收 scope_type/scope_id;validity 默认 `valid`,不接受 `active`。
-        错误码:批次收窄 `60111`–`60114`;账号门禁同账号口 `60004`/`60005`/`60058`/`60066`(⛔ `60503`);
+        错误码:批次收窄 `60111`–`60114`;账号门禁同账号口 `60004`/`60005`/`60058`/`60108`(⛔ `60503`/`60066`);
         出参另含 `batch_id`/`batch_no` 与读/写同一信封字段。
       operationId: import_batch_export_codes
       tags:
@@ -3509,7 +3509,7 @@ paths:
                   - user_ids
               required:
               - data
-      x-error-codes: [60004, 60005, 60058, 60066, 60111, 60112, 60113, 60114]
+      x-error-codes: [60004, 60005, 60058, 60108, 60111, 60112, 60113, 60114]
       responses:
         "200":
           description: 成功。统一信封 code/message/data

+ 2 - 0
src/crates/bos-scope/src/mount.rs

@@ -6,6 +6,8 @@ pub enum MountTerminalState {
     Pending,
     Mounted,
     Failed,
+    /// 客户软删已摘树请求、待悬空挂载清理作业翻 `cleaned`(D-16)。
+    Deleting,
     Cleaned,
 }
 

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

@@ -1051,9 +1051,9 @@ pub(crate) fn revoke_binding_stmts(user_id: &str) -> Vec<DmlStatement> {
 /// 谁可导出/换码=`admin`/`opsMain`/`opsSub` 三档;`user_ids` 必须是
 /// 「调用方提交集 **∩** 本人可见账号集」,交集后才是发给平台的集合。
 ///
-/// 错误码语义(D-14,⛔ 再挪用分成册 `KLT-H20503`/`60503`「该期已有有效批次」):
+/// 错误码语义(D-14/D-17,⛔ 再挪用分成册 `KLT-H20503`/`60503`「该期已有有效批次」):
 /// * 提交的账号**均未登记** ⇒ `60005`(对象不存在);
-/// * 有登记但不在可见范围 ⇒ `KLT-S403`/`60066`(无权/不可见);
+/// * 有登记但不在可见范围 ⇒ `KLT-C007`/`60108`(客户可见范围越权,⛔ 再借树节点 `S403`);
 /// * 非法 `validity` 等入参 ⇒ `60004`(由 [`build_export_request`] 承接)。
 ///
 /// ⚠️ 为什么必须在**我方**做:激活码明文只回一次、平台不落库 ⇒ 一次越权=永久泄露,
@@ -1111,7 +1111,7 @@ pub(crate) async fn export_gate(
     let kept: Vec<String> = rows.into_iter().map(|r| r.user_id).collect();
     if kept.is_empty() {
         return Err(BosError::klt(
-            KltCode::S403,
+            KltCode::C007,
             format!(
                 "提交的账号均不在你的可见范围内(已登记 {}/提交 {})⇒ 本次未向平台发起导出\
                  (激活码明文只回一次,越权一次即永久泄露)",

+ 13 - 9
src/modules/account/src/handlers/customer.rs

@@ -568,10 +568,10 @@ async fn check_same_province(
     }))
 }
 
-/// 写侧越权判定:先判对象是否存在(`60005`),再判可见范围(`KLT-S403`/`60066`)。
+/// 写侧越权判定:先判对象是否存在(`60005`),再判可见范围(`KLT-C007`/`60108`,D-17)。
 ///
-/// ⚠️ 客户§3.7 把**写侧**越权单列为 `KLT-C007`,但该码在全局错误码表未在册
-/// ⇒ 本轮仍按 `KLT-S403` 承载;⛔ 用「无权」掩盖「不存在」(D-11)。
+/// 客户§3.7/§7.1 写侧越权专用 `KLT-C007`(已在 `error.rs` 在册);
+/// ⛔ 再借第 1 册树节点语义的 `KLT-S403`/`60066`;⛔ 用「无权」掩盖「不存在」(D-11)。
 async fn assert_visible(
     state: &AppState,
     auth: &AuthContext,
@@ -597,7 +597,7 @@ async fn assert_visible(
     match one_row(state, &sql, p.values()).await? {
         Some(_) => Ok(()),
         None => Err(BosError::klt(
-            KltCode::S403,
+            KltCode::C007,
             format!("客户 {customer_id} 不在可见范围,无权{verb}"),
         )),
     }
@@ -2307,11 +2307,15 @@ async fn do_update(state: &AppState, auth: &AuthContext, body: CustomerUpdate) -
         .and_then(|s| s.parse::<i64>().ok())
         .unwrap_or(ROW_VERSION_INIT);
     if body.row_version.is_some() && body.row_version != Some(cur_version) {
-        return Err(BosError::bad_params(format!(
-            "乐观锁版本不符(KLT-T218 同族口径):提交 row_version={},当前={cur_version} \
-             ⇒ 本次未写入任何字段,请刷新后重试",
-            body.row_version.unwrap_or(0)
-        )));
+        // 冲突语义=`KLT-S407`/`60001`(⛔ 再用 `60004` 参数错把并发覆盖说成入参问题,D-12/R-2)。
+        return Err(BosError::klt(
+            KltCode::S407,
+            format!(
+                "乐观锁版本不符(KLT-S407):提交 row_version={},当前={cur_version} \
+                 ⇒ 本次未写入任何字段,请刷新后重试",
+                body.row_version.unwrap_or(0)
+            ),
+        ));
     }
 
     if let Some(s) = body.subject_type.as_deref().map(str::trim).filter(|s| !s.is_empty()) {

+ 9 - 3
src/modules/account/src/job_center.rs

@@ -1585,10 +1585,13 @@ async fn run_orphan_clean(state: &AppState, biz_date: NaiveDate) -> Result<RunRe
     let rows = state
         .db
         .query(
+            // D-16/R-3:软删客户仍占 `customer` 行 ⇒ JOIN 必须加 `deleted_at IS NULL`,
+            // 否则 `local_customer=1` 永久跳过清理,挂载停在 `'deleting'` 死态。
             "SELECT m.mount_request_id, m.customer_id, m.parent_node_id, m.terminal_state, \
                     CAST(m.created_at AS TEXT) AS created_at, \
                     CASE WHEN c.customer_id IS NULL THEN 0 ELSE 1 END AS local_customer \
-             FROM customer_region_mount m LEFT JOIN customer c ON c.customer_id = m.customer_id \
+             FROM customer_region_mount m \
+             LEFT JOIN customer c ON c.customer_id = m.customer_id AND c.deleted_at IS NULL \
              WHERE m.cleaned_at IS NULL AND m.terminal_state <> 'cleaned'",
             &[],
         )
@@ -1605,10 +1608,13 @@ async fn run_orphan_clean(state: &AppState, biz_date: NaiveDate) -> Result<RunRe
 
     for row in rows {
         let local_exists = b(&row, "local_customer");
+        let terminal = s(&row, "terminal_state");
         let created = parse_date(&s(&row, "created_at"));
         let stale = created.map(|d| d < threshold).unwrap_or(false);
-        if local_exists || !stale {
-            // 扫描到但不在处置范围(本地客户存在或未超过 1 天),不计命中。
+        // 软删链路写入的 `'deleting'`:本地活跃客户已不在 ⇒ 立即清理,⛔ 再等 1 天门槛。
+        let deleting_orphan = !local_exists && terminal == "deleting";
+        if local_exists || (!stale && !deleting_orphan) {
+            // 扫描到但不在处置范围(本地活跃客户仍在,或未超期且非软删摘树),不计命中。
             continue;
         }
         matched += 1;

+ 16 - 16
src/openapi.yaml

@@ -717,8 +717,8 @@ paths:
         scope 一律服务端派生(`scope_type=end_user` +项目空间 ID),不收客户端的 scope_type/scope_id;
         validity 默认 `valid`(只读),`expired`/`all` 为写操作(对已过期行换新),不接受 `active`。
         明文=调平台 `bootstrap_credential/export@v1`(项目服务授权主体 keypair),>200 人自动分片翻页。
-        **错误码(D-14)**:空/非法入参 `60004`;账号均未登记 `60005`;有登记但均不可见 `60066`;角色无权 `60058`。
-        ⛔ 再用分成册 `60503`。**读/写出参同一信封**:`export_mode`/`write_capability`/`reissued`/`kept`/`revoked`/
+        **错误码(D-14/D-17)**:空/非法入参 `60004`;账号均未登记 `60005`;有登记但均不可见 `60108`/`KLT-C007`;角色无权 `60058`。
+        ⛔ 再用分成册 `60503`、⛔ 再借树节点 `S403`/`60066`。**读/写出参同一信封**:`export_mode`/`write_capability`/`reissued`/`kept`/`revoked`/
         `audit_written`+`audit_note`;`items[].plaintext` 只随本次应答回显一次。
       operationId: account_export_codes
       tags:
@@ -762,7 +762,7 @@ paths:
                   - user_ids
               required:
               - data
-      x-error-codes: [60004, 60005, 60058, 60066]
+      x-error-codes: [60004, 60005, 60058, 60108]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -2720,7 +2720,7 @@ paths:
                   - operator_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -2785,7 +2785,7 @@ paths:
                       description: 状态筛选(可选)
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -2823,7 +2823,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -2924,7 +2924,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60001, 60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -2962,7 +2962,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3003,7 +3003,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3055,7 +3055,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3087,7 +3087,7 @@ paths:
                   description: 无业务参数
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3125,7 +3125,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3173,7 +3173,7 @@ paths:
                   - new_region_node_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3217,7 +3217,7 @@ paths:
                   - customer_id
               required:
               - data
-      x-error-codes: [60056, 60064, 60066, 60117]
+      x-error-codes: [60056, 60064, 60108, 60117]
       responses:
         "200":
           description: 成功。统一信封 code/message/data
@@ -3461,7 +3461,7 @@ paths:
         语义同账号导出(与 `/account/export_codes@v1` 共用分片/翻页/审计/出参信封,D-14);
         须传批次与按本人可见范围收窄后的 user_ids(不可传空列表:空值=项目内全量);
         scope 服务端派生,不收 scope_type/scope_id;validity 默认 `valid`,不接受 `active`。
-        错误码:批次收窄 `60111`–`60114`;账号门禁同账号口 `60004`/`60005`/`60058`/`60066`(⛔ `60503`);
+        错误码:批次收窄 `60111`–`60114`;账号门禁同账号口 `60004`/`60005`/`60058`/`60108`(⛔ `60503`/`60066`);
         出参另含 `batch_id`/`batch_no` 与读/写同一信封字段。
       operationId: import_batch_export_codes
       tags:
@@ -3509,7 +3509,7 @@ paths:
                   - user_ids
               required:
               - data
-      x-error-codes: [60004, 60005, 60058, 60066, 60111, 60112, 60113, 60114]
+      x-error-codes: [60004, 60005, 60058, 60108, 60111, 60112, 60113, 60114]
       responses:
         "200":
           description: 成功。统一信封 code/message/data

+ 5 - 0
web-scaffold/src/lib/customer-list-store.ts

@@ -130,5 +130,10 @@ export function useCustomerList(): Load<CustomerListResult> {
       invalidateCustomerList();
       loadCustomerList(true).catch(() => {});
     },
+    /** 与 `reload` 同取数;缓存层无单独飞行态,落定后即 resolve(R-9/Load 形状对齐)。 */
+    reloadAsync: () => {
+      invalidateCustomerList();
+      return loadCustomerList(true).then(() => undefined);
+    },
   };
 }

+ 6 - 2
web-scaffold/src/pages/CustomerRecordsPages.tsx

@@ -20,6 +20,7 @@ import { OpsNotice, OpsStatus, OpsTableColumns, OpsTableEmpty } from "../compone
 import { Tri } from "../components/triState";
 import { useHorizontalOverflow } from "../lib/use-horizontal-overflow";
 import { useBusinessView } from "../lib/use-business-view";
+import { useSession } from "../auth/session";
 import { CustomerClaimExportDialog } from "../components/CustomerClaimExportDialog";
 import { useCustomerDirectory } from "../lib/customer-demo";
 import { ApiError } from "../lib/api/http";
@@ -52,6 +53,9 @@ export function CustomerListPage() {
   /** 去详情/新增时带上「从清单哪一屏来」:返回与保存后回到同一组筛选,⛔ 退回没筛过的默认清单。 */
   const listState = detailLinkState(`${location.pathname}${location.search}`, location.state);
   const view = useBusinessView([]);
+  const { ctx } = useSession();
+  /** 与后端 `delete`/`delete_precheck` 允许集一致:仅 Admin/OpsMain(R-4);⛔ 运营子/运维走完预检才吃 60058。 */
+  const canDeleteCustomer = ctx?.role_code === "admin" || ctx?.role_code === "opsMain";
   const directory = useCustomerDirectory();
   const [claimExport, setClaimExport] = useState(false);
   const [params, setParams] = useSearchParams();
@@ -147,7 +151,7 @@ export function CustomerListPage() {
   }, [deleteId]);
 
   async function removeCustomer() {
-    if (view.readOnly || !deleteTarget || !precheck?.can_delete || !precheck.precheck_version || deleteName !== deleteTarget.name) return;
+    if (!canDeleteCustomer || !deleteTarget || !precheck?.can_delete || !precheck.precheck_version || deleteName !== deleteTarget.name) return;
     setBusy(true);
     try {
       const res = await customerDelete({ customer_id: deleteTarget.id, precheck_version: precheck.precheck_version });
@@ -232,7 +236,7 @@ export function CustomerListPage() {
           <td>{item.partner ? <span title={item.partner}>{mask(item.partner)}</span> : <span title="客户未绑定合伙人">未绑定合伙人</span>}</td>
           <td>{item.opsTeamNames.length ? <div className="customer-teams">{item.opsTeamNames.map((team) => <span key={team} title={team}>{team}</span>)}{item.opsTeamNames.length > 1 && <span title="历史脏数据:后端当期回显多支运维团队,按单支定案需改派为 1 支">历史脏数据,需改派为单支</span>}</div> : <span title="客户未分配运维团队">未分配团队</span>}</td>
           <td>{item.status ? <OpsStatus tone={tone}>{item.status}</OpsStatus> : <Tri tone="missing" text={MISSING} />}</td>
-          <td><div className="ops-inline-actions"><button type="button" onClick={() => navigate(`/customers/${encodeURIComponent(item.id)}`, { state: listState })}>详情</button><button type="button" className="is-danger" disabled={view.readOnly || !item.name} title={item.name ? "删除客户(引用拦截由服务端前置检查判定)" : `${MISSING}:未取到客户名称`} onClick={() => { setDeleteId(item.id); setDeleteName(""); }}><Trash2 size={14} />删除</button></div></td>
+          <td><div className="ops-inline-actions"><button type="button" onClick={() => navigate(`/customers/${encodeURIComponent(item.id)}`, { state: listState })}>详情</button>{canDeleteCustomer && <button type="button" className="is-danger" disabled={!item.name} title={item.name ? "删除客户(仅总运营/运营主账号;引用拦截由服务端前置检查判定)" : `${MISSING}:未取到客户名称`} onClick={() => { setDeleteId(item.id); setDeleteName(""); }}><Trash2 size={14} />删除</button>}</div></td>
         </tr>;
       })}{!filtered.length && directory.loading && <OpsTableEmpty colSpan={8}>客户档案加载中…</OpsTableEmpty>}{!filtered.length && !directory.loading && <OpsTableEmpty colSpan={8}>{listFailed ? "客户档案取数失败。" : hasFilters ? "没有符合筛选条件的数据" : "暂无数据"}</OpsTableEmpty>}</tbody></table></div>
       <ListPager total={filtered.length} page={safePage} pageSize={LIST_PAGE_SIZE} onPageChange={setPage} unit="家" />

+ 31 - 10
web-scaffold/src/pages/CustomerWorkspacePage.tsx

@@ -403,6 +403,17 @@ export function CustomerWorkspacePage() {
    * - 失败保留输入态与草稿,错误行内呈现,可改后重试或取消;
    * - 成功后退出编辑并重读详情与变更历史。
    */
+  /** 详情口下发的乐观锁版本;行内 `customer/update` 必须原样带回(D-12/R-2)。 */
+  const rowVersion = (() => {
+    const raw = customer?.row_version as number | string | null | undefined;
+    if (typeof raw === "number" && Number.isFinite(raw)) return raw;
+    if (typeof raw === "string" && raw.trim() !== "") {
+      const n = Number(raw);
+      return Number.isFinite(n) ? n : undefined;
+    }
+    return undefined;
+  })();
+
   async function commitField(key: keyof ProfileDraft) {
     if (!no || !draft || !baseline || busy) return;
     const current = draft;
@@ -418,27 +429,32 @@ export function CustomerWorkspacePage() {
     if (key === "idNo" && !/^[A-Z0-9]{18}$|^\d{15}$/.test(idNo)) { setFieldError({ key, message: "识别号格式不符:应为 18 位统一社会信用代码/组织代码,或 15 位旧营业执照号" }); return; }
     // 值没变:不写接口、不留痕,直接退出编辑。
     if (sameAsBaseline(key, current)) { setEditingField(null); setFieldError(null); setIdBasis(""); return; }
+    const needsRowVersion = key === "name" || key === "subject" || key === "idNo" || key === "contact" || key === "phone" || key === "address" || key === "teamId";
+    if (needsRowVersion && rowVersion === undefined) {
+      setFieldError({ key, message: "详情未下发 row_version,无法带版本提交;请刷新页面后重试。" });
+      return;
+    }
     setBusy(true);
     setFieldError(null);
     try {
       switch (key) {
         case "name":
-          await customerUpdate({ customer_id: no, customer_name: current.name.trim() });
+          await customerUpdate({ customer_id: no, customer_name: current.name.trim(), row_version: rowVersion });
           break;
         case "subject":
-          await customerUpdate({ customer_id: no, subject_type: current.subject });
+          await customerUpdate({ customer_id: no, subject_type: current.subject, row_version: rowVersion });
           break;
         case "idNo":
-          await customerUpdate({ customer_id: no, id_code: idNo, ...(idBasis.trim() ? { change_basis: idBasis.trim() } : {}) });
+          await customerUpdate({ customer_id: no, id_code: idNo, row_version: rowVersion, ...(idBasis.trim() ? { change_basis: idBasis.trim() } : {}) });
           break;
         case "contact":
-          await customerUpdate({ customer_id: no, contact_name: current.contact.trim() });
+          await customerUpdate({ customer_id: no, contact_name: current.contact.trim(), row_version: rowVersion });
           break;
         case "phone":
-          await customerUpdate({ customer_id: no, contact_mobile: current.phone.trim() });
+          await customerUpdate({ customer_id: no, contact_mobile: current.phone.trim(), row_version: rowVersion });
           break;
         case "address":
-          await customerUpdate({ customer_id: no, address: current.address.trim() });
+          await customerUpdate({ customer_id: no, address: current.address.trim(), row_version: rowVersion });
           break;
         case "operatorId":
         case "partnerId":
@@ -449,7 +465,7 @@ export function CustomerWorkspacePage() {
           await customerMoveRegion({ customer_id: no, new_region_node_id: current.regionId });
           break;
         case "teamId":
-          await customerUpdate({ customer_id: no, ops_team_ids: [current.teamId] });
+          await customerUpdate({ customer_id: no, ops_team_ids: [current.teamId], row_version: rowVersion });
           break;
       }
       invalidateCustomerList();
@@ -460,7 +476,8 @@ export function CustomerWorkspacePage() {
       setEditingField(null);
       setIdBasis("");
       setNotice("该项修改已保存,变更记录已写入历史。");
-      detail.reload();
+      // 成功后重读详情拿新 row_version,⛔ 同页二次提交旧版本。
+      await detail.reloadAsync();
       changes.reload();
     } catch (e) {
       setFieldError({ key, message: (e as ApiError)?.message || "保存失败,请稍后重试。" });
@@ -505,13 +522,17 @@ export function CustomerWorkspacePage() {
    */
   async function replaceLicense(file: File | null) {
     if (!file || !no) return;
+    if (rowVersion === undefined) {
+      setLicenseError("详情未下发 row_version,无法带版本提交;请刷新页面后重试。");
+      return;
+    }
     setLicenseError("");
     setLicenseBusy(true);
     try {
       const uploaded = await uploadCustomerLicense(file);
-      await customerUpdate({ customer_id: no, license: uploaded });
+      await customerUpdate({ customer_id: no, license: uploaded, row_version: rowVersion });
       invalidateCustomerList();
-      detail.reload();
+      await detail.reloadAsync();
     } catch (e) {
       setLicenseError((e as ApiError)?.message || "影像上传失败。");
     } finally {