Repository navigation
feat(admin): product contract fields in plan drawer, price catalog page, template read API - #11
Merged
Merged
Conversation
…ge, template read API - add AdminListProductTemplates/AdminGetProductTemplate/AdminUpdateProductTemplate under /api/subscription/admin/templates; PUT only accepts display_name, display_metadata, min_margin_percent on unlocked templates, answers 403 for locked templates or contract-key field changes (migration path) - subscriptions plan drawer gains a Product Contract section: product_type (create-only select), product_code, model_scope multi-select filtered by the template scope, billing_multiplier, price_version, product_family, tier and the listed/redemption/course/fallback switches, with read-only template constraint hints (allowed prices, duration, multiplier, model scope) - new /product-prices admin page for the immutable versioned price catalog: list, add-version drawer, enable/disable toggle - sidebar admin group gains a Product Prices entry; i18n keys synced
Author
|
维护者评审通过(2026-10-21):
AI 辅助实现,维护者已核对。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
本 PR 为 AI 辅助生成(提交者非仓库历史核心开发者),描述已人工整理。
📝 变更描述 / Description
让管理员后台真正能管理商品契约,分三部分:
后端模板管理 API(
controller/product_template.go+router/api-router.go):在现有/api/subscription/admin组下新增GET /templates、GET /templates/:id、PUT /templates/:id。PUT 仅允许修改非 locked 模板的运营字段(display_name、display_metadata、min_margin_percent);locked 模板或任何契约关键字段(product_type、price_rules、billing_multiplier、duration_days、model_scope、allowed_channels、max_upstream_cost等)的变更返回 403 并提示走代码迁移流程。locked 拒绝复用model.UpdateProductTemplate的既有守卫;缓存失效由saveProductTemplate→InvalidateProductTemplateCache完成(控制器侧亦显式调用一次)。套餐抽屉补全(
web/src/features/subscriptions/):新增「商品契约」section——product_type(创建时从模板列表选择,编辑时只读)、product_code(创建可写、编辑只读)、model_scope(MultiSelect 多选,getEnabledModels()数据源,逗号分隔序列化)、billing_multiplier、price_version、product_family、product_tier,以及listed/redemption_enabled/course_eligible/fallback_allowed开关。选定 product_type 后展示模板只读约束提示(允许价格列表、固定时长、计费倍率、允许模型集合、限购数),并按模板model_scope过滤多选选项。redemption_enabled因 PUT 明确保留旧值(PATCH 为权威路径),编辑保存后通过PATCH /plans/:id单独同步。模板校验失败的服务端错误由 axios 拦截器 toast 展示。价格目录页(
web/src/features/product-prices/+ 路由/product-prices):版本化价格列表(product_type / model / price_version / 售价分量 / 生效时间 / 启用状态)、「新增版本」抽屉(四组价格分量 + 计费表达式 + 允许渠道)、启停确认对话框。价格行不可变(后端BeforeUpdate强制),UI 不提供编辑入口。侧边栏 admin 组登记Product Prices项及模块开关映射。模板管理页本阶段不做,抽屉内模板信息均走只读 API。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
📸 运行证明 / Proof of Work
GOWORK=off go build ./...、go vet ./controller ./model、go test ./controller -count=1全部通过(含新增product_template_test.go5 个用例:locked 403、关键字段 403、回声字段放行、display 字段更新、min_margin 越界拒绝)。bun run build、bun run typecheck、bun run test(51 个隔离测试文件全过,含新增 plan-form / template-hints / price-form 共 23 个用例)。