feat:增加用户资产和会员状态

This commit is contained in:
henry
2021-12-10 11:34:19 +08:00
parent 626f30a2bd
commit 2ee564d540
13 changed files with 188 additions and 31 deletions

View File

@ -3,18 +3,22 @@ package session
import (
"SciencesServer/utils"
"encoding/json"
"time"
)
// Enterprise 企业用户
type Enterprise struct {
Token string `json:"token"` // token
UID uint64 `json:"uid"` // 唯一标识ID
IdentityUID uint64 `json:"identity_uid"` // 用户身份唯一ID
Avatar string `json:"avatar"` // 头像
Name string `json:"name"` // 名称
Mobile string `json:"mobile"` // 手机号码
Identity int `json:"identity"` // 总身份信息
SelectIdentity int `json:"select_identity"` // 选中身份信息
Token string `json:"token"` // token
UID uint64 `json:"uid"` // 唯一标识ID
IdentityUID uint64 `json:"identity_uid"` // 用户身份唯一ID
Avatar string `json:"avatar"` // 头像
Name string `json:"name"` // 名称
Mobile string `json:"mobile"` // 手机号码
Vip bool `json:"vip"` // VIP状态
VipDeadline time.Time `json:"vip_deadline"` // VIP过期时间
Currency float64 `json:"currency"` // 货币-创新币
Identity int `json:"identity"` // 总身份信息
SelectIdentity int `json:"select_identity"` // 选中身份信息
}
func (this *Enterprise) SetToken(token string) {
@ -29,6 +33,10 @@ func (this *Enterprise) UIDToString() string {
return utils.UintToString(this.UID)
}
func (this *Enterprise) VipStatus() bool {
return this.Vip && this.VipDeadline.After(time.Now())
}
func (this *Enterprise) MarshalBinary() ([]byte, error) {
return json.Marshal(this)
}