mirror of https://gitee.com/answerdev/answer.git
fix(activity): wrong decrease user rank when reach daily rank
This commit is contained in:
parent
fcb48b86ee
commit
5861eebb78
|
@ -293,8 +293,14 @@ func (vr *VoteRepo) saveActivitiesAvailable(session *xorm.Session, op *schema.Vo
|
|||
continue
|
||||
}
|
||||
if exist {
|
||||
if _, err = session.Where("id = ?", existsActivity.ID).Cols("`cancelled`").
|
||||
Update(&entity.Activity{Cancelled: entity.ActivityAvailable}); err != nil {
|
||||
bean := &entity.Activity{
|
||||
Cancelled: entity.ActivityAvailable,
|
||||
Rank: activity.Rank,
|
||||
HasRank: activity.HasRank(),
|
||||
}
|
||||
session.Where("id = ?", existsActivity.ID)
|
||||
if _, err = session.Cols("`cancelled`", "`rank`", "`has_rank`").
|
||||
Update(bean); err != nil {
|
||||
return false, err
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -50,11 +50,11 @@ func (ur *UserRankRepo) CheckReachLimit(ctx context.Context, session *xorm.Sessi
|
|||
MoreVal: now.EndOfDay(),
|
||||
})
|
||||
|
||||
earned, err := session.Sum(&entity.Activity{}, "`rank`")
|
||||
earned, err := session.SumInt(&entity.Activity{}, "`rank`")
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if int(earned) <= maxDailyRank {
|
||||
if int(earned) < maxDailyRank {
|
||||
return false, nil
|
||||
}
|
||||
log.Infof("user %s today has rank %d is reach stand %d", userID, earned, maxDailyRank)
|
||||
|
|
Loading…
Reference in New Issue