沿用订阅体系现成先例 MaxPurchasePerUser,给 SubscriptionPlan 加 MaxAgents: - model: SubscriptionPlan.MaxAgents(0=回退全局默认)+ GetUserMaxAgents(取用户 active 订阅档最高 MaxAgents,无则回退默认)。 - HeicodeDeployAgent: 部署上限改 model.GetUserMaxAgents(userID, 环境默认5)。 团队8=管理员把团队档配成8;个人5=默认;代码不硬编码 tier。 - subscription 控制器: Create/Update 校验 MaxAgents>=0;Update updateMap 补 max_agents。 - 前端管理端套餐表单(plan-form/types/drawer)加「Agent 部署上限」字段 + zh i18n。 测试 model/subscription_max_agents_test.go 全过(无订阅/团队档/0回退/过期/多档取最高/非法用户)。 go build、go vet、前端 tsc 干净。 Fixes #8 Co-authored-by: chenchen <chenchen@xinghanlab.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -140,6 +140,10 @@ func AdminCreateSubscriptionPlan(c *gin.Context) {
|
||||
common.ApiErrorMsg(c, "购买上限不能为负数")
|
||||
return
|
||||
}
|
||||
if req.Plan.MaxAgents < 0 {
|
||||
common.ApiErrorMsg(c, "Agent 部署上限不能为负数")
|
||||
return
|
||||
}
|
||||
if req.Plan.TotalAmount < 0 {
|
||||
common.ApiErrorMsg(c, "总额度不能为负数")
|
||||
return
|
||||
@@ -203,6 +207,10 @@ func AdminUpdateSubscriptionPlan(c *gin.Context) {
|
||||
common.ApiErrorMsg(c, "购买上限不能为负数")
|
||||
return
|
||||
}
|
||||
if req.Plan.MaxAgents < 0 {
|
||||
common.ApiErrorMsg(c, "Agent 部署上限不能为负数")
|
||||
return
|
||||
}
|
||||
if req.Plan.TotalAmount < 0 {
|
||||
common.ApiErrorMsg(c, "总额度不能为负数")
|
||||
return
|
||||
@@ -235,6 +243,7 @@ func AdminUpdateSubscriptionPlan(c *gin.Context) {
|
||||
"stripe_price_id": req.Plan.StripePriceId,
|
||||
"creem_product_id": req.Plan.CreemProductId,
|
||||
"max_purchase_per_user": req.Plan.MaxPurchasePerUser,
|
||||
"max_agents": req.Plan.MaxAgents,
|
||||
"total_amount": req.Plan.TotalAmount,
|
||||
"upgrade_group": req.Plan.UpgradeGroup,
|
||||
"quota_reset_period": req.Plan.QuotaResetPeriod,
|
||||
|
||||
Reference in New Issue
Block a user