Files
ccdi/docs/reports/implementation/2026-03-18-lsfx-logid-primary-binding-implementation.md

50 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# LSFX Mock LogId 主体账号绑定实施记录
## 变更概述
-`lsfx-mock-server/services/file_service.py``FileRecord` 增加 `primary_enterprise_name``primary_account_no`,统一维护 `logId -> 主体/账号` 单一主绑定。
- 上传文件、拉取本行信息两条链路都改为创建并保存完整 `FileRecord`,后续上传状态查询优先读取真实记录,未命中时才回退到 deterministic 生成。
- `lsfx-mock-server/services/statement_service.py` 改为按 `logId``FileService` 读取主绑定,并将 `leName``accountMaskNo` 统一注入分页流水结果。
- `lsfx-mock-server/routers/api.py` 改为让 `statement_service``file_service` 共享同一份 `FileService` 实例,确保上传状态接口与查流水接口使用同一组绑定数据。
- 补齐 `tests/test_file_service.py``tests/test_statement_service.py``tests/test_api.py``tests/integration/test_full_workflow.py` 回归测试,并在 `tests/conftest.py` 增加单例状态重置夹具,避免测试串扰。
## 联动结果
- 上传文件:创建 `FileRecord` 时同时生成主绑定,并同步回填 `accountsOfLog``uploadLogList`
- 拉取本行信息:返回 `logId` 前即落库 `FileRecord`,后续 `bs/upload``getpendings``getBSByLogId` 都可复用同一主绑定。
- 上传状态:优先读取真实 `FileRecord`;只有当 `logId` 没有已存记录时,才走 deterministic fallback。
- 银行流水:优先从 `FileService` 读取 `primary_enterprise_name``primary_account_no`,统一写入每条流水的 `leName``accountMaskNo`
## 优先级说明
- `FileService.get_upload_status()`:真实 `FileRecord` 优先deterministic fallback 兜底。
- `StatementService` 主绑定解析:真实 `FileRecord` 优先,服务内 fallback 仅在记录不存在时生效。
- deterministic fallback 的时间字段、主体字段、账号字段都已改为基于 `logId` 的稳定生成,保证同一 `logId` 重复查询结果一致。
## 提交记录
- `0120d09` `收敛Mock文件记录主体账号绑定模型`
- `6fb7287` `让拉取本行信息链路复用Mock主体账号绑定`
- `0a85c09` `统一Mock上传状态主体账号绑定优先级`
- `5195617` `让Mock流水查询复用logId主体账号绑定`
## 验证记录
- `cd lsfx-mock-server && python3 -m pytest tests/test_file_service.py -v`
- `cd lsfx-mock-server && python3 -m pytest tests/test_statement_service.py -v`
- `cd lsfx-mock-server && python3 -m pytest tests/test_api.py -v`
- `cd lsfx-mock-server && python3 -m pytest tests/integration/test_full_workflow.py -v`
- `cd lsfx-mock-server && python3 verify_implementation.py`
## 验证结果
- `tests/test_file_service.py`3 个用例全部通过。
- `tests/test_statement_service.py`1 个用例通过。
- `tests/test_api.py`14 个用例全部通过。
- `tests/integration/test_full_workflow.py`4 个用例全部通过。
- `verify_implementation.py`:接口字段完整性与模板文件校验全部通过。
## 进程说明
- 本次验证仅运行 pytest 与 `verify_implementation.py`,未启动 `python main.py``uvicorn`,无需额外停止服务进程。