防止重复抽奖

This commit is contained in:
sk 2024-10-29 09:07:15 +08:00
parent 0333ef441e
commit 0a67496d50
1 changed files with 9 additions and 0 deletions

View File

@ -53,6 +53,7 @@ func init() {
// LotteryData 抽奖数据 // LotteryData 抽奖数据
type LotteryData struct { type LotteryData struct {
*model.LotteryData *model.LotteryData
isDone bool // 抽奖中
} }
// Reset 重置抽奖数据 // Reset 重置抽奖数据
@ -287,6 +288,11 @@ func (l *LotteryData) Done() {
value, tp, index, l.RobotIndex, l.Code, l.PlayerIndex, l.CId) value, tp, index, l.RobotIndex, l.Code, l.PlayerIndex, l.CId)
} }
if l.isDone {
return
}
l.isDone = true
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
// 查询参与人数 // 查询参与人数
joinNum, err = model.GetLotteryCodeJoinNum(l.Platform, l.CId, l.StartTs) joinNum, err = model.GetLotteryCodeJoinNum(l.Platform, l.CId, l.StartTs)
@ -333,6 +339,9 @@ func (l *LotteryData) Done() {
} }
return nil return nil
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) { }), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
defer func() {
l.isDone = false
}()
if code == nil && isMust { if code == nil && isMust {
code = &model.LotteryCode{ code = &model.LotteryCode{
Platform: l.Platform, Platform: l.Platform,