feat: 累积功能变更 — 聊天集成、租户管理、小程序更新、ETL 增强、迁移脚本

包含多个会话的累积代码变更:
- backend: AI 聊天服务、触发器调度、认证增强、WebSocket、调度器最小间隔
- admin-web: ETL 状态页、任务管理、调度配置、登录优化
- miniprogram: 看板页面、聊天集成、UI 组件、导航更新
- etl: DWS 新任务(finance_area_daily/board_cache)、连接器增强
- tenant-admin: 项目初始化
- db: 19 个迁移脚本(etl_feiqiu 11 + zqyy_app 8)
- packages/shared: 枚举和工具函数更新
- tools: 数据库工具、报表生成、健康检查
- docs: PRD/架构/部署/合约文档更新

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Neo
2026-04-06 00:03:48 +08:00
parent 70324d8542
commit 6f8f12314f
515 changed files with 76604 additions and 7456 deletions

View File

@@ -0,0 +1,63 @@
# 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``<text wx:if="{{isCurrentMonth}}" class="estimate-tag">预估</text>`
- 收入标签:`{{isCurrentMonth ? '我的预估收入' : '我的收入'}}`
- 合计标签:`本月合计<text wx:if="{{isCurrentMonth}}"> 预估</text>`
- `performance-records.wxml`:统计概览中 `<text class="stat-hint" wx:if="{{isCurrentMonth}}">预估</text>`
### 证据
```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
<!-- performance.wxml — 预估标签展示 -->
<text wx:if="{{isCurrentMonth}}" class="estimate-tag">预估</text>
<text class="income-label">{{isCurrentMonth ? '我的预估收入' : '我的收入'}}</text>
```
### 建议
1. **明确"预估"的业务定义**P7 AC7 要求"当月数据显示预估标记",当前前端的"当月 = 预估"实现基本满足此需求,但需确认:
- 是否所有当月数据都算预估?还是仅未结算的记录?
- 月末 ETL 完成最终计算后,当月数据是否仍标记为预估?
2. **后端应提供 `is_estimate` 字段**:即使当前逻辑是"当月 = 预估",也应由后端返回此标记,避免前后端判断逻辑不一致
3. **单条记录级别的预估标记**`is_estimate` 字段已在 `xcx_tasks.py``xcx_customers.py` 的 schema 中定义,但在绩效 schema 中缺失