# P7→NS1/RNS1 缺失项 #2:"预估"标记的判断逻辑 ## 简要结论 - 状态:⚠️ 部分解决 - 风险等级:🟠 中 - 前端已实现"当月 = 预估"的判断逻辑并展示预估标签,但后端 `is_estimate` 字段硬编码为 `False`,未实现真正的预估判断。当前方案是纯前端判断(year/month == 当前年月),未考虑 ETL 数据更新延迟等场景。 ## 详细审查 ### 审查范围 - `apps/backend/app/services/fdw_queries.py` — `get_service_records()` 中 `is_estimate` 字段 - `apps/backend/app/schemas/xcx_performance.py` — PERF-1/PERF-2 响应 schema - `apps/miniprogram/miniprogram/pages/performance/performance.wxml` — 预估标签展示 - `apps/miniprogram/miniprogram/pages/performance/performance.ts` — `isCurrentMonth` 判断 - `apps/miniprogram/miniprogram/pages/performance-records/performance-records.wxml` — 预估标签展示 ### 发现 1. **后端 `is_estimate` 硬编码为 `False`**: - `fdw_queries.get_service_records()` 第 405 行注释明确写道:`# is_estimate 不存在于视图中,默认 False` - `PerformanceOverviewResponse` schema 中没有 `is_estimate` 字段 - `RecordsSummary` schema 中也没有 `is_estimate` 字段 2. **前端使用纯客户端判断**: - `performance.ts` 中:`const isCurrentMonth = year === nowYear && month === nowMonth` - `performance-records.ts` 中:同样的 `isCurrentMonth` 判断 - WXML 中根据 `isCurrentMonth` 展示"预估"标签和"我的预估收入"文案 3. **前端展示已到位**: - `performance.wxml`:`预估` - 收入标签:`{{isCurrentMonth ? '我的预估收入' : '我的收入'}}` - 合计标签:`本月合计 预估` - `performance-records.wxml`:统计概览中 `预估` ### 证据 ```python # fdw_queries.py — is_estimate 硬编码 records.append({ ... "income": float(row[10]) if row[10] is not None else 0.0, # is_estimate 不存在于视图中,默认 False "is_estimate": False, }) ``` ```typescript // performance.ts — 纯前端判断 const isCurrentMonth = year === nowYear && month === nowMonth ``` ```xml 预估 {{isCurrentMonth ? '我的预估收入' : '我的收入'}} ``` ### 建议 1. **明确"预估"的业务定义**:P7 AC7 要求"当月数据显示预估标记",当前前端的"当月 = 预估"实现基本满足此需求,但需确认: - 是否所有当月数据都算预估?还是仅未结算的记录? - 月末 ETL 完成最终计算后,当月数据是否仍标记为预估? 2. **后端应提供 `is_estimate` 字段**:即使当前逻辑是"当月 = 预估",也应由后端返回此标记,避免前后端判断逻辑不一致 3. **单条记录级别的预估标记**:`is_estimate` 字段已在 `xcx_tasks.py` 和 `xcx_customers.py` 的 schema 中定义,但在绩效 schema 中缺失