mh_server/model/analyse.go

60 lines
1.6 KiB
Go
Raw Normal View History

2022-06-29 08:03:50 +00:00
package model
2022-07-12 13:20:57 +00:00
import (
"github.com/codinl/go-logger"
"time"
)
//go:generate goqueryset -in analyse.go
2022-06-29 08:03:50 +00:00
type Statistic struct {
Model
Count uint32 `json:"count"` // 计数
Type uint32 `json:"type" gorm:"index"` // 类型:1-
2022-07-12 13:20:57 +00:00
}
const (
UserRenewalLogActionPop = 1 // 弹窗
UserRenewalLogActionEnterActivity = 2 // 进入活动
UserRenewalLogActionPickGold = 3 // 领取黄金会员
UserRenewalLogActionPickPlatinum = 4 // 领取白金会员
UserRenewalLogActionPickBlackGold = 5 // 领取黑金会员
UserRenewalLogActionUseGold = 6 // 使用黄金会员
UserRenewalLogActionUsePlatinum = 7 // 使用白金会员
UserRenewalLogActionUseBlackGold = 8 // 使用黑金会员
)
// gen:qs
type UserRenewalLog struct {
Model
Uid uint32 `json:"uid"`
Action uint32 `json:"action"`
MemberExpire time.Time `json:"member_expire"`
Type uint32 `json:"type"` // 类型:1-续费 2-升级
RenewalNum uint32 `json:"renewal_num"`
Serial uint32 `json:"serial"`
// user_renewal_log
}
func (l *UserRenewalLog) Add() error {
err := DB.Create(l).Error
if err != nil {
logger.Error("user log add err:", err)
return err
}
return nil
}
func GetActionUserRenewalLog(uid, action uint32) (UserRenewalLog, error) {
var userRenewalLog UserRenewalLog
err := NewUserRenewalLogQuerySet(DB).UidEq(uid).ActionEq(action).OrderDescByID().Limit(1).One(&userRenewalLog)
if err != nil && err != RecordNotFound {
logger.Error("user renewal log err:", err)
return userRenewalLog, err
}
return userRenewalLog, nil
2022-06-29 08:03:50 +00:00
}