fix(activity): wrong decrease user rank when reach daily rank

This commit is contained in:
LinkinStars 2023-07-06 15:37:20 +08:00
parent fcb48b86ee
commit 5861eebb78
2 changed files with 10 additions and 4 deletions

View File

@ -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 {

View File

@ -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)