Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-group
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-group
Commits
a3e5bd4f
Commit
a3e5bd4f
authored
Aug 23, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Plain Diff
group support
parents
af6580c8
2cc919d6
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
279 additions
and
119 deletions
+279
-119
cron.go
cron/cron.go
+5
-4
send_gift_redis.go
cron/gift_cron/send_gift_redis.go
+90
-0
on_mic.go
cron/mic_cron/on_mic.go
+1
-3
group.go
cv/group_cv/group.go
+14
-3
gift_event.go
domain/cache/gift_c/gift_event.go
+34
-0
userRoomVisit.go
domain/cache/room_c/userRoomVisit.go
+1
-1
group_rank.go
domain/model/groupPower_m/group_rank.go
+2
-1
factory.go
domain/model/group_m/factory.go
+2
-2
groupGame.go
domain/model/group_m/groupGame.go
+17
-0
mic.go
domain/model/group_m/mic.go
+4
-3
room.go
domain/model/group_m/room.go
+4
-4
userNoble.go
domain/model/noble_m/userNoble.go
+2
-2
user.go
domain/model/tim_m/user.go
+1
-1
medal.go
domain/model/user_m/medal.go
+2
-2
user.go
domain/model/user_m/user.go
+5
-5
vip.go
domain/model/user_m/vip.go
+5
-6
event_init.go
domain/service/event_s/event_init.go
+66
-67
group_info.go
route/group_r/group_info.go
+1
-1
group_list.go
route/group_r/group_list.go
+22
-13
user_test.go
test/user_test.go
+1
-1
No files found.
cron/cron.go
View file @
a3e5bd4f
...
...
@@ -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
()
// 群组扶持计算
}
cron/gift_cron/send_gift_redis.go
0 → 100644
View file @
a3e5bd4f
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
}
cron/mic_cron/on_mic.go
View file @
a3e5bd4f
...
...
@@ -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
,
...
...
cv/group_cv/group.go
View file @
a3e5bd4f
...
...
@@ -251,13 +251,24 @@ type CvCountry struct {
AreaCodeName
*
string
`json:"areaShortName"`
}
func
BuildJoinedGroupInfo
(
myService
*
domain
.
Service
,
myUserId
uint64
,
g
roupIds
[]
string
,
pageSize
,
pageIndex
int
)
([]
JoinedGroupInfo
,
int
,
error
)
{
func
BuildJoinedGroupInfo
(
myService
*
domain
.
Service
,
myUserId
uint64
,
originG
roupIds
[]
string
,
pageSize
,
pageIndex
int
)
([]
JoinedGroupInfo
,
int
,
error
)
{
model
:=
domain
.
CreateModel
(
myService
.
CtxAndDb
)
groupInfo
,
err
:=
group_m
.
BatchGetGroupInfo
(
model
,
g
roupIds
)
groupInfo
,
err
:=
group_m
.
BatchGetGroupInfo
(
model
,
originG
roupIds
)
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
{
...
...
domain/cache/gift_c/gift_event.go
0 → 100644
View file @
a3e5bd4f
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
}
domain/cache/room_c/userRoomVisit.go
View file @
a3e5bd4f
...
...
@@ -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
{
...
...
domain/model/groupPower_m/group_rank.go
View file @
a3e5bd4f
...
...
@@ -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
)
...
...
domain/model/group_m/factory.go
View file @
a3e5bd4f
...
...
@@ -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
()
...
...
domain/model/group_m/groupGame.go
0 → 100644
View file @
a3e5bd4f
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
}
domain/model/group_m/mic.go
View file @
a3e5bd4f
...
...
@@ -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
}
...
...
domain/model/group_m/room.go
View file @
a3e5bd4f
...
...
@@ -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
)
...
...
domain/model/noble_m/userNoble.go
View file @
a3e5bd4f
...
...
@@ -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
)
}
...
...
domain/model/tim_m/user.go
View file @
a3e5bd4f
...
...
@@ -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
{
...
...
domain/model/user_m/medal.go
View file @
a3e5bd4f
...
...
@@ -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
)
...
...
domain/model/user_m/user.go
View file @
a3e5bd4f
...
...
@@ -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
...
...
domain/model/user_m/vip.go
View file @
a3e5bd4f
...
...
@@ -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
{
...
...
domain/service/event_s/event_init.go
View file @
a3e5bd4f
...
...
@@ -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, "送礼")
//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
//})
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----
...
...
route/group_r/group_info.go
View file @
a3e5bd4f
...
...
@@ -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
)
...
...
route/group_r/group_list.go
View file @
a3e5bd4f
...
...
@@ -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
)
...
...
test/user_test.go
View file @
a3e5bd4f
...
...
@@ -18,7 +18,7 @@ func TestGetUserMap(t *testing.T) {
func
TestGetUserVipMap
(
t
*
testing
.
T
)
{
var
userIds
[]
uint64
for
i
:=
0
;
i
<
1
500
;
i
++
{
for
i
:=
0
;
i
<
1
0502
;
i
++
{
userIds
=
append
(
userIds
,
7642
)
}
res
,
err
:=
user_m
.
BatchGetVips
(
userIds
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment