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,77 @@
# Feature Spec: 会员套餐 MembershipPlanOps · ECR-014
> Status: `Active`Loop continuous · Approved · coding)· Map: `§7` · Phase: `Ops-D`
> Parent: **WAVE0-FROZEN** · Predecessor: **ECR-013B Closed**
> ESS: `docs/ECR/ECR-014-membership-plan.md`
> Capability: `CommerceEntitlement` · BC: `Membership_Orders`
> 授权:`docs/WAVE0/LOOP_AUTHORIZATION.md`
---
## ESS 门禁
1. L2 · Loop continuous:契约齐 → 自动 Approve + coding
2. **不含** 真支付 · 兑换码 · Entitlement 矩阵 · ask_pack 价目表
---
## L0 Capability
| 字段 | 内容 |
|------|------|
| Capability ID | `CommerceEntitlement` |
| Purpose | 运营可配置成长会员套餐时长与标价(mock 履约仍用既有支付) |
| Why now | planDays/金额硬编码;013B 完成后进入 Commerce 配置面最小切片 |
| Non-goals | 真支付网关 · RedemptionCode · Entitlement 细权 · ask_pack |
---
## L1 Bounded Context
| Primary BC | `Membership_Orders` |
| owns | `MembershipPlan` |
| does_not_own | `UserStatus` · `Payment` 适配器 · `AdminRole` |
| allowed | `Admin_Auth_Audit.write_audit` |
| forbidden | 真支付 · UGC |
---
## L2 Domain
| Entity | 不变式 |
|--------|--------|
| `MembershipPlan` | `code` ∈ {month,quarter,year} 本切片冻结;`duration_days`>0`amount_cents`≥0`active` 布尔 |
---
## L3 API
| Method | Path | 权限 | 语义 |
|--------|------|------|------|
| GET | `/admin/membership-plans` | `admin.membership.plans.read` | 列表 |
| GET | `/admin/membership-plans/:code` | `admin.membership.plans.read` | 详情 |
| PUT | `/admin/membership-plans/:code` | `admin.membership.plans.write` | 更新 title/days/amount/active + AuditLog |
履约:`GrantMembership` / membership `CreateOrder` 读表(缺行回退旧硬编码)。
`contract_diff``docs/CONTRACT_DIFF/ECR-014.yaml`
---
## L4 AC
| ID | Then |
|----|------|
| AC-F-01 | GET plans 含 month/quarter/year |
| AC-F-02 | PUT month days/amount → GET 一致 |
| AC-F-03 | GrantMembership 使用表内 duration_days |
| AC-S-01 | 无 write 权限 PUT → 403 |
| AC-S-02 | 无 Admin → 401 |
| AC-P-01 | GET list P95 &lt; 500ms 本机 |
| AC-O-01 | PUT 成功 → AuditLog `membership.plans.update` |
---
## Implementation Notes
Migration `membership_plans` + RBAC additive permissions · admin-h5 最小列表编辑页