feat: 购油方案 — 会员请求+老师定制+购油清单
Some checks failed
Test / unit-test (push) Successful in 5s
Test / build-check (push) Failing after 4s
PR Preview / teardown-preview (pull_request) Has been skipped
Test / e2e-test (push) Failing after 3m5s
PR Preview / test (pull_request) Successful in 6s
PR Preview / deploy-preview (pull_request) Failing after 10s

后端:
- oil_plans/oil_plan_recipes 表
- 7个API: teachers列表、方案CRUD、配方增删、购油清单计算
- 购油清单自动算月消耗、瓶数、费用,交叉比对库存

前端:
- 会员端(库存页): 请求方案→选老师→描述需求;查看购油清单
- 老师端(用户管理): 接收请求→选配方+频率→激活方案
- plans store 管理状态

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-12 21:38:07 +00:00
parent e0ee1cba8c
commit 7ae2e73ee5
5 changed files with 608 additions and 2 deletions

View File

@@ -245,6 +245,24 @@ def init_db():
if "en_name" not in cols:
c.execute("ALTER TABLE recipes ADD COLUMN en_name TEXT DEFAULT ''")
# Oil plans
c.execute("""CREATE TABLE IF NOT EXISTS oil_plans (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL,
teacher_id INTEGER,
title TEXT DEFAULT '',
health_desc TEXT DEFAULT '',
status TEXT NOT NULL DEFAULT 'pending',
created_at TEXT DEFAULT (datetime('now'))
)""")
c.execute("""CREATE TABLE IF NOT EXISTS oil_plan_recipes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
plan_id INTEGER NOT NULL REFERENCES oil_plans(id) ON DELETE CASCADE,
recipe_name TEXT NOT NULL,
ingredients TEXT NOT NULL DEFAULT '[]',
times_per_month INTEGER NOT NULL DEFAULT 1
)""")
# Seed admin user if no users exist
count = c.execute("SELECT COUNT(*) FROM users").fetchone()[0]
if count == 0: