From d085813f675e0f0c1acdc1028e417042171ab5e9 Mon Sep 17 00:00:00 2001 From: tommy <3405129587@qq.com> Date: Mon, 13 Jul 2020 17:31:07 +0800 Subject: [PATCH] fix:bug --- controllers/client/shake_red_envelope.go | 4 +--- controllers/pc/vote.go | 10 ++++++++-- models/new_vote_activity.go | 5 +++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/controllers/client/shake_red_envelope.go b/controllers/client/shake_red_envelope.go index 08f1e09..b8c693b 100644 --- a/controllers/client/shake_red_envelope.go +++ b/controllers/client/shake_red_envelope.go @@ -97,9 +97,7 @@ func (t *ShakeRedEnvelopeCtl) Shake() { if activity.RehearsalId == 0 { result, err := pay_service.SendRedPack("欧轩互动", user.Openid, "红包只会越抢越多", "直播抢红包活动", "抢的多,赚得多", int(record.Amount*100), 1, 2) - if err != nil { - t.ERROR("红包被领完了", code.MSG_SHAKERB_RECORD_NOT_HIT) - } + t.CheckErr(err) record.MchBillno = result.MchBillno models.Update(record.Id, record, "mch_billno") } diff --git a/controllers/pc/vote.go b/controllers/pc/vote.go index 221d811..c2c96f2 100644 --- a/controllers/pc/vote.go +++ b/controllers/pc/vote.go @@ -133,7 +133,8 @@ func (t *VoteCtl) JoinTotal() { t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") total, err := core.GetXormAuto().Distinct("user_id").Where("vote_activity_id=? and rehearsal_id=? "+ - " and is_delete=0", voteActivityId, activity.RehearsalId, activity.ArchId).Count(new(models.NewVoteActivityHistory)) + " arch_id=? and is_delete=0", voteActivityId, activity.RehearsalId, activity.ArchId). + Count(new(models.NewVoteActivityHistory)) t.CheckErr(err) t.JSON(total) } @@ -142,7 +143,12 @@ func (t *VoteCtl) JoinTotal() { func (t *VoteCtl) List() { activityId := t.MustGetInt64("activity_id") - votes, err := models.GetVoteListByActivityId(activityId) + activity := new(models.Activity) + exist, err := models.Get(activity, activityId) + t.CheckErr(err) + t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") + + votes, err := models.GetVoteListByActivityId(activityId, activity.ArchId) t.CheckErr(err) ids := make([]int64, 0) diff --git a/models/new_vote_activity.go b/models/new_vote_activity.go index f0e5f6d..41de907 100644 --- a/models/new_vote_activity.go +++ b/models/new_vote_activity.go @@ -11,6 +11,7 @@ const NewVoteActivityTableName = TableNamePrefix + "new_vote_activity" type NewVoteActivity struct { Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"` ActivityId int64 `json:"activity_id" xorm:"not null comment('互动id') INT(11)"` + Arch int `json:"arch" xorm:"not null default 0 comment('归档') INT(11)"` VoteActivityLadders []*NewVoteActivityLadder `json:"vote_activity_ladders" xorm:"-"` Theme string `json:"theme" xorm:"not null default('') comment('投票主题') VARCHAR(255)"` JoinWay string `json:"join_way" xorm:"not null comment('参与方式说明') TEXT"` @@ -63,9 +64,9 @@ func UpdateVoteStatusByActivityId(aid int64) (int64, error) { Update(&NewVoteActivity{VoteStatus: define.StatusNotBegin}) } -func GetVoteListByActivityId(activityId interface{}) ([]*NewVoteActivity, error) { +func GetVoteListByActivityId(activityId, archId interface{}) ([]*NewVoteActivity, error) { votes := make([]*NewVoteActivity, 0) - err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId). + err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and arch_id=?", activityId, archId). Asc("created_at").Find(&votes) return votes, err }