Files
qitongxue-api/internal/model/entity/entity_user_tool_quota.go
2026-09-17 17:38:45 +08:00

19 lines
860 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package entity
import "github.com/gogf/gf/v2/os/gtime"
// UserToolQuota 用户在某工具上的付费额度余额(次数包买断制,按工具绑定)。
//
// 一个用户对一个工具只有一行UNIQUE(user_id, tool_key)),重复购买同工具时
// 次数累加、有效期顺延base = max(now, 当前到期时间)expire = base + valid_days
type UserToolQuota struct {
Id int64 `json:"id"`
UserId int64 `json:"user_id"`
ToolKey string `json:"tool_key"`
TimesLeft int `json:"times_left"` // 剩余次数
TotalBought int `json:"total_bought"` // 累计购买次数(用于对账与展示)
ExpireAt *gtime.Time `json:"expire_at"` // 到期时间NULL 视为已过期
CreatedAt *gtime.Time `json:"created_at"`
UpdatedAt *gtime.Time `json:"updated_at"`
}