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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user