diff --git a/cv/group_cv/group.go b/cv/group_cv/group.go index 28cb11bcaac52c813f9d02273f72c39f0fc62a04..54e20f272e5b57e189e1d4e8641ea50a98d771f0 100644 --- a/cv/group_cv/group.go +++ b/cv/group_cv/group.go @@ -357,6 +357,15 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, groupIds [ } medals := make([]medal_cv.PicElement, 0) + // 补上房间流水勋章 + var pe *medal_cv.PicElement + _, pe, err = medal_cv.GetGroupConsumeMedal(model, i) + if err != nil { + model.Log.Infof("BuildJoinedGroupInfo: GetGroupConsumeMedal: %s", err.Error()) + } else if pe != nil { + medals = append(medals, medal_cv.PicElement{PicUrl: pe.PicUrl}) + } + // res_medal if m, ok := groupMedals[i]; ok { for _, j := range m { mId := uint32(j) @@ -367,14 +376,6 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, groupIds [ } } } - // 补上房间流水勋章 - var pe *medal_cv.PicElement - _, pe, err = medal_cv.GetGroupConsumeMedal(model, i) - if err != nil { - model.Log.Infof("BuildJoinedGroupInfo: GetGroupConsumeMedal: %s", err.Error()) - } else if pe != nil { - medals = append(medals, medal_cv.PicElement{PicUrl: pe.PicUrl}) - } var password *string = nil if len(g.Password) > 0 && g.Owner != myUserId { diff --git a/domain/model/group_m/groupMedal.go b/domain/model/group_m/groupMedal.go index f79e62195bf776fa046632488f0e625d8aa379b7..71f24240af4e9d926f78d5707c88e5b9b597bdc2 100644 --- a/domain/model/group_m/groupMedal.go +++ b/domain/model/group_m/groupMedal.go @@ -3,9 +3,11 @@ package group_m import ( "git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/resource/mysql" + "git.hilo.cn/hilo-common/utils" "gorm.io/gorm" "gorm.io/gorm/clause" "hilo-group/myerr" + "time" ) //群组勋章 @@ -30,7 +32,6 @@ func (groupInfo *GroupInfo) GroupMedalMgrAdd(model *domain.Model, resMedalId uin } } - func GetGroupMedalOrErr(model *domain.Model, id mysql.ID) (*GroupMedal, error) { groupMedal := GroupMedal{} if err := model.Db.Model(&GroupMedal{}).First(&groupMedal, id).Error; err != nil { @@ -65,7 +66,9 @@ func BatchGetMedals(db *gorm.DB, groupIds []string) (map[string][]uint64, error) return nil, nil } rows := make([]GroupMedal, 0) - if err := db.Model(&GroupMedal{}).Where("im_group_id IN ?", groupIds).Find(&rows).Error; err != nil { + if err := db.Model(&GroupMedal{}).Where("im_group_id IN ?", groupIds). + Where("(expire_at is null or expire_at > ?)", time.Now().Format(utils.DATETIME_FORMAT)). + Find(&rows).Error; err != nil { return nil, err } result := make(map[string][]uint64, 0)