|
|
@ -43,6 +43,52 @@ func (t *LotteryDrawCtl) Start() { |
|
|
|
map[string]interface{}{ |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"desc": "开始抽奖", |
|
|
|
}) |
|
|
|
t.SUCCESS("操作成功") |
|
|
|
} |
|
|
|
|
|
|
|
// 滚动
|
|
|
|
func (t *LotteryDrawCtl) StartRoll() { |
|
|
|
ladderId := t.MustGetInt64("lottery_draw_ladder_id") |
|
|
|
activityId := t.MustGetInt64("activity_id") |
|
|
|
|
|
|
|
ladder := new(models.LotteryDrawRuleLadder) |
|
|
|
exist, err := models.GetById(ladder, ladderId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") |
|
|
|
|
|
|
|
if ladder.Status != define.StatusRunning { |
|
|
|
t.ERROR(fmt.Sprintf("该活动%s", ladder.Status), code.MSG_ERR) |
|
|
|
} |
|
|
|
// 通知直播开始抽奖
|
|
|
|
im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeLotteryDrawRollStart, |
|
|
|
map[string]interface{}{ |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"desc": "开始滚动", |
|
|
|
}) |
|
|
|
t.SUCCESS("操作成功") |
|
|
|
} |
|
|
|
|
|
|
|
func (t *LotteryDrawCtl) StopRoll() { |
|
|
|
ladderId := t.MustGetInt64("lottery_draw_ladder_id") |
|
|
|
activityId := t.MustGetInt64("activity_id") |
|
|
|
|
|
|
|
ladder := new(models.LotteryDrawRuleLadder) |
|
|
|
exist, err := models.GetById(ladder, ladderId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") |
|
|
|
|
|
|
|
if ladder.Status != define.StatusRunning { |
|
|
|
t.ERROR(fmt.Sprintf("该活动%s", ladder.Status), code.MSG_ERR) |
|
|
|
} |
|
|
|
// 通知直播开始抽奖
|
|
|
|
im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeLotteryDrawRollStop, |
|
|
|
map[string]interface{}{ |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"desc": "停止滚动", |
|
|
|
}) |
|
|
|
t.SUCCESS("操作成功") |
|
|
|
} |
|
|
@ -72,6 +118,7 @@ func (t *LotteryDrawCtl) Stop() { |
|
|
|
map[string]interface{}{ |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"desc": "结束抽奖", |
|
|
|
}) |
|
|
|
|
|
|
|
t.SUCCESS("操作成功") |
|
|
@ -329,9 +376,18 @@ func (t *LotteryDrawCtl) Lottery() { |
|
|
|
NotIn("user_id", recordIds).Find(&lotteryUsers) |
|
|
|
t.CheckErr(err) |
|
|
|
} else { |
|
|
|
// 同轮次剔除中奖用户
|
|
|
|
// 去除同规则中将用户
|
|
|
|
recordIds := make([]int64, 0) |
|
|
|
err = core.GetXormAuto().Table(new(models.LotteryDrawRecord)).Select("user_id"). |
|
|
|
Where("lottery_draw_rule_ladder_id=? and rehearsal_id=? and area_id=? and is_delete=0", |
|
|
|
ladderId, activity.RehearsalId, area.Id).Find(&recordIds) |
|
|
|
t.CheckErr(err) |
|
|
|
|
|
|
|
err = core.GetXormAuto().Table(new(models.SignHistory)).Select("user_id"). |
|
|
|
Where("is_delete=0 and rehearsal_id=? and area_id=?", |
|
|
|
activity.RehearsalId, area.Id).In("sign_rule_id", signUpIds).Find(&lotteryUsers) |
|
|
|
activity.RehearsalId, area.Id).In("sign_rule_id", signUpIds). |
|
|
|
NotIn("user_id", recordIds).Find(&lotteryUsers) |
|
|
|
t.CheckErr(err) |
|
|
|
} |
|
|
|
if len(lotteryUsers) < number { |
|
|
@ -397,9 +453,10 @@ func (t *LotteryDrawCtl) Lottery() { |
|
|
|
// 通知直播开始抽奖
|
|
|
|
im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeLotteryDrawResult, |
|
|
|
map[string]interface{}{ |
|
|
|
"winners": winners, |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"winners": winners, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"desc": "抽奖结果", |
|
|
|
}) |
|
|
|
|
|
|
|
t.RAW(winners) |
|
|
|