From 5298f8f58e6d4b32edddbf62c3a6d58d63e2a7b1 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 28 May 2026 17:58:33 +0800 Subject: [PATCH] feat: return expiry/balance based on billing type on login - Return expiry_at for subscription mode - Return balance for usage-based mode - Return is_permanent for permanent members Co-Authored-By: Claude Opus 4.7 --- backend/internal/router/app/auth.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/backend/internal/router/app/auth.go b/backend/internal/router/app/auth.go index 68b568c..fcc5d67 100644 --- a/backend/internal/router/app/auth.go +++ b/backend/internal/router/app/auth.go @@ -694,10 +694,27 @@ func handleAppLogin(c *gin.Context) { service.LogVerification(c, &appModel.ID, &user.ID, "login", "用户登录: "+req.Username, req.DeviceID, nil) - response.SuccessWithMessage(c, "登录成功", gin.H{ + // 根据运营模式返回不同参数 + loginData := gin.H{ "user_id": user.ID, "token": token, - }) + } + + // 永久会员返回永久标识 + if user.Balance == -1 { + loginData["is_permanent"] = true + } else if appModel.BillingType == "subscription" { + // 订阅模式返回到期时间 + if user.ExpiryAt != nil { + loginData["expiry_at"] = user.ExpiryAt.Format("2006-01-02 15:04:05") + loginData["expiry_timestamp"] = user.ExpiryAt.Unix() + } + } else if appModel.BillingType != "free" { + // 次数/余额模式返回余额 + loginData["balance"] = user.Balance + } + + response.SuccessWithMessage(c, "登录成功", loginData) } func checkFreePeriod(app *model.Application) bool {