feat(ECR-014): MembershipPlan 套餐配置并 Closed

membership_plans 表、admin 套餐页、Grant/CreateOrder 读表;
Loop continuous 自动 Approve/Closed。Next:ECR-015 RedemptionCode。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-07 18:03:38 +08:00
co-authored by Cursor
parent e25cd94b0c
commit 882c01d81a
31 changed files with 887 additions and 27 deletions
@@ -0,0 +1,23 @@
# Backend Design: ECR-014 MembershipPlan
| ID | BD-2026-014 |
| ECR | ECR-014 |
| Status | Approved |
| Coding | AuthorizedLoop |
| Change Level | L2 |
| Risk | Low |
## Change Boundary
```text
Domain: MembershipPlan
App: admin + membership CreateOrder amount/days
Infra: migration + repo
API: /admin/membership-plans*
Migration: YES
Tests: integration
```
## Rollback
down migration;回退硬编码 planDays/amount
+18
View File
@@ -0,0 +1,18 @@
# CODE_REVIEW — ECR-014
**Verdict:** Approve → Closed
Date: 2026-08-07 · Loop continuous
## Checklist
- [x] Spec + BD Approved · migration 000017
- [x] Admin GET/PUT membership-plans · OpenAPI
- [x] Grant/CreateOrder 读表
- [x] TEST_REPORT AC 映射
- [x] 无真支付 · 兑换码 · ask_pack
```text
Decision: Approve → Closed
Next: ECR-015Commerce 兑换码或 UserIntelligence 薄切片)
```
+36
View File
@@ -0,0 +1,36 @@
ecr: ECR-014
capability: CommerceEntitlement
bounded_context: Membership_Orders
parent: WAVE0-FROZEN
predecessor: ECR-013B
change:
type: additive
breaking_change: false
migration_required: true
compatibility_notes: >
New membership_plans table seeded with month/quarter/year.
Grant/CreateOrder read duration/amount from table with hardcoded fallback.
Additive RBAC permissions.
entities:
- name: MembershipPlan
before: null
after:
fields: [code, title, duration_days, amount_cents, active, updated_at]
codes: [month, quarter, year]
apis:
- method: GET
path: /api/v1/admin/membership-plans
change: added
- method: GET
path: /api/v1/admin/membership-plans/{code}
change: added
- method: PUT
path: /api/v1/admin/membership-plans/{code}
change: added
security_impact:
- "admin.membership.plans.read/write"
observability_impact:
- "AuditLog membership.plans.update"
+29
View File
@@ -0,0 +1,29 @@
# ECR-014
**Title:** MembershipPlan(会员套餐配置薄切片)
**Status:** **Closed**
**Closed:** 2026-08-07Loop continuous
**Parent:** WAVE0-FROZEN (`27f27a1`)
**Predecessor:** ECR-013B **Closed**
**Change Level: L2**
## Change
1. Spec `ops-membership-plan.md`
2. Entity `MembershipPlan` 表 + 种子 month/quarter/year
3. Admin GET/PUT `/membership-plans*`
4. Grant / CreateOrder(membership) 读表
5. `docs/CONTRACT_DIFF/ECR-014.yaml`
6. **不含** 真支付 · 兑换码 · Entitlement · ask_pack
## Scope Forbidden
UGC · 真支付 · soft-delete User · 新建 plan code(本切片冻结三码)
## Acceptance
见 Spec L4。
## Linked
- Spec / PRODUCT / ENGINEERING / BD-2026-014 / CONTRACT_DIFF / HANDOFF / STATE / TASK
@@ -0,0 +1,15 @@
# ENGINEERING_SPEC — ECR-014 MembershipPlan
**Approved · codingLoop**
## Implement order
1. Migration `membership_plans` + permission 种子
2. Repo/service/admin handlers
3. Wire GrantMembership + membership CreateOrder
4. OpenAPI · admin-h5 最小页
5. Integration AC · TEST_REPORT · Closed
## Constraints
函数≤50 · 文件≤400 · 无真支付 · 无新 plan code
@@ -0,0 +1,6 @@
# HANDOFF — ECR-014 Architect → Engineer
**Loop continuous** · Approved + Coding authorized.
Consume Spec/BD/CONTRACT_DIFF。Do ENGINEERING_SPEC order。
Forbidden: 真支付 · 兑换码 · ask_pack · 新 plan code。
@@ -0,0 +1,4 @@
# HANDOFF — ECR-014 Engineer → Reviewer
Done: membership_plans · admin API/H5 · Grant/CreateOrder 读表 · TEST_REPORT.
Loop continuous → Reviewer Closed in same cycle.
@@ -0,0 +1,12 @@
# PRODUCT_SPEC — ECR-014 MembershipPlan
对齐 `.ai/product/feature-spec/ops-membership-plan.md`
Status: Approved · Loop continuous
| ECR | ECR-014 |
| Capability | CommerceEntitlement |
| BC | Membership_Orders |
| Change Level | L2 |
Outcome:运营可改会员套餐时长与标价;mock 履约读表。
Out:真支付 · 兑换码 · ask_pack。
+2 -2
View File
@@ -46,9 +46,9 @@
## Active anchors
- ECR: **ECR-014** MembershipPlanLoop continuous);**ECR-013B Closed****ECR-013A Closed****WAVE0-FROZEN** @ 27f27a1
- ECR: **ECR-014 Closed**Next **ECR-015** RedemptionCodeLoop continuous);013A/B Closed**ECR-013A Closed****WAVE0-FROZEN** @ 27f27a1
- EXP: (无)
- STATE: `docs/STATE/ECR-014.md` · Loop: `docs/WAVE0/LOOP_AUTHORIZATION.md`
- STATE: `docs/STATE/ECR-014.md`Closed)· next ECR-015 · Loop: `docs/WAVE0/LOOP_AUTHORIZATION.md`
- Ops foundation: `docs/WAVE0/` · `.ai/domain/boundary-rules.md` · `glossary.yaml`
- TRACEABILITY: `docs/TRACEABILITY.md`
- ADR: `.ai/adr/0007-ess-ai-dual-track.md`
+12
View File
@@ -0,0 +1,12 @@
# STATE — ECR-014
| Field | Value |
|-------|-------|
| ECR | ECR-014 |
| Status | **Closed** |
| Phase | closed |
| Parent | WAVE0-FROZEN |
| Predecessor | ECR-013B Closed |
| Test | TEST_REPORT/ECR-014.md |
| Review | CODE_REVIEW Approve → Closed |
| Updated | 2026-08-07 |
+13
View File
@@ -0,0 +1,13 @@
id: TASK-014-ECR014
ecr: ECR-014
title: MembershipPlan Closed
role: reviewer
status: closed
change_level: L2
parent: WAVE0-FROZEN
predecessor: ECR-013B
outputs:
- CODE_REVIEW Approve → Closed
acceptance:
- Spec AC mapped
- No true payment
+29
View File
@@ -0,0 +1,29 @@
# TEST_REPORT — ECR-014 MembershipPlan
Date: 2026-08-07 · Loop continuous
## Commands
```bash
cd apps/api && go test ./internal/integration/ -run TestMembershipPlans -count=1
npm run build:admin
```
## Results
| Check | Result |
|-------|--------|
| TestMembershipPlans | PASS |
| build:admin | PASS |
## AC
| ID | Evidence |
|----|----------|
| AC-F-01 | GET plans ≥3 codes |
| AC-F-02 | PUT month → GET 一致 |
| AC-F-03 | grant month 200(读表 duration |
| AC-S-01 | RequirePermission middleware(同 013A 模式) |
| AC-S-02 | 无 token → 401 |
| AC-P-01 | GET &lt; 500ms |
| AC-O-01 | AuditLog membership.plans.update |
+1 -1
View File
@@ -17,4 +17,4 @@
| ECR-012 | 星座对齐收口(星盘 · outlook · 合盘) | **Implemented** | Spec star-profile · BD-2026-012 · TEST_REPORT · HANDOFF review |
| WAVE-0 | Ops Contract-First Foundation | **FROZEN** (`WAVE0-FROZEN` @ 27f27a1) | `docs/WAVE0/` · HUMAN_REVIEW FREEZE · boundary-rules · glossary · contract template |
| ECR-013A | Admin RBAC | **Closed** | Spec ops-rbac · BD-2026-013A · migration 000015 · TEST_REPORT · CODE_REVIEW Approve · Parent WAVE0-FROZEN |
| ECR-013B | AccountLifecycle / UserStatus | **Closed** | Spec ops-account-lifecycle · BD-2026-013B · migration 000016 · TEST_REPORT · CODE_REVIEW Approve · Parent WAVE0-FROZEN |
| ECR-014 | MembershipPlan | **Closed** | Spec ops-membership-plan · BD-2026-014 · migration 000017 · TEST_REPORT · CODE_REVIEW · Loop continuous |