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
07123285
Commit
07123285
authored
Aug 23, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
group support
parent
a0452059
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
47 deletions
+45
-47
send_gift_redis.go
cron/gift_cron/send_gift_redis.go
+44
-2
event_init.go
domain/service/event_s/event_init.go
+1
-45
No files found.
cron/gift_cron/send_gift_redis.go
View file @
07123285
package
gift_cron
import
(
"context"
"git.hilo.cn/hilo-common/_const/rediskey"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/resource/redisCli"
"hilo-group/_const/enum/gift_e"
"hilo-group/_const/enum/groupPower_e"
"hilo-group/domain/cache/gift_c"
"hilo-group/domain/event/gift_ev"
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/group_m"
"time"
)
// 送礼事件
...
...
@@ -18,8 +24,9 @@ func SendGiftEvent() {
for
true
{
model
:=
domain
.
CreateModelNil
()
if
sendGiftEvent
:=
gift_c
.
BLPopQueueSendGift
(
model
);
sendGiftEvent
!=
nil
{
groupPowerGrade
(
model
,
sendGiftEvent
)
// 家族经验
groupPowerStar
(
model
,
sendGiftEvent
)
// 家族之星
groupPowerGrade
(
model
,
sendGiftEvent
)
// 家族经验
groupPowerStar
(
model
,
sendGiftEvent
)
// 家族之星
groupSupportAddConsume
(
model
,
sendGiftEvent
)
// 群组扶持
}
}
}()
...
...
@@ -88,3 +95,38 @@ func groupPowerStar(model *domain.Model, sendGiftEvent *gift_ev.SendGiftEvent) {
}
return
}
// 群组扶持增加流水数据
func
groupSupportAddConsume
(
model
*
domain
.
Model
,
sendGiftEvent
*
gift_ev
.
SendGiftEvent
)
{
//if time.Now().Unix() <= 1692964800 { // cwj----
// return nil
//}
if
sendGiftEvent
.
SceneType
!=
gift_e
.
GroupSceneType
||
sendGiftEvent
.
SceneUid
==
""
{
return
}
_
,
_
,
period
:=
group_m
.
GetSupportLevelTime
(
time
.
Now
())
// 钻石数
diamond
:=
sendGiftEvent
.
GiftN
*
sendGiftEvent
.
ResGift
.
DiamondNum
keyDiamond
:=
rediskey
.
GetGroupSupportConsumeSummary
(
period
)
_
,
err
:=
model
.
RedisCluster
.
ZIncrBy
(
context
.
Background
(),
keyDiamond
,
float64
(
diamond
),
sendGiftEvent
.
SceneUid
)
.
Result
()
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"AddSendGiftEventAsync groupSupport key:%s, val:%d, member:%s, err:%v"
,
keyDiamond
,
diamond
,
sendGiftEvent
.
SceneUid
,
err
)
}
err
=
redisCli
.
SetExpire
(
model
.
RedisCluster
,
keyDiamond
,
time
.
Hour
*
24
*
14
)
// 保留两周
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"AddSendGiftEventAsync groupSupport key:%s, val:%d, member:%s, err:%v"
,
keyDiamond
,
diamond
,
sendGiftEvent
.
SceneUid
,
err
)
}
// 支持者数量
keySupportNum
:=
rediskey
.
GetGroupSupportCountSupporter
(
period
,
sendGiftEvent
.
SceneUid
)
err
=
model
.
RedisCluster
.
SAdd
(
context
.
Background
(),
keySupportNum
,
sendGiftEvent
.
SendUserId
)
.
Err
()
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"AddSendGiftEventAsync groupSupport key:%s, UserId:%d, err:%v"
,
keySupportNum
,
sendGiftEvent
.
SendUserId
,
err
)
}
err
=
redisCli
.
SetExpire
(
model
.
RedisCluster
,
keySupportNum
,
time
.
Hour
*
24
*
14
)
// 保留两周
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"AddSendGiftEventAsync groupSupport key:%s, UserId:%d, err:%v"
,
keySupportNum
,
sendGiftEvent
.
SendUserId
,
err
)
}
return
}
domain/service/event_s/event_init.go
View file @
07123285
package
event_s
import
(
"context"
"encoding/json"
"git.hilo.cn/hilo-common/_const/rediskey"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/resource/redisCli"
"git.hilo.cn/hilo-common/rpc"
"git.hilo.cn/hilo-common/sdk/tencentyun"
"hilo-group/_const/enum/gift_e"
"hilo-group/_const/enum/group_e"
"hilo-group/_const/enum/msg_e"
"hilo-group/_const/enum/task_e"
"hilo-group/domain/cache/group_c"
"hilo-group/domain/event/gift_ev"
"hilo-group/domain/event/group_ev"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/event/mic_ev"
...
...
@@ -37,7 +32,7 @@ func EventInit() {
GroupEvents
()
GroupImMass
()
GroupTheme
()
SendGift
()
// 送礼事件
//
SendGift() // 送礼事件
OnMic
()
// 在麦上事件
GroupInMicChangeEvent
()
// 用户进房推送mic位置信息
}
...
...
@@ -473,45 +468,6 @@ func FlushHiloInfo(extId string, isVip bool, isPrettyCode bool, medals []uint32,
}
func
SendGift
()
{
// 送礼事件-群组扶持数据累加
gift_ev
.
AddSendGiftEventAsync
(
func
(
model
*
domain
.
Model
,
event
interface
{})
error
{
//if time.Now().Unix() <= 1692964800 { // cwj----
// return nil
//}
sendGiftEvent
,
ok
:=
event
.
(
*
gift_ev
.
SendGiftEvent
)
if
!
ok
{
model
.
Log
.
Errorf
(
"AddSendGiftEventAsync event type err 群组扶持"
)
return
nil
}
if
sendGiftEvent
.
SceneType
!=
gift_e
.
GroupSceneType
||
sendGiftEvent
.
SceneUid
==
""
{
return
nil
}
_
,
_
,
period
:=
group_m
.
GetSupportLevelTime
(
time
.
Now
())
// 钻石数
diamond
:=
sendGiftEvent
.
GiftN
*
sendGiftEvent
.
ResGift
.
DiamondNum
keyDiamond
:=
rediskey
.
GetGroupSupportConsumeSummary
(
period
)
_
,
err
:=
model
.
RedisCluster
.
ZIncrBy
(
context
.
Background
(),
keyDiamond
,
float64
(
diamond
),
sendGiftEvent
.
SceneUid
)
.
Result
()
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"AddSendGiftEventAsync groupSupport key:%s, val:%d, member:%s, err:%v"
,
keyDiamond
,
diamond
,
sendGiftEvent
.
SceneUid
,
err
)
}
err
=
redisCli
.
SetExpire
(
model
.
RedisCluster
,
keyDiamond
,
time
.
Hour
*
24
*
14
)
// 保留两周
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"AddSendGiftEventAsync groupSupport key:%s, val:%d, member:%s, err:%v"
,
keyDiamond
,
diamond
,
sendGiftEvent
.
SceneUid
,
err
)
}
// 支持者数量
keySupportNum
:=
rediskey
.
GetGroupSupportCountSupporter
(
period
,
sendGiftEvent
.
SceneUid
)
err
=
model
.
RedisCluster
.
SAdd
(
context
.
Background
(),
keySupportNum
,
sendGiftEvent
.
SendUserId
)
.
Err
()
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"AddSendGiftEventAsync groupSupport key:%s, UserId:%d, err:%v"
,
keySupportNum
,
sendGiftEvent
.
SendUserId
,
err
)
}
err
=
redisCli
.
SetExpire
(
model
.
RedisCluster
,
keySupportNum
,
time
.
Hour
*
24
*
14
)
// 保留两周
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"AddSendGiftEventAsync groupSupport key:%s, UserId:%d, err:%v"
,
keySupportNum
,
sendGiftEvent
.
SendUserId
,
err
)
}
return
nil
})
// 送礼事件-势力经验
//gift_ev.AddSendGiftEventAsync(func(model *domain.Model, event interface{}) error {
// sendGiftEvent, ok := event.(*gift_ev.SendGiftEvent)
...
...
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