Commit 1bc7c692 authored by chenweijian's avatar chenweijian

Merge remote-tracking branch 'origin/master' into feature/dominoes

parents 03cbde0f 17462cb3
......@@ -9,7 +9,7 @@ import (
const (
UserEnterRoomPrefix = "uer:"
UserEnterRoomUserKey = UserEnterRoomPrefix + "u:${user_id}"
UserEnterRoomGroupKey = UserEnterRoomPrefix + "g:${user_id}"
UserEnterRoomGroupKey = UserEnterRoomPrefix + "g:${group_id}"
)
func GetUserEnterRoomUserKey(userId uint64) string {
......
......@@ -27,6 +27,8 @@ func OnMicCheck() {
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,
......
......@@ -28,6 +28,7 @@ func ZAddUserEnterRoom(model *domain.Model, userId uint64, imGroupId string) {
}
// 获取最近房间访客
// 15天
func GetLastRoomVisitors(model *domain.Model, imGroupId string) (userIds []uint64) {
groupKey := group_k.GetUserEnterRoomGroupKey(imGroupId)
res, err := model.Redis.ZRangeByScore(model, groupKey, &redis.ZRangeBy{
......@@ -47,11 +48,12 @@ func GetLastRoomVisitors(model *domain.Model, imGroupId string) (userIds []uint6
}
// 获取最近进入的房间
// 3个月
func GetUserRecentRooms(model *domain.Model, userId uint64) (imGroupIds []string) {
userKey := group_k.GetUserEnterRoomUserKey(userId)
var err error
imGroupIds, err = model.Redis.ZRangeByScore(model, userKey, &redis.ZRangeBy{
Min: fmt.Sprintf("%d", time.Now().AddDate(0, 0, -15).Unix()),
Min: fmt.Sprintf("%d", time.Now().AddDate(0, -3, 0).Unix()),
Max: "+inf",
}).Result()
if err != nil {
......@@ -64,8 +66,10 @@ func GetUserRecentRooms(model *domain.Model, userId uint64) (imGroupIds []string
// 15天前访问的
func RemoveRoomVisitors(model *domain.Model, imGroupId string) {
groupKey := group_k.GetUserEnterRoomGroupKey(imGroupId)
err := model.Redis.ZRemRangeByScore(model, groupKey, "-inf", fmt.Sprintf("%d", time.Now().AddDate(0, 0, -15).Unix())).Err()
n, err := model.Redis.ZRemRangeByScore(model, groupKey, "-inf", fmt.Sprintf("%d", time.Now().AddDate(0, 0, -15).Unix())).Result()
if err != nil {
model.Log.Errorf("RemoveRoomVisitors fail:%v", err)
} else {
model.Log.Infof("RemoveRoomVisitors key:%v,n:%v", groupKey, n)
}
}
......@@ -127,6 +127,40 @@ func (g *GiftOperate) GetConsumeByRange(beginTime, endTime time.Time) (uint32, u
if len(rows) <= 0 {
return 0, 0, nil
}
if beginTime.Unix() >= 1691337600 && beginTime.Unix() < 1691942400 { // 因为这周水果机被部分人刷币,所以这里做了特殊的处理
reduceMap := map[string]uint64{
"HTGS#a63226380": 20000000,
//"HTGS#a42641278": 10000000,
"@TGS#3ZZ5GZLHA": 27141539,
"HTGS#a81630128": 8955410,
"HTGS#a42300598": 50211301,
"HTGS#a40088696": 10000000,
"HTGS#a21700997": 14352310,
"HTGS#a83608384": 49644203,
"@TGS#33GDXTSIH": 50000000,
"HTGS#a50538513": 15000000,
"HTGS#a77282385": 15000000,
"HTGS#a59437326": 10000000,
"HTGS#a16909405": 10000000,
"HTGS#a44104431": 16861206,
"HTGS#a56794634": 59591313,
"HTGS#a11286025": 31232311,
"HTGS#a17238550": 52309338,
"HTGS#a83592361": 79545067,
"HTGS#a39882521": 10255093,
}
if reduceNum, ok := reduceMap[g.SceneUid]; ok {
if g.Log != nil {
g.Log.Infof("fruit diamond reduceMap,groupId:%v,reduceNum:%v", g.SceneUid, reduceNum)
}
if rows[0].Consume >= reduceNum {
rows[0].Consume -= reduceNum
} else {
rows[0].Consume = 0
}
}
}
return rows[0].C, rows[0].Consume, nil
}
......
......@@ -16,6 +16,7 @@ import (
"hilo-group/cv/group_power_cv"
"hilo-group/cv/medal_cv"
"hilo-group/cv/user_cv"
"hilo-group/domain/cache/group_c"
"hilo-group/domain/cache/res_c"
"hilo-group/domain/cache/room_c"
"hilo-group/domain/model/game_m"
......@@ -703,11 +704,12 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) {
model := domain.CreateModelContext(myContext)
uer := group_m.UserEnterRoom{UserId: userId}
rec, err := uer.Find(model.Db)
if err != nil {
return myContext, err
}
//uer := group_m.UserEnterRoom{UserId: userId}
//rec, err := uer.Find(model.Db)
//if err != nil {
// return myContext, err
//}
rec := group_c.GetUserRecentRooms(model, userId)
myGroups, err := group_m.FindGroupMapByOwner(model, userId)
if err != nil {
......@@ -716,9 +718,9 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) {
// 剔除自己创建的群
groupIds := make([]string, 0)
for _, i := range rec {
if _, ok := myGroups[i.GroupId]; !ok {
groupIds = append(groupIds, i.GroupId)
for _, groupId := range rec {
if _, ok := myGroups[groupId]; !ok {
groupIds = append(groupIds, groupId)
}
}
......@@ -827,19 +829,20 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) {
return myContext, err
}
uer := group_m.UserEnterRoom{GroupId: groupId}
rows, err := uer.Find(model.Db)
if err != nil {
return myContext, err
}
//uer := group_m.UserEnterRoom{GroupId: groupId}
//rows, err := uer.Find(model.Db)
//if err != nil {
// return myContext, err
//}
rows := group_c.GetLastRoomVisitors(model, groupId)
now := time.Now()
t := now.AddDate(0, 0, -15) // 只要15天内进入房间的人
//now := time.Now()
//t := now.AddDate(0, 0, -15) // 只要15天内进入房间的人
userIds := make([]uint64, 0)
for _, i := range rows {
if i.EnterTime.After(t) {
userIds = append(userIds, i.UserId)
}
for _, u := range rows {
//if i.EnterTime.After(t) {
userIds = append(userIds, u)
//}
}
users, err := user_m.GetUserMapByIds(model, userIds)
if err != nil {
......@@ -970,6 +973,8 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) {
}
}
resp.ResponseOk(c, result)
// 清理15天之前的访客
group_c.RemoveRoomVisitors(model, groupId)
return myContext, nil
}
......
......@@ -1858,6 +1858,10 @@ func GroupIn(c *gin.Context) (*mycontext.MyContext, error) {
if groupId == "HTGS#a93989299" {
provider = group_e.GroupProvider_TRTC
}
// 指定房间号写死sw
if groupId == "HTGS#a25015185" {
provider = group_e.GroupProvider_SW
}
if channelId, token, err := group_s.NewGroupService(myContext).GroupIn(userId, externalId, groupId, password, imei, ip, provider, gi.Id); err != nil {
return myContext, err
......
......@@ -2,6 +2,7 @@ package test
import (
"git.hilo.cn/hilo-common/domain"
"hilo-group/domain/cache/group_c"
"hilo-group/domain/model/user_m"
"testing"
)
......@@ -23,3 +24,7 @@ func TestGetUserVipMap(t *testing.T) {
res, err := user_m.BatchGetVips(userIds)
t.Logf("%v-%v", res, err)
}
func TestRemoveRoomVisit(t *testing.T) {
group_c.RemoveRoomVisitors(domain.CreateModelNil(), "HTGS#a47478749")
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment