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
32c52c48
Commit
32c52c48
authored
Aug 28, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:去掉家族月之星
parent
b28ebb47
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
63 deletions
+30
-63
send_gift_redis.go
cron/gift_cron/send_gift_redis.go
+0
-6
group_power_star.go
domain/cache/groupPower_c/group_power_star.go
+5
-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
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_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 @
32c52c48
...
@@ -75,9 +75,6 @@ func groupPowerStar(model *domain.Model, sendGiftEvent *gift_ev.SendGiftEvent) {
...
@@ -75,9 +75,6 @@ func groupPowerStar(model *domain.Model, sendGiftEvent *gift_ev.SendGiftEvent) {
// 送礼加分
// 送礼加分
if
data
,
ok
:=
groupPowers
[
sendGiftEvent
.
SendUserId
];
ok
{
if
data
,
ok
:=
groupPowers
[
sendGiftEvent
.
SendUserId
];
ok
{
diamonds
:=
sendGiftEvent
.
GiftN
*
sendGiftEvent
.
ResGift
.
DiamondNum
*
mysql
.
Num
(
len
(
sendGiftEvent
.
ReceiveUserIds
))
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
,
if
err
:=
groupPower_c
.
IncrGroupPowerDayStarScore
(
model
,
data
.
GroupPowerId
,
data
.
UserId
,
groupPower_e
.
GroupPowerStarTypeFamous
,
diamonds
);
err
!=
nil
{
groupPower_e
.
GroupPowerStarTypeFamous
,
diamonds
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"IncrGroupPowerDayStarScore famous fail:%v"
,
err
)
model
.
Log
.
Errorf
(
"IncrGroupPowerDayStarScore famous fail:%v"
,
err
)
...
@@ -87,9 +84,6 @@ func groupPowerStar(model *domain.Model, sendGiftEvent *gift_ev.SendGiftEvent) {
...
@@ -87,9 +84,6 @@ func groupPowerStar(model *domain.Model, sendGiftEvent *gift_ev.SendGiftEvent) {
for
_
,
userId
:=
range
sendGiftEvent
.
ReceiveUserIds
{
for
_
,
userId
:=
range
sendGiftEvent
.
ReceiveUserIds
{
if
data
,
ok
:=
groupPowers
[
userId
];
ok
{
if
data
,
ok
:=
groupPowers
[
userId
];
ok
{
diamonds
:=
sendGiftEvent
.
GiftN
*
sendGiftEvent
.
ResGift
.
DiamondNum
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
,
if
err
:=
groupPower_c
.
IncrGroupPowerDayStarScore
(
model
,
data
.
GroupPowerId
,
data
.
UserId
,
groupPower_e
.
GroupPowerStarTypeCharm
,
diamonds
);
err
!=
nil
{
groupPower_e
.
GroupPowerStarTypeCharm
,
diamonds
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"IncrGroupPowerDayStarScore charm fail:%v"
,
err
)
model
.
Log
.
Errorf
(
"IncrGroupPowerDayStarScore charm fail:%v"
,
err
)
...
...
domain/cache/groupPower_c/group_power_star.go
View file @
32c52c48
...
@@ -47,7 +47,8 @@ func IncrGroupPowerDayStarScore(model *domain.Model, groupPowerId, userId mysql.
...
@@ -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
var
res
[]
*
GroupPowerStarRank
date
:=
""
date
:=
""
switch
period
{
switch
period
{
...
@@ -61,6 +62,9 @@ func GetGroupPowerStarRankPeriod(model *domain.Model, period string, groupPowerI
...
@@ -61,6 +62,9 @@ func GetGroupPowerStarRankPeriod(model *domain.Model, period string, groupPowerI
if
len
(
date
)
<=
0
{
if
len
(
date
)
<=
0
{
return
res
,
errors
.
New
(
"illegal date"
)
return
res
,
errors
.
New
(
"illegal date"
)
}
}
if
len
(
targetDate
)
>
0
{
date
=
targetDate
[
0
]
}
key
:=
groupPower_k
.
GetGroupPowerStarRankKey
(
_type
,
period
,
groupPowerId
,
date
)
key
:=
groupPower_k
.
GetGroupPowerStarRankKey
(
_type
,
period
,
groupPowerId
,
date
)
rows
,
err
:=
model
.
RedisCluster
.
ZRevRangeByScoreWithScores
(
model
,
key
,
&
redis
.
ZRangeBy
{
rows
,
err
:=
model
.
RedisCluster
.
ZRevRangeByScoreWithScores
(
model
,
key
,
&
redis
.
ZRangeBy
{
Min
:
"-inf"
,
Min
:
"-inf"
,
...
...
domain/model/groupPower_m/group_grade.go
View file @
32c52c48
...
@@ -154,56 +154,6 @@ func IncrGroupPowerExpOnMic(model *domain.Model, groupPowerId, userId mysql.ID)
...
@@ -154,56 +154,6 @@ func IncrGroupPowerExpOnMic(model *domain.Model, groupPowerId, userId mysql.ID)
return
nil
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
{
func
ClearGroupPowerExp
(
model
*
domain
.
Model
)
error
{
var
groupPowerGrades
[]
*
GroupPowerGrade
var
groupPowerGrades
[]
*
GroupPowerGrade
...
...
domain/model/groupPower_m/group_star.go
View file @
32c52c48
...
@@ -35,6 +35,7 @@ type GroupPowerDayStar struct {
...
@@ -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
{
func
IncrGroupPowerMonthStarScore
(
model
*
domain
.
Model
,
groupPowerId
,
userId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
score
mysql
.
Num
,
lastCalTs
int64
)
error
{
month
:=
time
.
Now
()
.
Format
(
"200601"
)
month
:=
time
.
Now
()
.
Format
(
"200601"
)
star
:=
&
GroupPowerMonthStar
{
star
:=
&
GroupPowerMonthStar
{
...
@@ -83,6 +84,7 @@ func IncrGroupPowerDayStarScore(model *domain.Model, groupPowerId, userId mysql.
...
@@ -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
)
{
func
GetGroupPowerMonthStarRank
(
model
*
domain
.
Model
,
groupPowerId
mysql
.
ID
,
_type
groupPower_e
.
GroupPowerStarType
,
offset
,
limit
int
,
month
string
)
([]
*
GroupPowerMonthStar
,
error
)
{
var
res
[]
*
GroupPowerMonthStar
var
res
[]
*
GroupPowerMonthStar
//month := time.Now().Format("200601")
//month := time.Now().Format("200601")
...
...
domain/service/group_mic_s/group_mic.go
View file @
32c52c48
...
@@ -322,11 +322,7 @@ func (s *GroupMicService) IncrGroupPowerOnMicExpAndTime(groupId string, userId u
...
@@ -322,11 +322,7 @@ func (s *GroupMicService) IncrGroupPowerOnMicExpAndTime(groupId string, userId u
if
err
:=
groupPower_m
.
IncrGroupPowerExpOnMic
(
model
,
groupPowerId
,
userId
);
err
!=
nil
{
if
err
:=
groupPower_m
.
IncrGroupPowerExpOnMic
(
model
,
groupPowerId
,
userId
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"IncrGroupPowerExpOnMic fail:%v"
,
err
)
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_m.IncrGroupPowerStarOnMicDay(model, groupPowerId, userId, joinMicTimestamp); err != nil {
if
err
:=
groupPower_c
.
IncrGroupPowerDayStarScore
(
model
,
groupPowerId
,
userId
,
if
err
:=
groupPower_c
.
IncrGroupPowerDayStarScore
(
model
,
groupPowerId
,
userId
,
groupPower_e
.
GroupPowerStarTypeActive
,
60
);
err
!=
nil
{
groupPower_e
.
GroupPowerStarTypeActive
,
60
);
err
!=
nil
{
...
...
domain/service/group_power_s/group_power.go
View file @
32c52c48
...
@@ -13,6 +13,7 @@ import (
...
@@ -13,6 +13,7 @@ import (
"hilo-group/_const/enum/msg_e"
"hilo-group/_const/enum/msg_e"
"hilo-group/cv/group_power_cv"
"hilo-group/cv/group_power_cv"
"hilo-group/cv/user_cv"
"hilo-group/cv/user_cv"
"hilo-group/domain/cache/groupPower_c"
"hilo-group/domain/cache/user_c"
"hilo-group/domain/cache/user_c"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/groupPower_m"
...
@@ -154,7 +155,12 @@ func GetGroupPowerRankResp(model *domain.Model, beginDate, endDate string, userI
...
@@ -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
)
{
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
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
test/group_power_test.go
View file @
32c52c48
...
@@ -3,8 +3,10 @@ package test
...
@@ -3,8 +3,10 @@ package test
import
(
import
(
"fmt"
"fmt"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/redisCli"
"git.hilo.cn/hilo-common/utils"
"git.hilo.cn/hilo-common/utils"
"github.com/jinzhu/now"
"github.com/jinzhu/now"
"hilo-group/domain/cache/groupPower_c"
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/group_m"
"hilo-group/domain/model/group_m"
"hilo-group/domain/service/group_power_s"
"hilo-group/domain/service/group_power_s"
...
@@ -69,3 +71,14 @@ func TestGetRandomImProvider(t *testing.T) {
...
@@ -69,3 +71,14 @@ func TestGetRandomImProvider(t *testing.T) {
fmt
.
Printf
(
"true--------------times0:%v
\n
"
,
times0
)
fmt
.
Printf
(
"true--------------times0:%v
\n
"
,
times0
)
fmt
.
Printf
(
"true--------------times1:%v
\n
"
,
times1
)
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 @
32c52c48
...
@@ -11,6 +11,8 @@ MYSQL_DB=hilo_code
...
@@ -11,6 +11,8 @@ MYSQL_DB=hilo_code
[REDIS]
[REDIS]
REDIS_HOST
=
47.244.34.27:6379
REDIS_HOST
=
47.244.34.27:6379
REDIS_PASSWORD
=
8QZ9JD1zLvPR3yHf
REDIS_PASSWORD
=
8QZ9JD1zLvPR3yHf
REDIS_CLUSTER_HOST
=
47.244.34.27:6379
REDIS_CLUSTER_PASSWORD
=
8QZ9JD1zLvPR3yHf
[JWT]
[JWT]
SECRET
=
hilo1632
SECRET
=
hilo1632
ISSUER_API
=
hiloApi
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