fix: 心跳接口根据运营模式返回不同信息
- 订阅模式返回到期时间 expiry_at - 余额模式返回余额 balance - 永久会员返回 is_permanent 标识 - 免费模式只返回成功消息 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -203,8 +203,24 @@ func handleAppHeartbeat(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
response.SuccessWithMessage(c, "心跳成功", gin.H{
|
// 根据运营模式返回不同参数
|
||||||
|
heartbeatData := gin.H{
|
||||||
"message": "心跳成功",
|
"message": "心跳成功",
|
||||||
"balance": user.Balance,
|
}
|
||||||
})
|
|
||||||
|
// 永久会员返回永久标识
|
||||||
|
if user.Balance == -1 {
|
||||||
|
heartbeatData["is_permanent"] = true
|
||||||
|
} else if app.BillingType == "subscription" {
|
||||||
|
// 订阅模式返回到期时间
|
||||||
|
if user.ExpiryAt != nil {
|
||||||
|
heartbeatData["expiry_at"] = user.ExpiryAt.Format("2006-01-02 15:04:05")
|
||||||
|
heartbeatData["expiry_timestamp"] = user.ExpiryAt.Unix()
|
||||||
|
}
|
||||||
|
} else if app.BillingType != "free" {
|
||||||
|
// 余额模式返回余额
|
||||||
|
heartbeatData["balance"] = user.Balance
|
||||||
|
}
|
||||||
|
|
||||||
|
response.SuccessWithMessage(c, "心跳成功", heartbeatData)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user