抽奖活动日志

This commit is contained in:
sk 2024-10-30 16:22:37 +08:00
parent 6a9c97c77c
commit 3e02f7ba03
1 changed files with 12 additions and 14 deletions

View File

@ -29,7 +29,7 @@ var LotteryMgrInst = &LotteryMgr{
}
func init() {
module.RegisteModule(LotteryMgrInst, time.Minute, 0)
module.RegisteModule(LotteryMgrInst, time.Second*10, 0)
common.RegisterClockFunc(&common.ClockFunc{
OnDayTimerFunc: func() {
for _, v := range LotteryMgrInst.PlatformConfig {
@ -145,8 +145,10 @@ func (l *LotteryData) GetRemainCode() int {
// 发奖
func (l *LotteryData) sendAward(must bool) {
if l.isDone || !must {
return
if !must {
if l.isDone {
return
}
}
now := time.Now()
@ -180,7 +182,7 @@ func (l *LotteryData) sendAward(must bool) {
// 广播中奖结果
PlayerMgrSington.BroadcastMessageToPlatform(l.Platform, int(welfare.SPacketID_PACKET_NotifyLotteryAward), pack)
logger.Logger.Tracef("NotifyLotteryAward: %v", pack)
logger.Logger.Tracef("广播中奖信息: %v", pack)
if l.IsRobot {
return
@ -220,7 +222,6 @@ func (l *LotteryData) Done() {
return
}
l.isDone = true
logger.Logger.Tracef("LotteryData Done1: cid:%v wincode:%v snid:%v", l.CId, l.WinCode, l.SnId)
now := time.Now()
if l.EndTs <= 0 || l.EndTs >= now.Unix() || l.SnId > 0 || now.Unix()-l.EndTs > 5*60 {
@ -418,8 +419,7 @@ func (l *LotteryData) Done() {
Ts: l.WinTs,
}
mq.Write(lotteryLog)
logger.Logger.Tracef("LotteryData 抽奖中奖记录: %+v %p", *lotteryLog, l)
logger.Logger.Tracef("LotteryData Done2: cid:%v wincode:%v snid:%v", l.CId, l.WinCode, l.SnId)
logger.Logger.Tracef("LotteryData 抽奖中奖记录: %v", lotteryLog)
// 开始发奖
l.sendAward(true)
}
@ -480,9 +480,7 @@ func (l *LotteryMgr) Update() {
// 随机给机器人发放抽奖码
d.sendRobotCode(1, 5)
// 活动结束,开始抽奖
logger.Logger.Tracef("Done1 cid:%v wincode:%v %p", d.CId, d.WinCode, d)
d.Done()
logger.Logger.Tracef("Done2 cid:%v wincode:%v %p", d.CId, d.WinCode, d)
// 开始发奖
d.sendAward(false)
}
@ -546,7 +544,7 @@ func (l *LotteryMgr) UpdateConfig(conf *webapi.LotteryConfig) {
v.TotalCode = 1
}
data := l.GetData(conf.GetPlatform(), v.GetId())
if data.EndTs > 0 && (data.EndTs < now.Unix() || data.StartTs <= now.Unix()) {
if data.EndTs > 0 && (data.WinTs <= now.Unix() || data.StartTs <= now.Unix()) {
continue
} else {
data.Reset()
@ -658,10 +656,10 @@ func (l *LotteryMgr) GetList(plt string) []*welfare.LotteryInfo {
if d.WinTs > 0 && d.WinTs > now.Unix() {
// 隐藏未发奖的中奖信息
d.WinCode = ""
d.SnId = 0
d.Name = ""
d.RoleId = 0
info.WinCode = ""
info.SnId = 0
info.Name = ""
info.RoleId = 0
}
ret = append(ret, info)