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:
@@ -0,0 +1,3 @@
|
||||
DELETE FROM admin_role_permissions
|
||||
WHERE code IN ('admin.membership.plans.read', 'admin.membership.plans.write');
|
||||
DROP TABLE IF EXISTS membership_plans;
|
||||
@@ -0,0 +1,27 @@
|
||||
-- ECR-014 MembershipPlan
|
||||
|
||||
CREATE TABLE IF NOT EXISTS membership_plans (
|
||||
code varchar(32) PRIMARY KEY,
|
||||
title varchar(64) NOT NULL,
|
||||
duration_days int NOT NULL CHECK (duration_days > 0),
|
||||
amount_cents int NOT NULL CHECK (amount_cents >= 0),
|
||||
active boolean NOT NULL DEFAULT true,
|
||||
updated_at timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
INSERT INTO membership_plans(code, title, duration_days, amount_cents, active)
|
||||
VALUES
|
||||
('month', '月卡', 31, 2500, true),
|
||||
('quarter', '季卡', 92, 6800, true),
|
||||
('year', '年卡', 366, 19800, true)
|
||||
ON CONFLICT (code) DO NOTHING;
|
||||
|
||||
INSERT INTO admin_role_permissions(role_id, code)
|
||||
SELECT r.id, p.code
|
||||
FROM admin_roles r
|
||||
CROSS JOIN (VALUES
|
||||
('admin.membership.plans.read'),
|
||||
('admin.membership.plans.write')
|
||||
) AS p(code)
|
||||
WHERE r.name = 'super_admin'
|
||||
ON CONFLICT DO NOTHING;
|
||||
Reference in New Issue
Block a user