From 47056792ebbf95fde4ac8e555df0bdd139abe736 Mon Sep 17 00:00:00 2001 From: zhangshy <994452054@qq.com> Date: Fri, 11 Sep 2026 11:24:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=84=E8=8C=83=E9=A2=84=E8=AD=A6?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=AE=A2=E6=88=B7=E7=BC=96=E5=8F=B7=E6=98=A0?= =?UTF-8?q?=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/repository/risk_repository.py | 14 +++++++++++--- docs/风控业务演示文档/06-模块接口与字段映射.md | 10 ++++++++++ docs/风控业务演示文档/11-证据来源与脱敏说明.md | 3 ++- tests/unit/repository/test_risk_repository.py | 2 ++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/repository/risk_repository.py b/app/repository/risk_repository.py index 7fd91dd..9d3e269 100644 --- a/app/repository/risk_repository.py +++ b/app/repository/risk_repository.py @@ -277,7 +277,10 @@ class RiskRepository: profile.real_name if profile else None, product.product_code if product else None, product.product_name if product else None), - "customer": self._profile_row(profile), + "customer": self._profile_row( + profile, + customer.user_no if customer else None, + ), "transaction": self._model_values(transaction), "product": self._model_values(product), "work_order": self._model_values(work_order), @@ -964,11 +967,16 @@ class RiskRepository: } @staticmethod - def _profile_row(profile: FundCustomerProfile | None) -> dict[str, Any] | None: + def _profile_row( + profile: FundCustomerProfile | None, + customer_no: str | None = None, + ) -> dict[str, Any] | None: if profile is None: return None return { - "customer_id": str(profile.customer_id), + # 兼容既有前端字段名,但值必须是业务客户编号,不能暴露内部主键。 + "customer_id": customer_no, + "customer_no": customer_no, "name": mask_name(profile.real_name), "birth_date": profile.birth_date, "occupation": profile.occupation, diff --git a/docs/风控业务演示文档/06-模块接口与字段映射.md b/docs/风控业务演示文档/06-模块接口与字段映射.md index 70cdfa7..f0039b0 100644 --- a/docs/风控业务演示文档/06-模块接口与字段映射.md +++ b/docs/风控业务演示文档/06-模块接口与字段映射.md @@ -103,3 +103,13 @@ | `disposition_hint` | 列表级只读研判提示 | | `disposition_assessment` | 详情级只读研判草案 | +## 预警详情客户对象 + +预警详情中的客户对象不使用内部数据库主键: + +| 字段 | 含义 | +|---|---| +| `customer_no` | 业务客户编号,来源 `sys_user.user_no` | +| `customer_id` | 兼容字段,值与 `customer_no` 相同,仅供既有前端继续使用 | + +内部 `fin_customer_profile.customer_id` 和 `sys_user.id` 不向预警详情接口暴露。 diff --git a/docs/风控业务演示文档/11-证据来源与脱敏说明.md b/docs/风控业务演示文档/11-证据来源与脱敏说明.md index 582e609..a8d64d4 100644 --- a/docs/风控业务演示文档/11-证据来源与脱敏说明.md +++ b/docs/风控业务演示文档/11-证据来源与脱敏说明.md @@ -32,6 +32,8 @@ - 证据快照。 - 只读研判草案。 +客户编号统一使用 `sys_user.user_no`。内部 `sys_user.id` 和 `fin_customer_profile.customer_id` 只能用于服务端关联,不能作为预警详情的客户编号展示。 + ## 证据快照 `fin_risk_alert.evidence_snapshot` 保存: @@ -60,4 +62,3 @@ - 不修改预警业务状态。 - 不把部分文件信息写入证据快照。 - 返回明确错误供人工处理。 - diff --git a/tests/unit/repository/test_risk_repository.py b/tests/unit/repository/test_risk_repository.py index f18bf79..0aa652b 100644 --- a/tests/unit/repository/test_risk_repository.py +++ b/tests/unit/repository/test_risk_repository.py @@ -237,6 +237,8 @@ async def test_alert_detail_returns_immutable_snapshot() -> None: assert record is not None assert record["alert"]["customer_name"] == "张*" assert record["customer"]["name"] == "张*" + assert record["customer"]["customer_id"] == "CUST-009" + assert record["customer"]["customer_no"] == "CUST-009" assert record["transaction"]["transaction_no"] == "TX-010" assert record["product"]["product_code"] == "P-R5"