Compare commits

..

No commits in common. "6a9c97c77c8e79723a1726db0d0ded6356e8caa9" and "a10ff0ecc778ade57b2ebee3ac83dab02c804f92" have entirely different histories.

3 changed files with 11 additions and 17 deletions

View File

@ -41,6 +41,8 @@ func init() {
if err = svc.InsertLotteryLogs(log.Platform, log); err != nil {
logger.Logger.Errorf("InsertLotteryLogs error: %v", err)
}
mq.Write(&model.LotteryLog{Platform: log.Platform}, mq.RankLotteryLog)
return
},
})

View File

@ -69,8 +69,7 @@ func GetLotteryLogs(plt string, count int) (ret []*model.LotteryLog, err error)
if clog == nil {
return nil, LotteryLogDBErr
}
now := time.Now().Unix()
err = clog.Find(bson.M{"ts": bson.M{"$lt": now}}).Sort("-ts").Limit(count).All(&ret)
err = clog.Find(bson.M{"ts": bson.M{"$lt": time.Now().Unix()}}).Sort("-ts").Limit(count).All(&ret)
if err != nil && !errors.Is(err, mgo.ErrNotFound) {
return nil, err
}

View File

@ -104,7 +104,6 @@ func (l *LotteryData) Reset() {
l.CostCard = 0
l.RobotCodeCount = 0
l.PlayerNum = 0
logger.Logger.Tracef("LotteryData Reset: %v", l.CId)
}
// GetCode 获取抽奖码
@ -144,8 +143,8 @@ func (l *LotteryData) GetRemainCode() int {
}
// 发奖
func (l *LotteryData) sendAward(must bool) {
if l.isDone || !must {
func (l *LotteryData) sendAward() {
if l.isDone {
return
}
@ -154,7 +153,6 @@ func (l *LotteryData) sendAward(must bool) {
return
}
l.IsSend = true
mq.Write(&model.LotteryLog{Platform: l.Platform}, mq.RankLotteryLog)
var lotteryAward []*welfare.PropInfo
for _, v := range l.Reward {
@ -220,7 +218,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,12 +415,11 @@ 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)
l.sendAward()
}
})).StartByExecutor(fmt.Sprintf("LotterySendAward_%s_%d", l.Platform, l.CId))
}), "LotterySendAward").Start()
}
type LotteryConfig struct {
@ -467,9 +463,8 @@ func (l *LotteryMgr) Init() {
}
func (l *LotteryMgr) Update() {
for i := range l.Data {
for k := range l.Data[i] {
d := l.Data[i][k]
for _, v := range l.Data {
for _, d := range v {
if d == nil {
continue
}
@ -480,11 +475,9 @@ 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)
d.sendAward()
}
}
}