fix: 规范预警详情客户编号映射
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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` 不向预警详情接口暴露。
|
||||
|
||||
@@ -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 @@
|
||||
- 不修改预警业务状态。
|
||||
- 不把部分文件信息写入证据快照。
|
||||
- 返回明确错误供人工处理。
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user