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
Compare Revisions
master...feature/family-redis
Source
feature/family-redis
Select Git revision
...
Target
master
Select Git revision
Compare
Commits (4)
feat:还没能编译
· 358f9798
hujiebin
authored
Jul 28, 2023
358f9798
Merge branch 'master' into feature/family-redis
· f454ed75
hujiebin
authored
Jul 28, 2023
f454ed75
feat:加一个log
· 8062f880
hujiebin
authored
Jul 28, 2023
8062f880
Update group_power_grade.go
· 3aedb726
hujiebin
authored
Jul 28, 2023
3aedb726
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
94 additions
and
5 deletions
+94
-5
group_power_grade.go
_const/redis_key/groupPower_k/group_power_grade.go
+10
-0
cron.go
cron/cron.go
+2
-1
group_power_grade.go
cron/group_cron/group_power_grade.go
+24
-0
group_power_grade.go
domain/cache/groupPower_c/group_power_grade.go
+50
-0
group_grade.go
domain/model/groupPower_m/group_grade.go
+3
-1
event_init.go
domain/service/event_s/event_init.go
+5
-3
No files found.
_const/redis_key/groupPower_k/group_power_grade.go
0 → 100644
View file @
3aedb726
package
groupPower_k
// groupPower等级
const
(
GroupPowerGradeExpQueue
=
"group_power_grade_exp_queue"
)
func
GetGroupPowerGradeExpQueue
()
string
{
return
GroupPowerGradeExpQueue
}
cron/cron.go
View file @
3aedb726
...
...
@@ -17,4 +17,5 @@ func Init() {
group_cron
.
GroupPowerExpClear
()
// 清理家族经验/等级
group_cron
.
GroupPowerMonthRankAct
()
group_cron
.
GroupInEventInit
()
// 进房事件
group_cron
.
GroupPowerGradeExp
()
// 家族升级
}
cron/group_cron/group_power_grade.go
0 → 100644
View file @
3aedb726
package
group_cron
import
(
"git.hilo.cn/hilo-common/domain"
"hilo-group/domain/cache/groupPower_c"
"hilo-group/domain/model/groupPower_m"
)
func
GroupPowerGradeExp
()
{
go
func
()
{
for
true
{
model
:=
domain
.
CreateModelNil
()
if
data
:=
groupPower_c
.
BLPopGroupPowerGradeExp
(
model
);
data
!=
nil
{
if
err
:=
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
return
groupPower_m
.
IncrGroupPowerExp
(
model
,
data
.
GroupPowerId
,
data
.
Exp
,
data
.
UserId
,
data
.
Remark
)
});
err
!=
nil
{
model
.
Log
.
Errorf
(
"IncrGroupPowerExp fail,data:%v-err:%v"
,
data
,
err
)
}
else
{
model
.
Log
.
Infof
(
"IncrGroupPowerExp success,data:%v"
,
data
)
}
}
}
}()
}
domain/cache/groupPower_c/group_power_grade.go
0 → 100644
View file @
3aedb726
package
groupPower_c
import
(
"encoding/json"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"hilo-group/_const/redis_key/groupPower_k"
"time"
)
type
GroupPowerGradeExp
struct
{
GroupPowerId
mysql
.
ID
Exp
mysql
.
Num
UserId
mysql
.
ID
Remark
string
}
// redis队列缓冲GroupPowerGradeExp升级内容
func
QueueGroupPowerGradeExp
(
model
*
domain
.
Model
,
groupPowerId
mysql
.
ID
,
exp
mysql
.
Num
,
userId
mysql
.
ID
,
remark
string
)
error
{
queue
:=
groupPower_k
.
GetGroupPowerGradeExpQueue
()
data
:=
GroupPowerGradeExp
{
GroupPowerId
:
groupPowerId
,
Exp
:
exp
,
UserId
:
userId
,
Remark
:
remark
,
}
body
,
_
:=
json
.
Marshal
(
data
)
return
model
.
Redis
.
RPush
(
model
,
queue
,
string
(
body
))
.
Err
()
}
// redis弹出GroupPowerGradeExp升级内容
func
BLPopGroupPowerGradeExp
(
model
*
domain
.
Model
)
*
GroupPowerGradeExp
{
var
res
*
GroupPowerGradeExp
queue
:=
groupPower_k
.
GetGroupPowerGradeExpQueue
()
strs
,
err
:=
model
.
Redis
.
BLPop
(
model
,
time
.
Second
,
queue
)
.
Result
()
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"BLPopGroupPowerGradeExp fail:%v"
,
err
)
return
nil
}
if
len
(
strs
)
>=
2
{
content
:=
strs
[
1
]
res
=
new
(
GroupPowerGradeExp
)
if
err
:=
json
.
Unmarshal
([]
byte
(
content
),
res
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"BLPopGroupPowerGradeExp json fail:%v"
,
err
)
return
nil
}
return
res
}
return
nil
}
domain/model/groupPower_m/group_grade.go
View file @
3aedb726
...
...
@@ -8,6 +8,7 @@ import (
"gorm.io/gorm"
"gorm.io/gorm/clause"
"hilo-group/_const/enum/groupPower_e"
"hilo-group/domain/cache/groupPower_c"
"hilo-group/domain/event/group_power_ev"
"time"
)
...
...
@@ -230,7 +231,8 @@ func IncrGroupPowerExpOnMic(model *domain.Model, groupPowerId, userId mysql.ID,
return
err
}
// 每10分钟增加100点经验
if
err
:=
IncrGroupPowerExp
(
model
,
groupPowerId
,
100
,
userId
,
"上麦10分钟"
);
err
!=
nil
{
//if err := IncrGroupPowerExp(model, groupPowerId, 100, userId, "上麦10分钟"); err != nil {
if
err
:=
groupPower_c
.
QueueGroupPowerGradeExp
(
model
,
groupPowerId
,
100
,
userId
,
"上麦10分钟"
);
err
!=
nil
{
return
err
}
}
...
...
domain/service/event_s/event_init.go
View file @
3aedb726
...
...
@@ -10,6 +10,7 @@ import (
"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"
...
...
@@ -488,9 +489,10 @@ func SendGift() {
}
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 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
})
...
...