diff --git a/cron/cron.go b/cron/cron.go index 4685ff48a5225e01ab003370251f6040d5223b19..1e2dc64df19656e6c674606930577f00784c6d89 100644 --- a/cron/cron.go +++ b/cron/cron.go @@ -11,13 +11,14 @@ func Init() { if !config.IsMaster() { return } - gift_cron.SendGiftEventInit() // 礼物消息 - gift_cron.GiftRemark() // 礼物消息补偿 + //gift_cron.SendGiftEventInit() // 礼物消息 + //gift_cron.GiftRemark() // 礼物消息补偿 + gift_cron.SendGiftEvent() // 礼物事件 mic_cron.OnMicCheck() // 检查上麦 group_cron.GroupPowerExpClear() // 清理家族经验/等级 group_cron.GroupPowerMonthRankAct() - group_cron.GroupInEventInit() // 进房事件 - group_cron.GroupPowerGradeExp() // 家族升级 + //group_cron.GroupInEventInit() // 进房事件 + group_cron.GroupPowerGradeExp() // 家族升级(上麦事件会用到) todo group_cron.CreateGroup() // group_cron.CalcGroupSupport() // 群组扶持计算 } diff --git a/cron/gift_cron/send_gift_redis.go b/cron/gift_cron/send_gift_redis.go new file mode 100644 index 0000000000000000000000000000000000000000..cc9f581850bc858dd461b9cccccc3952247afa7c --- /dev/null +++ b/cron/gift_cron/send_gift_redis.go @@ -0,0 +1,90 @@ +package gift_cron + +import ( + "git.hilo.cn/hilo-common/domain" + "git.hilo.cn/hilo-common/resource/mysql" + "hilo-group/_const/enum/groupPower_e" + "hilo-group/domain/cache/gift_c" + "hilo-group/domain/event/gift_ev" + "hilo-group/domain/model/groupPower_m" +) + +// 送礼事件 +func SendGiftEvent() { + //if !config.IsMaster() { + // return + //} + go func() { + for true { + model := domain.CreateModelNil() + if sendGiftEvent := gift_c.BLPopQueueSendGift(model); sendGiftEvent != nil { + groupPowerGrade(model, sendGiftEvent) // 家族经验 + groupPowerStar(model, sendGiftEvent) // 家族之星 + } + } + }() +} + +// 群组势力经验 +func groupPowerGrade(model *domain.Model, sendGiftEvent *gift_ev.SendGiftEvent) { + model.Log.Infof("AddSendGiftEventAsync %+v", sendGiftEvent) + if sendGiftEvent.ResGift.GiftType != mysql.DiamondYellow { + return + } + exist, groupPowerId, err := groupPower_m.CheckGroupPowerUser(model, sendGiftEvent.SendUserId) + if err != nil { + model.Log.Infof("CheckGroupPowerUser fail %+v", err) + return + } + if exist { + exp := sendGiftEvent.GiftN * mysql.Num(len(sendGiftEvent.ReceiveUserIds)) * sendGiftEvent.ResGift.DiamondNum + //return model.Transaction(func(model *domain.Model) error { + // return groupPower_m.IncrGroupPowerExp(model, groupPowerId, exp, sendGiftEvent.SendUserId, "送礼") + //}) + //return groupPower_c.QueueGroupPowerGradeExp(model, groupPowerId, exp, sendGiftEvent.SendUserId, "送礼") + if err := model.Transaction(func(model *domain.Model) error { + return groupPower_m.IncrGroupPowerExp(model, groupPowerId, exp, sendGiftEvent.SendUserId, "送礼") + }); err != nil { + model.Log.Errorf("IncrGroupPowerExp fail,data:%v-err:%v", *sendGiftEvent, err) + } else { + model.Log.Infof("IncrGroupPowerExp success,data:%v", *sendGiftEvent) + } + } +} + +// 家族之星 +func groupPowerStar(model *domain.Model, sendGiftEvent *gift_ev.SendGiftEvent) { + if sendGiftEvent.ResGift.GiftType != mysql.DiamondYellow { + return + } + var userIds = []mysql.ID{sendGiftEvent.SendUserId} + userIds = append(userIds, sendGiftEvent.ReceiveUserIds...) + groupPowers, err := groupPower_m.BatchGetGroupPowerUser(model, userIds) + if err != nil { + model.Log.Errorf("AddSendGiftEventAsync fail:%v", err) + return + } + // 送礼加分 + if data, ok := groupPowers[sendGiftEvent.SendUserId]; ok { + diamonds := sendGiftEvent.GiftN * sendGiftEvent.ResGift.DiamondNum * mysql.Num(len(sendGiftEvent.ReceiveUserIds)) + if err := groupPower_m.IncrGroupPowerMonthStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeFamous, diamonds, 0); err != nil { + model.Log.Errorf("IncrGroupPowerMonthStarScore famous fail:%v", err) + } + if err := groupPower_m.IncrGroupPowerDayStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeFamous, diamonds, 0); err != nil { + model.Log.Errorf("IncrGroupPowerDayStarScore famous fail:%v", err) + } + } + // 收礼加分 + for _, userId := range sendGiftEvent.ReceiveUserIds { + if data, ok := groupPowers[userId]; ok { + diamonds := sendGiftEvent.GiftN * sendGiftEvent.ResGift.DiamondNum + if err := groupPower_m.IncrGroupPowerMonthStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeCharm, diamonds, 0); err != nil { + model.Log.Errorf("IncrGroupPowerMonthStarScore charm fail:%v", err) + } + if err := groupPower_m.IncrGroupPowerDayStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeCharm, diamonds, 0); err != nil { + model.Log.Errorf("IncrGroupPowerDayStarScore charm fail:%v", err) + } + } + } + return +} diff --git a/cron/mic_cron/on_mic.go b/cron/mic_cron/on_mic.go index 5e5ad8b1e3df0999b333bc93f6c87fc6ee5abb18..923ecd8831df44089cecb9ed5343965960bc087b 100644 --- a/cron/mic_cron/on_mic.go +++ b/cron/mic_cron/on_mic.go @@ -21,14 +21,12 @@ func OnMicCheck() { } for _, groupId := range groupIds { //遍历每个麦位 - for i := 1; i <= 30; i++ { + for i := 1; i <= group_m.MaxMicNum; i++ { micUser, err := group_m.GetMicUser(model, groupId, i) if err != nil { model.Log.Errorf("cron micIn group_m.GetMicUser err:%v", err) } if micUser != nil { - continue - // todo 先不做麦位相关的动作。。 if err := mic_ev.PublishOnMicEvent(model, &mic_ev.OnMicEvent{ GroupUuid: micUser.GroupUuid, I: micUser.I, diff --git a/cv/group_cv/group.go b/cv/group_cv/group.go index 13971b1e7db3945423cb32ccfd8e3dd9c0b0f15b..cd04da4ceb618cfa944342ab4098cbc87e7f10ab 100644 --- a/cv/group_cv/group.go +++ b/cv/group_cv/group.go @@ -251,13 +251,24 @@ type CvCountry struct { AreaCodeName *string `json:"areaShortName"` } -func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, groupIds []string, pageSize, pageIndex int) ([]JoinedGroupInfo, int, error) { +func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, originGroupIds []string, pageSize, pageIndex int) ([]JoinedGroupInfo, int, error) { model := domain.CreateModel(myService.CtxAndDb) - groupInfo, err := group_m.BatchGetGroupInfo(model, groupIds) + groupInfo, err := group_m.BatchGetGroupInfo(model, originGroupIds) if err != nil { return nil, 0, err } + var groupIds []string + for _, groupId := range originGroupIds { + if group, ok := groupInfo[groupId]; ok { + if group.IsGameRoom == 0 { + groupIds = append(groupIds, groupId) + } + } + } + if len(groupIds) <= 0 { + return nil, 0, nil + } // todo: 可以移到后面,减小查询范围,因为roomMicUserMap不影响排序 roomMicUserMap, err := group_m.BatchGetAllMicUser(model, groupIds) @@ -310,7 +321,7 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, groupIds [ if err != nil { return nil, 0, err } - model.Log.Infof("BuildJoinedGroupInfo, roomEnterTime: %v", roomEnterTime) + //model.Log.Infof("BuildJoinedGroupInfo, roomEnterTime: %v", roomEnterTime) // 排序优先级V8.0版本 sort.Slice(groupIds, func(i, j int) bool { diff --git a/domain/cache/gift_c/gift_event.go b/domain/cache/gift_c/gift_event.go new file mode 100644 index 0000000000000000000000000000000000000000..5e9868b49fd52fef77704a50cf94832a4fffb9fc --- /dev/null +++ b/domain/cache/gift_c/gift_event.go @@ -0,0 +1,34 @@ +package gift_c + +import ( + "encoding/json" + "git.hilo.cn/hilo-common/domain" + "github.com/go-redis/redis/v8" + "hilo-group/domain/event/gift_ev" + "time" +) + +const EventSendGiftHiloGroupQueue = "send:gift:queue:hilo_group" + +// redis pop event sendGift +func BLPopQueueSendGift(model *domain.Model) *gift_ev.SendGiftEvent { + var res *gift_ev.SendGiftEvent + queue := EventSendGiftHiloGroupQueue + strs, err := model.Redis.BLPop(model, time.Second, queue).Result() + if err != nil { + if err != redis.Nil { + model.Log.Errorf("BLPopQueueSendGift fail:%v", err) + } + return nil + } + if len(strs) >= 2 { + content := strs[1] + res = new(gift_ev.SendGiftEvent) + if err := json.Unmarshal([]byte(content), res); err != nil { + model.Log.Errorf("BLPopQueueSendGift json fail:%v", err) + return nil + } + return res + } + return nil +} diff --git a/domain/cache/room_c/userRoomVisit.go b/domain/cache/room_c/userRoomVisit.go index 710286ae62c0d99c32df6302fa396fb1bd5a2ee3..94e24e653a7efee6b841bbb64f273bc33f0e5e0b 100644 --- a/domain/cache/room_c/userRoomVisit.go +++ b/domain/cache/room_c/userRoomVisit.go @@ -65,7 +65,7 @@ func GetUserRoomVisit(userId uint64) (map[string]int64, error) { if err != nil { return nil, err } - mylogrus.MyLog.Infof("GetUserRoomVisit, ZRangeWithScores %s, return %v", key, ret) + //mylogrus.MyLog.Infof("GetUserRoomVisit, ZRangeWithScores %s, return %v", key, ret) result := make(map[string]int64, 0) for _, i := range ret { diff --git a/domain/model/groupPower_m/group_rank.go b/domain/model/groupPower_m/group_rank.go index 387febbcb00b60369b227cc4a7715ab5ddd2edcf..71f5645db73040ed2bf66c9ac02bade17c446524 100644 --- a/domain/model/groupPower_m/group_rank.go +++ b/domain/model/groupPower_m/group_rank.go @@ -15,11 +15,12 @@ type GroupPowerExpRank struct { // 获取家族经验排行榜 // param limit: 排行榜人数 -// 10166 线上员工,对应的势力不上榜,groupPowerId=8951 +// 10166 线上员工,对应的势力不上榜,groupPowerId=8951,6171(产品要移走) func GetGroupPowerExpRank(model *domain.Model, beginDate, endDate string, limit int, gpStatus groupPower_e.GroupPowerStatus, area int) ([]GroupPowerExpRank, error) { var res []GroupPowerExpRank db := model.DB().Table("group_power_day_exp gpd").Select("gpd.group_power_id,SUM(gpd.exp) as exp"). Where("gpd.group_power_id <> 8951"). + Where("gpd.group_power_id <> 6171"). Where("gpd.date BETWEEN ? AND ?", beginDate, endDate) if gpStatus > 0 { db = db.Joins("left join group_power gp on gpd.group_power_id = gp.id").Where("gp.status = ?", gpStatus) diff --git a/domain/model/group_m/factory.go b/domain/model/group_m/factory.go index 7313a09afe29c8aea29eff01063b57f8516faec8..a1c5d390d9534143d907379b2182ed811c30eaf7 100644 --- a/domain/model/group_m/factory.go +++ b/domain/model/group_m/factory.go @@ -253,7 +253,7 @@ func BatchGetAllMicUser(model *domain.Model, groupIds []string) (map[string][]my if err != nil { return nil, err } - model.Log.Infof("BatchGetAllMicUser redis return size = %d, mics: %v", len(mics), mics) + //model.Log.Infof("BatchGetAllMicUser redis return size = %d, mics: %v", len(mics), mics) if len(mics) >= len(groupIds) { for i, g := range groupIds { @@ -432,7 +432,7 @@ func GetMicUserByExternalId(model *domain.Model, externalId string) (*MicUser, e //麦位上没人,返回nil func GetMicUser(model *domain.Model, groupUuid string, i int) (*MicUser, error) { - if i < 1 || i > 30 { + if i < 1 || i > MaxMicNum { return nil, myerr.NewSysErrorF("麦序不对,不在范围值内 i:%v", i) } str, err := redisCli.GetRedis().Get(context.Background(), redis_key.GetPrefixGroupMicUser(groupUuid, i)).Result() diff --git a/domain/model/group_m/groupGame.go b/domain/model/group_m/groupGame.go new file mode 100644 index 0000000000000000000000000000000000000000..03844d71d749de81ce7a4ec0c377a5f202ebd3df --- /dev/null +++ b/domain/model/group_m/groupGame.go @@ -0,0 +1,17 @@ +package group_m + +import "git.hilo.cn/hilo-common/domain" + +// 获取游戏房 +func GetGameGroupsMap(model *domain.Model) map[string]bool { + res := make(map[string]bool) + var rows []GroupInfo + if err := model.DB().Model(GroupInfo{}).Where("is_game_room = 1").Find(&rows).Error; err != nil { + model.Log.Errorf("GetGameGroupsMap fail:%v", err) + return res + } + for _, v := range rows { + res[v.ImGroupId] = true + } + return res +} diff --git a/domain/model/group_m/mic.go b/domain/model/group_m/mic.go index 25e340317ec1cf76814e7b23b28f211a724c92bb..810279f7dc45bd6dfa2a2861d3476d94264f0acf 100644 --- a/domain/model/group_m/mic.go +++ b/domain/model/group_m/mic.go @@ -843,6 +843,7 @@ func GetMicHasInGroups() ([]string, error) { if err != nil { return nil, myerr.WrapErr(err) } + return groupUuids, nil // 不需要下面的逐个麦位的判断了 // resultGroupUuids := make([]string, 0, len(groupUuids)) //循环lua判断是否, 最后的保证,(猜想:真正麦上有人的群没有很多) @@ -875,7 +876,7 @@ var micGroupNumCache = gcache.New(10000).LRU().Build() func GetMicHasInGroupNum(model *domain.Model) (map[string]int64, error) { // get from cache if data, err := micGroupNumCache.Get(micGroupNumKey); err == nil { - model.Log.Infof("GetMicHasInGroupNum cache hit:%v", data) + //model.Log.Infof("GetMicHasInGroupNum cache hit:%v", data) // 正服才缓存 if config.AppIsRelease() { return data.(map[string]int64), nil @@ -912,8 +913,8 @@ func GetMicHasInGroupNum(model *domain.Model) (map[string]int64, error) { } } // cache 1min - _ = micGroupNumCache.SetWithExpire(micGroupNumKey, resultGroupUuids, time.Minute) - model.Log.Infof("GetMicHasInGroupNum cache miss:%v", resultGroupUuids) + _ = micGroupNumCache.SetWithExpire(micGroupNumKey, resultGroupUuids, time.Minute*15) + //model.Log.Infof("GetMicHasInGroupNum cache miss:%v", resultGroupUuids) return resultGroupUuids, nil } diff --git a/domain/model/group_m/room.go b/domain/model/group_m/room.go index 24131ac845f9183d24c0a478886d017f65fdae9c..67604e385add87814cd850b1c14a7e4351f641e1 100644 --- a/domain/model/group_m/room.go +++ b/domain/model/group_m/room.go @@ -279,7 +279,7 @@ func RoomLivingExistsUserId(groupUid string) ([]uint64, error) { if err != nil { return nil, myerr.WrapErr(err) } - mylogrus.MyLog.Infof("group_room_living RoomLivingExistsUserId groupUserIdstrs:%v", groupUserIdstrs) + //mylogrus.MyLog.Infof("group_room_living RoomLivingExistsUserId groupUserIdstrs:%v", groupUserIdstrs) userIds := make([]uint64, 0, len(groupUserIdstrs)) for i, _ := range groupUserIdstrs { tempGroupUid, userId := analysisMemberStr(groupUserIdstrs[i]) @@ -333,7 +333,7 @@ func RoomLivingExistsGroup(model *domain.Model) (map[string]map[uint64]struct{}, if err != nil { return nil, myerr.WrapErr(err) } - model.Log.Infof("group_room_living RoomLivingExistsGroup groupUserIdstrs:%v", groupUserIdstrs) + //model.Log.Infof("group_room_living RoomLivingExistsGroup groupUserIdstrs:%v", groupUserIdstrs) groupGroup := map[string]map[uint64]struct{}{} for i, _ := range groupUserIdstrs { tempGroupUid, userId := analysisMemberStr(groupUserIdstrs[i]) @@ -429,7 +429,7 @@ func BatchGetRoomVisitCount(logE *logrus.Entry, groupIds []string) (map[string]i if err != nil { return nil, err } - logE.Infof("MGetRoomVisitCount:%v", roomVisitCount) + //logE.Infof("MGetRoomVisitCount:%v", roomVisitCount) visitCount := make(map[string]int64) for _, groupId := range groupIds { @@ -464,7 +464,7 @@ func BatchGetRoomVisitCountList(logE *logrus.Entry, groupIds []string) (map[stri if err != nil { return nil, nil, err } - logE.Infof("MGetRoomVisitCount:%v", roomVisitCount) + //logE.Infof("MGetRoomVisitCount:%v", roomVisitCount) res := make([]*RoomVisit, 0, len(groupIds)) visitCount := make(map[string]int64) diff --git a/domain/model/noble_m/userNoble.go b/domain/model/noble_m/userNoble.go index 9cf6aa4c36b27069af04f30b6f3e9385d894c47c..06a820cd0a83e31019629eb996c6decc8fe08b6d 100644 --- a/domain/model/noble_m/userNoble.go +++ b/domain/model/noble_m/userNoble.go @@ -144,7 +144,7 @@ func BatchGetActiveNoble(db *gorm.DB, userIds []uint64) (map[uint64]UserNoble, e start += NUM end += NUM } - mylogrus.MyLog.Infof("BatchGetActiveNoble expected:%v,actual:%v,notEndUids:%v", len(userIds), len(result), notEndUids) + //mylogrus.MyLog.Infof("BatchGetActiveNoble expected:%v,actual:%v,notEndUids:%v", len(userIds), len(result), notEndUids) if len(userIds) != len(result) { mylogrus.MyLog.Warnf("BatchGetActiveNoble expected:%v", userIds) } @@ -177,4 +177,4 @@ func BatchGetNobleLevel(db *gorm.DB, userIds []uint64) (map[uint64]uint16, error result[i] = m[i].Level } return result, nil -} \ No newline at end of file +} diff --git a/domain/model/tim_m/user.go b/domain/model/tim_m/user.go index 70d27ff2d76a49f499a06e5205ca9e99fce3456d..16e05cc2b71639d25f0701ae236a0ab97ec0c9d0 100644 --- a/domain/model/tim_m/user.go +++ b/domain/model/tim_m/user.go @@ -325,7 +325,7 @@ func GetOnlineStatus(model *domain.Model, extIds []string) (map[string]uint, err model.Log.Warnf("getOnlineStatus redis failed") left = extIds } else { - model.Log.Infof("getOnlineStatus redis return size = %d: %v", len(r), r) + //model.Log.Infof("getOnlineStatus redis return size = %d: %v", len(r), r) if len(r) >= len(extIds) { for i, e := range extIds { diff --git a/domain/model/user_m/medal.go b/domain/model/user_m/medal.go index 8930c194743832965bf0402d6d2bbd380a49a2cd..c77cc3c748c64603a69dc9a487f5f2558cef59c8 100644 --- a/domain/model/user_m/medal.go +++ b/domain/model/user_m/medal.go @@ -48,8 +48,8 @@ func GetUserMedalMerge(logger *logrus.Entry, db *gorm.DB, userId mysql.ID) ([]ui if err != nil { return nil, err } - logger.Infof("GetUserMedalLevelMap, user %d, medalMap %+v", medalTypes) - logger.Infof("GetUserMedalLevelMap, user %d, medalList %+v", medalList) + //logger.Infof("GetUserMedalLevelMap, user %d, medalMap %+v", medalTypes) + //logger.Infof("GetUserMedalLevelMap, user %d, medalList %+v", medalList) maxGrades := make(map[uint8]int, 0) maxMedalIds := make(map[uint8]uint32, 0) diff --git a/domain/model/user_m/user.go b/domain/model/user_m/user.go index dcf65bc2f539449797d20f26b6bf92564de8baf1..40287a18f4fd9947e038dabb84dac945e14caec6 100644 --- a/domain/model/user_m/user.go +++ b/domain/model/user_m/user.go @@ -94,10 +94,7 @@ func GetUserMapByIds(model *domain.Model, userIds []mysql.ID) (map[mysql.ID]User } var rows []User start := 0 - for end <= len(userIds) { - if end > len(userIds) { - end = len(userIds) - } + for start < len(userIds) { tmp, err := GetUsersByIds(model, userIds[start:end]) if err != nil { return result, err @@ -106,7 +103,10 @@ func GetUserMapByIds(model *domain.Model, userIds []mysql.ID) (map[mysql.ID]User } start += 500 end += 500 - model.Log.Infof("GetUserMapByIds start:%v-end:%v", start, end) + if end > len(userIds) { + end = len(userIds) + } + //model.Log.Infof("GetUserMapByIds start:%v-end:%v", start, end) } for _, i := range rows { result[i.ID] = i diff --git a/domain/model/user_m/vip.go b/domain/model/user_m/vip.go index 5d3ed7ac54624ccdbc5ac0d4c4160e8932a5f758..f7e7721ea77a4368041817dbb2fe4a5027a6578c 100644 --- a/domain/model/user_m/vip.go +++ b/domain/model/user_m/vip.go @@ -2,7 +2,6 @@ package user_m import ( "git.hilo.cn/hilo-common/domain" - "git.hilo.cn/hilo-common/mylogrus" "git.hilo.cn/hilo-common/resource/mysql" "gorm.io/gorm" "gorm.io/gorm/clause" @@ -69,10 +68,7 @@ func BatchGetVips(userIds []uint64) (map[uint64]*int64, error) { end = len(userIds) } start := 0 - for end <= len(userIds) { - if end > len(userIds) { - end = len(userIds) - } + for start < len(userIds) { tmp := make([]UserVip, 0) err := mysql.Db.Where("user_id IN ?", userIds[start:end]).Find(&tmp).Error if err != nil { @@ -85,7 +81,10 @@ func BatchGetVips(userIds []uint64) (map[uint64]*int64, error) { } start += 500 end += 500 - mylogrus.MyLog.Infof("BatchGetVips start:%v-end:%v", start, end) + if end > len(userIds) { + end = len(userIds) + } + //mylogrus.MyLog.Infof("BatchGetVips start:%v-end:%v", start, end) } for _, i := range userIds { diff --git a/domain/service/event_s/event_init.go b/domain/service/event_s/event_init.go index 2f7c3455c4a3ea19db06efb94e23ea491f8e8e25..c64d247bbec97f0a06711d946a6553a95f8a4659 100644 --- a/domain/service/event_s/event_init.go +++ b/domain/service/event_s/event_init.go @@ -10,11 +10,9 @@ import ( "git.hilo.cn/hilo-common/rpc" "git.hilo.cn/hilo-common/sdk/tencentyun" "hilo-group/_const/enum/gift_e" - "hilo-group/_const/enum/groupPower_e" "hilo-group/_const/enum/group_e" "hilo-group/_const/enum/msg_e" "hilo-group/_const/enum/task_e" - "hilo-group/domain/cache/groupPower_c" "hilo-group/domain/cache/group_c" "hilo-group/domain/event/gift_ev" "hilo-group/domain/event/group_ev" @@ -39,7 +37,7 @@ func EventInit() { GroupEvents() GroupImMass() GroupTheme() - SendGift() // 送礼事件 + //SendGift() // 送礼事件 OnMic() // 在麦上事件 GroupInMicChangeEvent() // 用户进房推送mic位置信息 } @@ -476,71 +474,72 @@ func FlushHiloInfo(extId string, isVip bool, isPrettyCode bool, medals []uint32, func SendGift() { // 送礼事件-势力经验 - gift_ev.AddSendGiftEventAsync(func(model *domain.Model, event interface{}) error { - sendGiftEvent, ok := event.(*gift_ev.SendGiftEvent) - if !ok { - model.Log.Errorf("AddSendGiftEventAsync event type err") - return nil - } - model.Log.Infof("AddSendGiftEventAsync %+v", sendGiftEvent) - if sendGiftEvent.ResGift.GiftType != mysql.DiamondYellow { - return nil - } - exist, groupPowerId, err := groupPower_m.CheckGroupPowerUser(model, sendGiftEvent.SendUserId) - if err != nil { - model.Log.Infof("CheckGroupPowerUser fail %+v", err) - return err - } - if exist { - exp := sendGiftEvent.GiftN * mysql.Num(len(sendGiftEvent.ReceiveUserIds)) * sendGiftEvent.ResGift.DiamondNum - //return model.Transaction(func(model *domain.Model) error { - // return groupPower_m.IncrGroupPowerExp(model, groupPowerId, exp, sendGiftEvent.SendUserId, "送礼") - //}) - return groupPower_c.QueueGroupPowerGradeExp(model, groupPowerId, exp, sendGiftEvent.SendUserId, "送礼") - } - return nil - }) + //gift_ev.AddSendGiftEventAsync(func(model *domain.Model, event interface{}) error { + // sendGiftEvent, ok := event.(*gift_ev.SendGiftEvent) + // if !ok { + // model.Log.Errorf("AddSendGiftEventAsync event type err") + // return nil + // } + // model.Log.Infof("AddSendGiftEventAsync %+v", sendGiftEvent) + // if sendGiftEvent.ResGift.GiftType != mysql.DiamondYellow { + // return nil + // } + // exist, groupPowerId, err := groupPower_m.CheckGroupPowerUser(model, sendGiftEvent.SendUserId) + // if err != nil { + // model.Log.Infof("CheckGroupPowerUser fail %+v", err) + // return err + // } + // if exist { + // exp := sendGiftEvent.GiftN * mysql.Num(len(sendGiftEvent.ReceiveUserIds)) * sendGiftEvent.ResGift.DiamondNum + // //return model.Transaction(func(model *domain.Model) error { + // // return groupPower_m.IncrGroupPowerExp(model, groupPowerId, exp, sendGiftEvent.SendUserId, "送礼") + // //}) + // return groupPower_c.QueueGroupPowerGradeExp(model, groupPowerId, exp, sendGiftEvent.SendUserId, "送礼") + // } + // return nil + //}) // 家族之星-送礼/收礼 - gift_ev.AddSendGiftEventAsync(func(model *domain.Model, event interface{}) error { - sendGiftEvent, ok := event.(*gift_ev.SendGiftEvent) - if !ok { - model.Log.Errorf("AddSendGiftEventAsync event type err") - return nil - } - if sendGiftEvent.ResGift.GiftType != mysql.DiamondYellow { - return nil - } - var userIds = []mysql.ID{sendGiftEvent.SendUserId} - userIds = append(userIds, sendGiftEvent.ReceiveUserIds...) - groupPowers, err := groupPower_m.BatchGetGroupPowerUser(model, userIds) - if err != nil { - model.Log.Errorf("AddSendGiftEventAsync fail:%v", err) - return err - } - // 送礼加分 - if data, ok := groupPowers[sendGiftEvent.SendUserId]; ok { - diamonds := sendGiftEvent.GiftN * sendGiftEvent.ResGift.DiamondNum * mysql.Num(len(sendGiftEvent.ReceiveUserIds)) - if err := groupPower_m.IncrGroupPowerMonthStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeFamous, diamonds, 0); err != nil { - model.Log.Errorf("IncrGroupPowerMonthStarScore famous fail:%v", err) - } - if err := groupPower_m.IncrGroupPowerDayStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeFamous, diamonds, 0); err != nil { - model.Log.Errorf("IncrGroupPowerDayStarScore famous fail:%v", err) - } - } - // 收礼加分 - for _, userId := range sendGiftEvent.ReceiveUserIds { - if data, ok := groupPowers[userId]; ok { - diamonds := sendGiftEvent.GiftN * sendGiftEvent.ResGift.DiamondNum - if err := groupPower_m.IncrGroupPowerMonthStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeCharm, diamonds, 0); err != nil { - model.Log.Errorf("IncrGroupPowerMonthStarScore charm fail:%v", err) - } - if err := groupPower_m.IncrGroupPowerDayStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeCharm, diamonds, 0); err != nil { - model.Log.Errorf("IncrGroupPowerDayStarScore charm fail:%v", err) - } - } - } - return nil - }) + //gift_ev.AddSendGiftEventAsync(func(model *domain.Model, event interface{}) error { + // sendGiftEvent, ok := event.(*gift_ev.SendGiftEvent) + // if !ok { + // model.Log.Errorf("AddSendGiftEventAsync event type err") + // return nil + // } + // if sendGiftEvent.ResGift.GiftType != mysql.DiamondYellow { + // return nil + // } + // var userIds = []mysql.ID{sendGiftEvent.SendUserId} + // userIds = append(userIds, sendGiftEvent.ReceiveUserIds...) + // groupPowers, err := groupPower_m.BatchGetGroupPowerUser(model, userIds) + // if err != nil { + // model.Log.Errorf("AddSendGiftEventAsync fail:%v", err) + // return err + // } + // // 送礼加分 + // if data, ok := groupPowers[sendGiftEvent.SendUserId]; ok { + // diamonds := sendGiftEvent.GiftN * sendGiftEvent.ResGift.DiamondNum * mysql.Num(len(sendGiftEvent.ReceiveUserIds)) + // if err := groupPower_m.IncrGroupPowerMonthStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeFamous, diamonds, 0); err != nil { + // model.Log.Errorf("IncrGroupPowerMonthStarScore famous fail:%v", err) + // } + // if err := groupPower_m.IncrGroupPowerDayStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeFamous, diamonds, 0); err != nil { + // model.Log.Errorf("IncrGroupPowerDayStarScore famous fail:%v", err) + // } + // } + // // 收礼加分 + // for _, userId := range sendGiftEvent.ReceiveUserIds { + // if data, ok := groupPowers[userId]; ok { + // diamonds := sendGiftEvent.GiftN * sendGiftEvent.ResGift.DiamondNum + // if err := groupPower_m.IncrGroupPowerMonthStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeCharm, diamonds, 0); err != nil { + // model.Log.Errorf("IncrGroupPowerMonthStarScore charm fail:%v", err) + // } + // if err := groupPower_m.IncrGroupPowerDayStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeCharm, diamonds, 0); err != nil { + // model.Log.Errorf("IncrGroupPowerDayStarScore charm fail:%v", err) + // } + // } + // } + // return nil + //}) + // 送礼事件-群组扶持数据累加 gift_ev.AddSendGiftEventAsync(func(model *domain.Model, event interface{}) error { if time.Now().Unix() < 1692964800 { // cwj---- diff --git a/route/group_r/group_info.go b/route/group_r/group_info.go index a71b61b7e14bd544e2ab53dfe6c1b884e670fe55..8cf0273b9d6d55bd1de8ea3d4ef4273ab08bd4f3 100644 --- a/route/group_r/group_info.go +++ b/route/group_r/group_info.go @@ -211,7 +211,7 @@ func GetTheirGroups(c *gin.Context) (*mycontext.MyContext, error) { if err != nil { return myContext, err } - model.Log.Infof("BuildJoinedGroupInfo, roomEnterTime: %v", roomEnterTime) + //model.Log.Infof("BuildJoinedGroupInfo, roomEnterTime: %v", roomEnterTime) // 正在进行的游戏 games := game_m.GetNotEndGamesMap(model) diff --git a/route/group_r/group_list.go b/route/group_r/group_list.go index cebe0a6c86225a5b93bbceb4d9a38583ae0b9520..bffc046c00b2ef3093e6261d5893791df20ab420 100644 --- a/route/group_r/group_list.go +++ b/route/group_r/group_list.go @@ -97,7 +97,8 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) { if err != nil { return myContext, err } - model.Log.Infof("GetPopularGroups: page size = %d, page index = %d, banMap %v, hidenMap %v,cost:%v", pageSize, pageIndex, bannedGroups, hiddenGroups, time.Now().Sub(start)) + gameGroups := group_m.GetGameGroupsMap(model) + //model.Log.Infof("GetPopularGroups: page size = %d, page index = %d, banMap %v, hidenMap %v,cost:%v", pageSize, pageIndex, bannedGroups, hiddenGroups, time.Now().Sub(start)) hotGroupList := make([]group_m.GroupInfo, 0) @@ -122,9 +123,13 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) { hiddenCount++ continue } + // 过滤掉游戏房 + if gameGroups[i] { + continue + } groupIds = append(groupIds, i) } - model.Log.Infof("GetPopularGroups, micGroupNum: %v, banned %d, hidden %d,cost:%v", micGroupNum, banCount, hiddenCount, time.Now().Sub(start)) + //model.Log.Infof("GetPopularGroups, micGroupNum: %v, banned %d, hidden %d,cost:%v", micGroupNum, banCount, hiddenCount, time.Now().Sub(start)) // 3. 处理置顶群 topGroupIds, err := getTopGroups(model, bannedGroups, hiddenGroups, area) @@ -197,7 +202,7 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) { } } } - model.Log.Infof("GetPopularGroups, countryScore[*]: %v,cost:%v", countryScore, time.Now().Sub(start)) + //model.Log.Infof("GetPopularGroups, countryScore[*]: %v,cost:%v", countryScore, time.Now().Sub(start)) now := time.Now() bTime := now.Add(-time.Minute * 30) @@ -206,7 +211,7 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) { if err != nil { return myContext, err } - model.Log.Infof("GetPopularGroups, diamonds in 30 mins: %v,cost:%v", diamonds, time.Now().Sub(start)) + //model.Log.Infof("GetPopularGroups, diamonds in 30 mins: %v,cost:%v", diamonds, time.Now().Sub(start)) visitCount, err := group_m.BatchGetRoomVisitCount(model.Log, groupIds) if err != nil { @@ -270,7 +275,7 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) { // ":" + strconv.FormatUint(diamonds[g], 10) + ":" + strconv.Itoa(int(visitCount[g])) } total := len(hotGroupList) - model.Log.Infof("GetPopularGroups: hotGroupList size = %d,cost:%v", total, time.Now().Sub(start)) + //model.Log.Infof("GetPopularGroups: hotGroupList size = %d,cost:%v", total, time.Now().Sub(start)) result := make([]group_cv.PopularGroupInfo, 0) @@ -304,7 +309,7 @@ func GetPopularGroups(c *gin.Context) (*mycontext.MyContext, error) { //if err != nil { // return myContext, err //} - model.Log.Infof("GetPopularGroups: final start = %d, end = %d, groupIds %v,cost:%v", beginPos, endPos, groupIds, time.Now().Sub(start)) + //model.Log.Infof("GetPopularGroups: final start = %d, end = %d, groupIds %v,cost:%v", beginPos, endPos, groupIds, time.Now().Sub(start)) roomCount, err := group_m.BatchGetRoomCount(model, groupIds) if err != nil { @@ -471,9 +476,13 @@ func GetLatestGroups(c *gin.Context) (*mycontext.MyContext, error) { if err != nil { return myContext, err } - + gameGroups := group_m.GetGameGroupsMap(model) gids := make([]string, 0) for i, _ := range micGroupNum { + // 过滤游戏房 + if gameGroups[i] { + continue + } gids = append(gids, i) } // 获取最新群组列表 @@ -848,7 +857,7 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) { if err != nil { return myContext, err } - model.Log.Infof("GetGroupVisitors %s: memberNum = %d, user size = %d", groupId, len(rows), len(userIds)) + //model.Log.Infof("GetGroupVisitors %s: memberNum = %d, user size = %d", groupId, len(rows), len(userIds)) result := GetGroupVisitorsRsp{Total: uint(len(userIds))} @@ -870,7 +879,7 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) { result.Online++ } } - model.Log.Infof("GetGroupVisitors %s: statusMap size = %d, onLine = %d", groupId, len(statusMap), result.Online) + //model.Log.Infof("GetGroupVisitors %s: statusMap size = %d, onLine = %d", groupId, len(statusMap), result.Online) roles, _, err := group_m.GetRolesInGroup(model, groupId) if err != nil { @@ -891,7 +900,7 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) { return myContext, err } - model.Log.Infof("GetGroupVisitors %s, users %v, roles: %v, nobles: %v, vips: %v", groupId, userIds, roles, nobleLevels, vips) + //model.Log.Infof("GetGroupVisitors %s, users %v, roles: %v, nobles: %v, vips: %v", groupId, userIds, roles, nobleLevels, vips) roomUsers, err := group_m.RoomLivingExistsUserId(groupId) if err != nil { @@ -946,7 +955,7 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) { return false }) - model.Log.Infof("GetGroupVisitors %s, sorted users: %v", groupId, userIds) + //model.Log.Infof("GetGroupVisitors %s, sorted users: %v", groupId, userIds) endPos := pageSize * pageIndex if endPos > len(userIds) { @@ -1239,7 +1248,7 @@ func GetGroupByCountry(c *gin.Context) (*mycontext.MyContext, error) { return myContext, err } - model.Log.Infof("GetGroupByCountry: page size = %d, page index = %d, banMap %v", pageSize, pageIndex, bannedGroups) + //model.Log.Infof("GetGroupByCountry: page size = %d, page index = %d, banMap %v", pageSize, pageIndex, bannedGroups) beginTime := time.Now() groups, banCount, visitCount, err := getCandidatesByCountry(model, bannedGroups, countryShortName) @@ -1249,7 +1258,7 @@ func GetGroupByCountry(c *gin.Context) (*mycontext.MyContext, error) { endTime := time.Now() model.Log.Infof("GetGroupByCountry: candidates size = %d, takes %d ms banned = %d, visitCount size = %d", len(groups), endTime.Sub(beginTime).Milliseconds(), banCount, len(visitCount)) - model.Log.Infof("GetGroupByCountry cost1:%v", time.Now().Sub(beginTime)) + //model.Log.Infof("GetGroupByCountry cost1:%v", time.Now().Sub(beginTime)) hotGroupList := make([]*group_m.GroupInfo, 0) diff --git a/test/user_test.go b/test/user_test.go index b4310b7432bdb10acb303a19742a33a31f447bdb..8fbd3b8b589d79af4ddbfc3aeeeb6eea37e72689 100644 --- a/test/user_test.go +++ b/test/user_test.go @@ -18,7 +18,7 @@ func TestGetUserMap(t *testing.T) { func TestGetUserVipMap(t *testing.T) { var userIds []uint64 - for i := 0; i < 1500; i++ { + for i := 0; i < 10502; i++ { userIds = append(userIds, 7642) } res, err := user_m.BatchGetVips(userIds)