From fa8e827956b99c4d6e89130e3ecff3940866fedc Mon Sep 17 00:00:00 2001 From: tommy <3405129587@qq.com> Date: Fri, 8 May 2020 18:17:00 +0800 Subject: [PATCH] xxxx --- controllers/client/activity.go | 27 +++++++++------------------ controllers/client/live.go | 2 +- models/shake_red_envelope_record.go | 5 +++-- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/controllers/client/activity.go b/controllers/client/activity.go index 7a8a6a6..4453cfe 100644 --- a/controllers/client/activity.go +++ b/controllers/client/activity.go @@ -39,34 +39,25 @@ func (t *ActivityCtl) ModuleCurrent() { t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") + var data map[string]interface{} switch moduleName { case define.MODULE_TUGWAR: // 拔河 - data, err := bahe_service.GetCurrentTugWar(activityId, uid, activity.RehearsalId) - t.CheckErr(err) - t.JSON(data) + data, err = bahe_service.GetCurrentTugWar(activityId, uid, activity.RehearsalId) case define.MODULE_CALORIE: // 卡路里 - data, err := calorie_service.GetCurrentCalorie(activityId, uid, activity.RehearsalId) - t.CheckErr(err) - t.JSON(data) + data, err = calorie_service.GetCurrentCalorie(activityId, uid, activity.RehearsalId) case define.MODULE_SHAKRB: // 摇红包 // 没有初始状态 // 记下参与人数 - data, err := red_envelope_service.GetCurrentRB(activityId, uid, activity.RehearsalId) - t.CheckErr(err) - t.JSON(data) + data, err = red_envelope_service.GetCurrentRB(activityId, uid, activity.RehearsalId) case define.MODULE_AUCTION: // 竞拍 - data, err := auction_service.GetCurrentAuction(activityId, activity.RehearsalId, t.MustGetUID()) - t.CheckErr(err) - t.JSON(data) + data, err = auction_service.GetCurrentAuction(activityId, activity.RehearsalId, t.MustGetUID()) case define.MODULE_VOTE: - data, err := vote_service.GetCurrentVote(activityId, uid, activity.RehearsalId) - t.CheckErr(err) - t.JSON(data) + data, err = vote_service.GetCurrentVote(activityId, uid, activity.RehearsalId) case define.MODULE_BULLYS: - data, err := bully_screen_service.GetCurrentBullyScreen(activityId) - t.CheckErr(err) - t.JSON(data) + data, err = bully_screen_service.GetCurrentBullyScreen(activityId) default: t.ERROR("不存在该模块", code.MSG_MODULE_NOT_EXIST) } + t.CheckErr(err) + t.JSON(data) } diff --git a/controllers/client/live.go b/controllers/client/live.go index 2d07f8f..75168cd 100644 --- a/controllers/client/live.go +++ b/controllers/client/live.go @@ -200,7 +200,7 @@ func (t *LiveCtl) GetLiveRedPack() { t.Assert(exist, code.MSG_USER_NOT_EXIST, "不存在用户") redPack := new(models.ShakeRedEnvelopeRecord) - exist, err = redPack.GetLiveRedPackRecord(ruleId) + exist, err = redPack.GetLiveRedPackRecord(ruleId, rule.RehearsalId) t.CheckErr(err) if !exist { // 通知其他的人 diff --git a/models/shake_red_envelope_record.go b/models/shake_red_envelope_record.go index 5636d1a..5c009a0 100644 --- a/models/shake_red_envelope_record.go +++ b/models/shake_red_envelope_record.go @@ -85,6 +85,7 @@ func GetRedEnvelopesByUserId(userId int64) ([]*ShakeRedEnvelopeRecord, error) { return records, err } -func (t *ShakeRedEnvelopeRecord) GetLiveRedPackRecord(id interface{}) (bool, error) { - return core.GetXormAuto().Where("is_delete=0 and red_envelope_type = 1 and live_red_envelope_rule_id=?", id).Get(t) +func (t *ShakeRedEnvelopeRecord) GetLiveRedPackRecord(id, rehearsalId interface{}) (bool, error) { + return core.GetXormAuto().Where("is_delete=0 and red_envelope_type = 1 and user_id == 0 "+ + "live_red_envelope_rule_id=? and rehearsal_id=?", id, rehearsalId).Get(t) }