|
|
@ -27,6 +27,12 @@ func (t *LotteryDrawCtl) Start() { |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") |
|
|
|
|
|
|
|
activity := new(models.Activity) |
|
|
|
exist, err = models.Get(activity, activityId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|
|
|
t.CheckRunning(activity.Status) |
|
|
|
|
|
|
|
if ladder.Status != define.StatusNotBegin { |
|
|
|
t.ERROR(fmt.Sprintf("该活动%s", ladder.Status), code.MSG_ERR) |
|
|
|
} |
|
|
@ -36,12 +42,15 @@ func (t *LotteryDrawCtl) Start() { |
|
|
|
_, err = models.Update(ladder.Id, ladder, "status", "roll_num", "updated_at") |
|
|
|
t.CheckErr(err) |
|
|
|
// 通知直播开始抽奖
|
|
|
|
im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeLotteryDrawStart, |
|
|
|
map[string]interface{}{ |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"desc": "开始抽奖", |
|
|
|
}) |
|
|
|
if activity.RehearsalId == 0 { |
|
|
|
go im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeLotteryDrawStart, |
|
|
|
map[string]interface{}{ |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"desc": "开始抽奖", |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
t.SUCCESS("操作成功") |
|
|
|
} |
|
|
|
|
|
|
@ -51,8 +60,14 @@ func (t *LotteryDrawCtl) StartRoll() { |
|
|
|
activityId := t.MustGetInt64("activity_id") |
|
|
|
num := t.MustGetInt64("num") |
|
|
|
|
|
|
|
activity := new(models.Activity) |
|
|
|
exist, err := models.Get(activity, activityId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|
|
|
t.CheckRunning(activity.Status) |
|
|
|
|
|
|
|
ladder := new(models.LotteryDrawRuleLadder) |
|
|
|
exist, err := models.Get(ladder, ladderId) |
|
|
|
exist, err = models.Get(ladder, ladderId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") |
|
|
|
|
|
|
@ -63,14 +78,16 @@ func (t *LotteryDrawCtl) StartRoll() { |
|
|
|
_, err = models.Update(ladder.Id, ladder, "roll_num") |
|
|
|
|
|
|
|
// 通知直播开始抽奖
|
|
|
|
im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeLotteryDrawRollStart, |
|
|
|
map[string]interface{}{ |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"roll_num": ladder.RollNum, |
|
|
|
"desc": "开始滚动", |
|
|
|
"number": num, |
|
|
|
}) |
|
|
|
if activity.RehearsalId == 0 { |
|
|
|
go im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeLotteryDrawRollStart, |
|
|
|
map[string]interface{}{ |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"roll_num": ladder.RollNum, |
|
|
|
"desc": "开始滚动", |
|
|
|
"number": num, |
|
|
|
}) |
|
|
|
} |
|
|
|
t.SUCCESS("操作成功") |
|
|
|
} |
|
|
|
|
|
|
@ -79,8 +96,14 @@ func (t *LotteryDrawCtl) StopRoll() { |
|
|
|
activityId := t.MustGetInt64("activity_id") |
|
|
|
num := t.MustGetInt64("num") |
|
|
|
|
|
|
|
activity := new(models.Activity) |
|
|
|
exist, err := models.Get(activity, activityId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|
|
|
t.CheckRunning(activity.Status) |
|
|
|
|
|
|
|
ladder := new(models.LotteryDrawRuleLadder) |
|
|
|
exist, err := models.Get(ladder, ladderId) |
|
|
|
exist, err = models.Get(ladder, ladderId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") |
|
|
|
|
|
|
@ -88,14 +111,16 @@ func (t *LotteryDrawCtl) StopRoll() { |
|
|
|
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(), |
|
|
|
"roll_num": ladder.RollNum, |
|
|
|
"desc": "停止滚动", |
|
|
|
"number": num, |
|
|
|
}) |
|
|
|
if activity.RehearsalId == 0 { |
|
|
|
go im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeLotteryDrawRollStop, |
|
|
|
map[string]interface{}{ |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"roll_num": ladder.RollNum, |
|
|
|
"desc": "停止滚动", |
|
|
|
"number": num, |
|
|
|
}) |
|
|
|
} |
|
|
|
t.SUCCESS("操作成功") |
|
|
|
} |
|
|
|
|
|
|
@ -104,8 +129,14 @@ func (t *LotteryDrawCtl) Stop() { |
|
|
|
ladderId := t.MustGetInt64("lottery_draw_ladder_id") |
|
|
|
activityId := t.MustGetInt64("activity_id") |
|
|
|
|
|
|
|
activity := new(models.Activity) |
|
|
|
exist, err := models.Get(activity, activityId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|
|
|
t.CheckRunning(activity.Status) |
|
|
|
|
|
|
|
ladder := new(models.LotteryDrawRuleLadder) |
|
|
|
exist, err := models.Get(ladder, ladderId) |
|
|
|
exist, err = models.Get(ladder, ladderId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_LOTTERY_RULE_NOT_EXIST, "抽奖规则不存在") |
|
|
|
|
|
|
@ -120,13 +151,14 @@ func (t *LotteryDrawCtl) Stop() { |
|
|
|
t.CheckErr(err) |
|
|
|
|
|
|
|
// 通知直播开始抽奖
|
|
|
|
im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeLotteryDrawStop, |
|
|
|
map[string]interface{}{ |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"desc": "结束抽奖", |
|
|
|
}) |
|
|
|
|
|
|
|
if activity.RehearsalId == 0 { |
|
|
|
go im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeLotteryDrawStop, |
|
|
|
map[string]interface{}{ |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"desc": "结束抽奖", |
|
|
|
}) |
|
|
|
} |
|
|
|
t.SUCCESS("操作成功") |
|
|
|
} |
|
|
|
|
|
|
@ -310,14 +342,16 @@ func (t *LotteryDrawCtl) Lottery() { |
|
|
|
} |
|
|
|
|
|
|
|
// 通知直播开始抽奖
|
|
|
|
im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeLotteryDrawResult, |
|
|
|
map[string]interface{}{ |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"winners": winners, |
|
|
|
"roll_num": ladder.RollNum, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"desc": "抽奖结果", |
|
|
|
}) |
|
|
|
if activity.RehearsalId == 0 { |
|
|
|
im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeLotteryDrawResult, |
|
|
|
map[string]interface{}{ |
|
|
|
"lottery_draw_ladder_id": ladder.Id, |
|
|
|
"winners": winners, |
|
|
|
"roll_num": ladder.RollNum, |
|
|
|
"timestamp": time.Now().Unix(), |
|
|
|
"desc": "抽奖结果", |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
t.JSON(winners) |
|
|
|
} |
|
|
|