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
1bc7c692
Commit
1bc7c692
authored
Aug 16, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into feature/dominoes
parents
03cbde0f
17462cb3
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
76 additions
and
22 deletions
+76
-22
enter_room.go
_const/redis_key/group_k/enter_room.go
+1
-1
on_mic.go
cron/mic_cron/on_mic.go
+2
-0
enter_room.go
domain/cache/group_c/enter_room.go
+6
-2
gift.go
domain/model/gift_m/gift.go
+34
-0
group_list.go
route/group_r/group_list.go
+24
-19
group_op.go
route/group_r/group_op.go
+4
-0
user_test.go
test/user_test.go
+5
-0
No files found.
_const/redis_key/group_k/enter_room.go
View file @
1bc7c692
...
...
@@ -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
{
...
...
cron/mic_cron/on_mic.go
View file @
1bc7c692
...
...
@@ -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
,
...
...
domain/cache/group_c/enter_room.go
View file @
1bc7c692
...
...
@@ -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
)
}
}
domain/model/gift_m/gift.go
View file @
1bc7c692
...
...
@@ -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
}
...
...
route/group_r/group_list.go
View file @
1bc7c692
...
...
@@ -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
.
G
roupId
];
!
ok
{
groupIds
=
append
(
groupIds
,
i
.
G
roupId
)
for
_
,
groupId
:=
range
rec
{
if
_
,
ok
:=
myGroups
[
g
roupId
];
!
ok
{
groupIds
=
append
(
groupIds
,
g
roupId
)
}
}
...
...
@@ -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
}
...
...
route/group_r/group_op.go
View file @
1bc7c692
...
...
@@ -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
...
...
test/user_test.go
View file @
1bc7c692
...
...
@@ -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"
)
}
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