Files
wx_service/docs/smoke/README.md
T
nepiedg f80c3e8f45 Update algorithm and API documentation for smoking tracking app
- Enhanced the algorithm documentation to clarify the calculation of smoking intervals, including default values and edge cases.
- Updated API documentation to reflect changes in response formats, including the addition of `exceeded_yesterday` and adjustments to time formatting to RFC3339.
- Improved descriptions of user profile management and AI suggestions in the product documentation, ensuring consistency across all related files.
- Removed outdated sequence diagram and UI documentation files to streamline project resources.
2026-01-25 08:51:25 +00:00

66 lines
2.9 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.
# 戒烟/抽烟记录小程序
本小程序用于记录抽烟情况(日期、原因、烟瘾程度、数量等)。
## 产品与流程文档
- 产品说明(PRD):`docs/smoke/PRODUCT.md`
- 算法与 AI 策略:`docs/smoke/ALGORITHM.md`
## 依赖
- 公共登录与认证:`docs/common/auth.md`
- 通用响应结构:`docs/common/response.md`
## 数据表
主表:`fa_smoke_log`DDL 见:`docs/sql/smoke.sql`)。
说明:
- 该表使用旧系统字段:`createtime/updatetime/deletetime`(秒级时间戳),并非 GORM 默认的 `created_at/updated_at/deleted_at`
- 接口层通过 Token 识别用户,`uid` 由后端从登录用户推导,不允许前端传入。
### 用户基础信息(首次进入补全)
用于建立“初始基准/个性化策略”的用户信息表:
- `fa_smoke_user_profile`DDL 见:`docs/sql/smoke.sql`
典型字段:
- 日均抽烟支数、烟龄、单包价格
- 抽烟动机、戒烟动力
- 起床/入睡时间(用于规避睡眠时间)
### 真实抽烟时间(推荐使用 `smoke_at`
为支持“按时间节点分析”(例如:昨天哪些时段更容易想抽),建议在 `fa_smoke_log` 中新增:
- `smoke_at`:真实抽烟时间(精确到时分秒,可补录)
数据约定建议:
- 前端若提供了真实时间:写入 `smoke_at`;并同步写 `smoke_time = date(smoke_at)`,方便沿用现有按天筛选。
- 前端未提供真实时间:`smoke_at=NULL`,时间节点可用 `createtime` 作为近似(但补录会造成偏差)。
### AI 戒烟建议(会员 + 广告解锁并行)
面向会员用户提供“昨日 AI 建议”;非会员用户在完成当日/指定日期的“看广告解锁”后也可生成建议。
涉及表(DDL 见:`docs/sql/smoke.sql`):
- `fa_smoke_ai_advice`:按 `uid + advice_date + prompt_version` 缓存建议结果,避免重复调用 AI。
- `fa_smoke_ai_advice_unlocks`:非会员用户的“每日解锁”记录(按 `uid + unlock_date` 唯一)。
- `fa_smoke_ai_next_smoke`:保存“AI 下次抽烟时间节点”(每个时间点一条记录),AI 元信息复用 `fa_smoke_ai_advice``type=next_smoke_time`)。
建议的权限判断顺序:
1) 若用户是会员:直接允许生成/获取建议。
2) 否则:查询 `fa_smoke_ai_advice_unlocks` 是否已对 `unlock_date=昨天(或请求 date` 解锁;已解锁则允许。
3) 否则:拒绝并提示“开通会员或观看广告解锁”。
会员判断建议使用通用会员表:
- `user_memberships`DDL 见:`docs/sql/users.sql`
无支付系统时,可用兑换码开通会员:
- API`docs/membership/API.md`
- DDL`docs/sql/membership.sql`
给 AI 的输入(最小必需)建议包含:
- 昨日总量:`SUM(num)`
- 时间节点列表:按 `COALESCE(smoke_at, FROM_UNIXTIME(createtime))` 排序的多条记录(每条带 `num/level/remark`