Files
suixinkan_ios_uikit/suixinkan_ios/Features/Statistics/Statistics.md
汉秋 d99a5b1bf8 Advance UIKit rewrite with AMap integration and core UI modules.
Integrate高德 SDK with simulator-safe build flags, add map views for operating area and punch points, refactor main tabs and key feature screens to UIKit with Diffable lists, and document Swift concurrency defaults in AGENTS.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 15:16:12 +08:00

33 lines
1.8 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.

# Statistics 模块业务逻辑
## 模块职责
Statistics 模块负责登录后的数据 Tab展示当前景区下的订单统计看板。
当前同步旧工程数据页的主要能力:时间段切换、统计汇总卡、每日明细、分页加载和下拉刷新。
## 核心对象
- `StatisticsViewController`:数据 Tab 根页面,使用 `UICollectionView` + Diffable Data Source 展示多 section 看板。
- `StatisticsViewModel`:管理时间段、汇总数据、每日明细、分页状态和加载状态。
- `StatisticsAPI`:封装摄影师和景区管理员两套统计接口。
- `StatisticsPeriod`表示今日、昨日、7日、本月四个快捷时间段。
## 数据流程
页面从 `AccountContext.currentScenic` 获取当前景区 ID。缺少景区时显示空状态不请求接口。
切换时间段时同时请求汇总接口和第一页日数据接口。汇总接口使用 `range` 参数,日数据接口使用 `start_time``end_time``page``page_size`
`roleId == 53` 时使用景区管理员接口,其他角色使用摄影师接口。日数据响应使用 `DataListPayload` 解码,兼容后端返回 `data``list` 字段。
## 分页规则
每日明细第一页随刷新或时间段切换加载。列表滚动到底部后,如果当前数量小于 total则继续加载下一页。加载更多失败时保留已有数据和当前页状态。
## 列表实现
- Section`empty`(无景区)、`period`(周期切换)、`summary`(汇总卡)、`daily`(每日明细,带 section 头「每日明细」)
- 使用 `UICollectionViewDiffableDataSource` + `NSDiffableDataSourceSnapshot` 驱动刷新,分页追加时保留插入动画
- 布局复用 `CollectionDiffableLayout` 全宽 section最后一项日明细 `willDisplay` 时触发 `loadMore`