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
3717f457
Commit
3717f457
authored
Aug 28, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into fix/group_country
parents
72b685e0
3f4af9eb
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
48 additions
and
72 deletions
+48
-72
send_gift_redis.go
cron/gift_cron/send_gift_redis.go
+0
-6
group.go
cv/group_cv/group.go
+4
-1
group_power_star.go
domain/cache/groupPower_c/group_power_star.go
+5
-1
enter_room.go
domain/cache/group_c/enter_room.go
+9
-3
userRoomVisit.go
domain/cache/room_c/userRoomVisit.go
+3
-1
group_grade.go
domain/model/groupPower_m/group_grade.go
+0
-50
group_star.go
domain/model/groupPower_m/group_star.go
+2
-0
user.go
domain/model/tim_m/user.go
+0
-2
group_mic.go
domain/service/group_mic_s/group_mic.go
+1
-5
group_power.go
domain/service/group_power_s/group_power.go
+7
-1
group_list.go
route/group_r/group_list.go
+2
-2
group_power_test.go
test/group_power_test.go
+13
-0
local.ini
test/local.ini
+2
-0
No files found.
cron/gift_cron/send_gift_redis.go
View file @
3717f457
...
...
@@ -75,9 +75,6 @@ func groupPowerStar(model *domain.Model, sendGiftEvent *gift_ev.SendGiftEvent) {
// 送礼加分
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_c
.
IncrGroupPowerDayStarScore
(
model
,
data
.
GroupPowerId
,
data
.
UserId
,
groupPower_e
.
GroupPowerStarTypeFamous
,
diamonds
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"IncrGroupPowerDayStarScore famous fail:%v"
,
err
)
...
...
@@ -87,9 +84,6 @@ func groupPowerStar(model *domain.Model, sendGiftEvent *gift_ev.SendGiftEvent) {
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_c
.
IncrGroupPowerDayStarScore
(
model
,
data
.
GroupPowerId
,
data
.
UserId
,
groupPower_e
.
GroupPowerStarTypeCharm
,
diamonds
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"IncrGroupPowerDayStarScore charm fail:%v"
,
err
)
...
...
cv/group_cv/group.go
View file @
3717f457
...
...
@@ -251,7 +251,7 @@ type CvCountry struct {
AreaCodeName
*
string
`json:"areaShortName"`
}
func
BuildJoinedGroupInfo
(
myService
*
domain
.
Service
,
myUserId
uint64
,
originGroupIds
[]
string
,
pageSize
,
pageIndex
int
)
([]
JoinedGroupInfo
,
int
,
error
)
{
func
BuildJoinedGroupInfo
(
myService
*
domain
.
Service
,
myUserId
uint64
,
originGroupIds
[]
string
,
pageSize
,
pageIndex
int
,
_roomEnterTime
...
map
[
string
]
int64
)
([]
JoinedGroupInfo
,
int
,
error
)
{
model
:=
domain
.
CreateModel
(
myService
.
CtxAndDb
)
groupInfo
,
err
:=
group_m
.
BatchGetGroupInfo
(
model
,
originGroupIds
)
...
...
@@ -321,6 +321,9 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, originGrou
if
err
!=
nil
{
return
nil
,
0
,
err
}
if
len
(
_roomEnterTime
)
>
0
{
roomEnterTime
=
_roomEnterTime
[
0
]
}
//model.Log.Infof("BuildJoinedGroupInfo, roomEnterTime: %v", roomEnterTime)
// 排序优先级V8.0版本
...
...
domain/cache/groupPower_c/group_power_star.go
View file @
3717f457
...
...
@@ -47,7 +47,8 @@ func IncrGroupPowerDayStarScore(model *domain.Model, groupPowerId, userId mysql.
}
// 获取家族之星排行
func
GetGroupPowerStarRankPeriod
(
model
*
domain
.
Model
,
period
string
,
groupPowerId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
offset
,
limit
int
)
([]
*
GroupPowerStarRank
,
error
)
{
// param period: day|week|month
func
GetGroupPowerStarRankPeriod
(
model
*
domain
.
Model
,
period
string
,
groupPowerId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
offset
,
limit
int
,
targetDate
...
string
)
([]
*
GroupPowerStarRank
,
error
)
{
var
res
[]
*
GroupPowerStarRank
date
:=
""
switch
period
{
...
...
@@ -61,6 +62,9 @@ func GetGroupPowerStarRankPeriod(model *domain.Model, period string, groupPowerI
if
len
(
date
)
<=
0
{
return
res
,
errors
.
New
(
"illegal date"
)
}
if
len
(
targetDate
)
>
0
{
date
=
targetDate
[
0
]
}
key
:=
groupPower_k
.
GetGroupPowerStarRankKey
(
_type
,
period
,
groupPowerId
,
date
)
rows
,
err
:=
model
.
RedisCluster
.
ZRevRangeByScoreWithScores
(
model
,
key
,
&
redis
.
ZRangeBy
{
Min
:
"-inf"
,
...
...
domain/cache/group_c/enter_room.go
View file @
3717f457
...
...
@@ -4,6 +4,7 @@ import (
"fmt"
"git.hilo.cn/hilo-common/domain"
"github.com/go-redis/redis/v8"
"github.com/spf13/cast"
"hilo-group/_const/redis_key/group_k"
"strconv"
"time"
...
...
@@ -49,16 +50,21 @@ func GetLastRoomVisitors(model *domain.Model, imGroupId string) (userIds []uint6
// 获取最近进入的房间
// 3个月
func
GetUserRecentRooms
(
model
*
domain
.
Model
,
userId
uint64
)
(
imGroupIds
[]
string
)
{
func
GetUserRecentRooms
(
model
*
domain
.
Model
,
userId
uint64
)
(
imGroupIds
[]
string
,
roomEnterTime
map
[
string
]
int64
)
{
roomEnterTime
=
make
(
map
[
string
]
int64
)
userKey
:=
group_k
.
GetUserEnterRoomUserKey
(
userId
)
var
err
error
imGroupIds
,
err
=
model
.
Redis
.
ZRangeByScore
(
model
,
userKey
,
&
redis
.
ZRangeBy
{
res
,
err
:=
model
.
Redis
.
ZRangeByScoreWithScores
(
model
,
userKey
,
&
redis
.
ZRangeBy
{
Min
:
fmt
.
Sprintf
(
"%d"
,
time
.
Now
()
.
AddDate
(
0
,
-
3
,
0
)
.
Unix
()),
Max
:
"+inf"
,
})
.
Result
()
if
err
!=
nil
{
return
}
for
_
,
v
:=
range
res
{
imGroupId
:=
cast
.
ToString
(
v
.
Member
)
imGroupIds
=
append
(
imGroupIds
,
imGroupId
)
roomEnterTime
[
imGroupId
]
=
int64
(
v
.
Score
)
}
return
}
...
...
domain/cache/room_c/userRoomVisit.go
View file @
3717f457
...
...
@@ -59,7 +59,10 @@ func ProcessUserRoomVisit(userId uint64, groupId string) error {
}
// 查询用户访问过的房间及其时间
// todo 去掉查询,redis性能
func
GetUserRoomVisit
(
userId
uint64
)
(
map
[
string
]
int64
,
error
)
{
result
:=
make
(
map
[
string
]
int64
,
0
)
return
result
,
nil
key
:=
redis_key
.
GetUserEnterRoomKey
(
userId
)
ret
,
err
:=
redisCli
.
GetRedis
()
.
ZRangeWithScores
(
context
.
Background
(),
key
,
0
,
-
1
)
.
Result
()
if
err
!=
nil
{
...
...
@@ -67,7 +70,6 @@ func GetUserRoomVisit(userId uint64) (map[string]int64, error) {
}
//mylogrus.MyLog.Infof("GetUserRoomVisit, ZRangeWithScores %s, return %v", key, ret)
result
:=
make
(
map
[
string
]
int64
,
0
)
for
_
,
i
:=
range
ret
{
result
[
i
.
Member
.
(
string
)]
=
int64
(
i
.
Score
)
}
...
...
domain/model/groupPower_m/group_grade.go
View file @
3717f457
...
...
@@ -154,56 +154,6 @@ func IncrGroupPowerExpOnMic(model *domain.Model, groupPowerId, userId mysql.ID)
return
nil
}
// 增加势力上麦时长-家族之星
// 事务操作
func
IncrGroupPowerStarOnMicMonth
(
model
*
domain
.
Model
,
groupPowerId
,
userId
mysql
.
ID
,
joinMicTimestamp
int64
)
error
{
// 月统计
//star, err := GetGroupPowerMonthStar(model, groupPowerId, userId, groupPower_e.GroupPowerStarTypeActive)
//curTs := joinMicTimestamp
//nowTs := time.Now().Unix()
//month0Ts := now.BeginningOfMonth().Unix()
//if err != nil && err != gorm.ErrRecordNotFound {
// return err
//}
//if star != nil && joinMicTimestamp < star.LastCalTs { // 加入的时间比上次计算时间小
// curTs = star.LastCalTs
//}
//// 跨月
//if curTs < month0Ts {
// curTs = month0Ts
//}
//score := nowTs - curTs
score
:=
60
err
:=
IncrGroupPowerMonthStarScore
(
model
,
groupPowerId
,
userId
,
groupPower_e
.
GroupPowerStarTypeActive
,
mysql
.
Num
(
score
),
0
)
return
err
}
// 增加势力上麦时长-家族之星
// 事务操作
func
IncrGroupPowerStarOnMicDay
(
model
*
domain
.
Model
,
groupPowerId
,
userId
mysql
.
ID
,
joinMicTimestamp
int64
)
error
{
// 日统计
//star, err := GetGroupPowerDayStar(model, groupPowerId, userId, groupPower_e.GroupPowerStarTypeActive)
//curTs := joinMicTimestamp
//nowTs := time.Now().Unix()
//day0Ts := now.BeginningOfDay().Unix()
//if err != nil && err != gorm.ErrRecordNotFound {
// return err
//}
//if star != nil && joinMicTimestamp < star.LastCalTs { // 加入的时间比上次计算时间小
// curTs = star.LastCalTs
//}
//// 跨天
//if curTs < day0Ts {
// curTs = day0Ts
//}
//score := nowTs - curTs
score
:=
60
err
:=
IncrGroupPowerDayStarScore
(
model
,
groupPowerId
,
userId
,
groupPower_e
.
GroupPowerStarTypeActive
,
mysql
.
Num
(
score
),
0
)
return
err
}
// 清理所有家族的经验
func
ClearGroupPowerExp
(
model
*
domain
.
Model
)
error
{
var
groupPowerGrades
[]
*
GroupPowerGrade
...
...
domain/model/groupPower_m/group_star.go
View file @
3717f457
...
...
@@ -35,6 +35,7 @@ type GroupPowerDayStar struct {
}
// 增加家族之星分数
// Deprecated: 用redis
func
IncrGroupPowerMonthStarScore
(
model
*
domain
.
Model
,
groupPowerId
,
userId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
score
mysql
.
Num
,
lastCalTs
int64
)
error
{
month
:=
time
.
Now
()
.
Format
(
"200601"
)
star
:=
&
GroupPowerMonthStar
{
...
...
@@ -83,6 +84,7 @@ func IncrGroupPowerDayStarScore(model *domain.Model, groupPowerId, userId mysql.
}
// 获取家族之星排行
// Deprecated: 用redis
func
GetGroupPowerMonthStarRank
(
model
*
domain
.
Model
,
groupPowerId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
offset
,
limit
int
,
month
string
)
([]
*
GroupPowerMonthStar
,
error
)
{
var
res
[]
*
GroupPowerMonthStar
//month := time.Now().Format("200601")
...
...
domain/model/tim_m/user.go
View file @
3717f457
...
...
@@ -319,8 +319,6 @@ func SendGroupInvitationShare(model *domain.Model, fromAccount string, toAccount
func
GetOnlineStatus
(
model
*
domain
.
Model
,
extIds
[]
string
)
(
map
[
string
]
uint
,
error
)
{
left
:=
make
([]
string
,
0
)
result
:=
make
(
map
[
string
]
uint
,
0
)
// todo
return
result
,
nil
r
,
err
:=
getOnlineStatus
(
extIds
)
if
err
!=
nil
{
...
...
domain/service/group_mic_s/group_mic.go
View file @
3717f457
...
...
@@ -322,11 +322,7 @@ func (s *GroupMicService) IncrGroupPowerOnMicExpAndTime(groupId string, userId u
if
err
:=
groupPower_m
.
IncrGroupPowerExpOnMic
(
model
,
groupPowerId
,
userId
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"IncrGroupPowerExpOnMic fail:%v"
,
err
)
}
// 增加势力上麦时长-月
if
err
:=
groupPower_m
.
IncrGroupPowerStarOnMicMonth
(
model
,
groupPowerId
,
userId
,
joinMicTimestamp
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"IncrGroupPowerStarOnMicMonth fail:%v"
,
err
)
}
// 增加势力上麦时长-天
// 增加势力上麦时长-天/周/月
//if err := groupPower_m.IncrGroupPowerStarOnMicDay(model, groupPowerId, userId, joinMicTimestamp); err != nil {
if
err
:=
groupPower_c
.
IncrGroupPowerDayStarScore
(
model
,
groupPowerId
,
userId
,
groupPower_e
.
GroupPowerStarTypeActive
,
60
);
err
!=
nil
{
...
...
domain/service/group_power_s/group_power.go
View file @
3717f457
...
...
@@ -13,6 +13,7 @@ import (
"hilo-group/_const/enum/msg_e"
"hilo-group/cv/group_power_cv"
"hilo-group/cv/user_cv"
"hilo-group/domain/cache/groupPower_c"
"hilo-group/domain/cache/user_c"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/model/groupPower_m"
...
...
@@ -154,7 +155,12 @@ func GetGroupPowerRankResp(model *domain.Model, beginDate, endDate string, userI
}
func
GetGroupPowerStar
(
model
*
domain
.
Model
,
groupPowerId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
offset
,
limit
int
,
month
string
)
([]
*
group_power_cv
.
CvGroupPowerStarData
,
error
)
{
rank
,
err
:=
groupPower_m
.
GetGroupPowerMonthStarRank
(
model
,
groupPowerId
,
_type
,
offset
,
limit
,
month
)
monthTime
,
err
:=
time
.
Parse
(
"200601"
,
month
)
if
err
!=
nil
{
return
nil
,
err
}
//rank, err := groupPower_m.GetGroupPowerMonthStarRank(model, groupPowerId, _type, offset, limit, month)
rank
,
err
:=
groupPower_c
.
GetGroupPowerStarRankPeriod
(
model
,
"month"
,
groupPowerId
,
_type
,
offset
,
limit
,
monthTime
.
Format
(
"2006-01-02"
))
if
err
!=
nil
{
return
nil
,
err
}
...
...
route/group_r/group_list.go
View file @
3717f457
...
...
@@ -720,7 +720,7 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) {
//if err != nil {
// return myContext, err
//}
rec
:=
group_c
.
GetUserRecentRooms
(
model
,
userId
)
rec
,
roomEnterTime
:=
group_c
.
GetUserRecentRooms
(
model
,
userId
)
myGroups
,
err
:=
group_m
.
FindGroupMapByOwner
(
model
,
userId
)
if
err
!=
nil
{
...
...
@@ -736,7 +736,7 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) {
}
myService
:=
domain
.
CreateService
(
myContext
)
result
,
_
,
err
:=
group_cv
.
BuildJoinedGroupInfo
(
myService
,
userId
,
groupIds
,
30
,
1
)
result
,
_
,
err
:=
group_cv
.
BuildJoinedGroupInfo
(
myService
,
userId
,
groupIds
,
30
,
1
,
roomEnterTime
)
if
err
!=
nil
{
return
myContext
,
err
}
...
...
test/group_power_test.go
View file @
3717f457
...
...
@@ -3,8 +3,10 @@ package test
import
(
"fmt"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/redisCli"
"git.hilo.cn/hilo-common/utils"
"github.com/jinzhu/now"
"hilo-group/domain/cache/groupPower_c"
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/group_m"
"hilo-group/domain/service/group_power_s"
...
...
@@ -69,3 +71,14 @@ func TestGetRandomImProvider(t *testing.T) {
fmt
.
Printf
(
"true--------------times0:%v
\n
"
,
times0
)
fmt
.
Printf
(
"true--------------times1:%v
\n
"
,
times1
)
}
func
TestMonthStar
(
t
*
testing
.
T
)
{
monthTime
,
err
:=
time
.
Parse
(
"200601"
,
"202307"
)
if
err
!=
nil
{
panic
(
err
)
}
redisCli
.
InitCluster
()
res
,
err
:=
groupPower_c
.
GetGroupPowerStarRankPeriod
(
domain
.
CreateModelNil
(),
"month"
,
242
,
1
,
0
,
10
,
monthTime
.
Format
(
"2006-01-02"
))
println
(
res
)
println
(
err
)
}
test/local.ini
View file @
3717f457
...
...
@@ -11,6 +11,8 @@ MYSQL_DB=hilo_code
[REDIS]
REDIS_HOST
=
47.244.34.27:6379
REDIS_PASSWORD
=
8QZ9JD1zLvPR3yHf
REDIS_CLUSTER_HOST
=
47.244.34.27:6379
REDIS_CLUSTER_PASSWORD
=
8QZ9JD1zLvPR3yHf
[JWT]
SECRET
=
hilo1632
ISSUER_API
=
hiloApi
...
...
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