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
2d0ca0c4
Commit
2d0ca0c4
authored
Aug 29, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/group_country' into 'master'
群组扶持旧数据 See merge request
!76
parents
d8d76b8a
ea19ee5c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
77 deletions
+82
-77
cron.go
cron/cron.go
+1
-1
send_gift_redis.go
cron/gift_cron/send_gift_redis.go
+1
-1
group_support.go
cron/group_cron/group_support.go
+78
-73
gift.go
domain/model/gift_m/gift.go
+2
-2
No files found.
cron/cron.go
View file @
2d0ca0c4
...
@@ -21,6 +21,6 @@ func Init() {
...
@@ -21,6 +21,6 @@ func Init() {
//group_cron.GroupInEventInit() // 进房事件
//group_cron.GroupInEventInit() // 进房事件
//group_cron.CreateGroup() //
//group_cron.CreateGroup() //
group_cron
.
CalcGroupSupport
()
// 群组扶持计算
group_cron
.
CalcGroupSupport
()
// 群组扶持计算
//
group_cron.CalcGroupSupport_OldData()
group_cron
.
CalcGroupSupport_OldData
()
group_cron
.
GroupCountryListSort
()
group_cron
.
GroupCountryListSort
()
}
}
cron/gift_cron/send_gift_redis.go
View file @
2d0ca0c4
...
@@ -95,7 +95,7 @@ func groupPowerStar(model *domain.Model, sendGiftEvent *gift_ev.SendGiftEvent) {
...
@@ -95,7 +95,7 @@ func groupPowerStar(model *domain.Model, sendGiftEvent *gift_ev.SendGiftEvent) {
// 群组扶持增加流水数据
// 群组扶持增加流水数据
func
groupSupportAddConsume
(
model
*
domain
.
Model
,
sendGiftEvent
*
gift_ev
.
SendGiftEvent
)
{
func
groupSupportAddConsume
(
model
*
domain
.
Model
,
sendGiftEvent
*
gift_ev
.
SendGiftEvent
)
{
if
time
.
Now
()
.
Unix
()
<=
169
28436
00
{
if
time
.
Now
()
.
Unix
()
<=
169
32759
00
{
return
return
}
}
model
.
Log
.
Infof
(
"groupSupportAddConsume UserId:%d, sendGiftEvent:%+v"
,
sendGiftEvent
.
SendUserId
,
sendGiftEvent
)
model
.
Log
.
Infof
(
"groupSupportAddConsume UserId:%d, sendGiftEvent:%+v"
,
sendGiftEvent
.
SendUserId
,
sendGiftEvent
)
...
...
cron/group_cron/group_support.go
View file @
2d0ca0c4
package
group_cron
package
group_cron
import
(
import
(
"context"
"encoding/json"
"encoding/json"
"git.hilo.cn/hilo-common/_const/rediskey"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/config"
"git.hilo.cn/hilo-common/resource/config"
"git.hilo.cn/hilo-common/resource/redisCli"
"git.hilo.cn/hilo-common/sdk/tencentyun"
"git.hilo.cn/hilo-common/sdk/tencentyun"
"git.hilo.cn/hilo-common/utils"
"git.hilo.cn/hilo-common/utils"
"github.com/robfig/cron"
"github.com/robfig/cron"
"hilo-group/_const/enum/gift_e"
"hilo-group/_const/enum/group_e"
"hilo-group/_const/enum/group_e"
"hilo-group/domain/model/gift_m"
"hilo-group/domain/model/group_m"
"hilo-group/domain/model/group_m"
"hilo-group/domain/service/group_s"
"hilo-group/domain/service/group_s"
"time"
"time"
...
@@ -87,76 +92,76 @@ func sendGroupSupportH5(model *domain.Model) error {
...
@@ -87,76 +92,76 @@ func sendGroupSupportH5(model *domain.Model) error {
}
}
// 群组扶持计算-旧数据
// 群组扶持计算-旧数据
//
func CalcGroupSupport_OldData() {
func
CalcGroupSupport_OldData
()
{
//
if !config.IsMaster() {
if
!
config
.
IsMaster
()
{
//
return
return
//
}
}
//
c := cron.New()
c
:=
cron
.
New
()
// spec := "0 20 11 25
8 ?"
spec
:=
"0 27 10 29
8 ?"
//
_ = c.AddFunc(spec, func() {
_
=
c
.
AddFunc
(
spec
,
func
()
{
//
defer utils.CheckGoPanic()
defer
utils
.
CheckGoPanic
()
//
var model = domain.CreateModelNil()
var
model
=
domain
.
CreateModelNil
()
//
//开始
//开始
//
model.Log.Infof("CalcGroupSupport_OldData start")
model
.
Log
.
Infof
(
"CalcGroupSupport_OldData start"
)
//
//
beginTime, endTime, period := group_m.GetSupportLevelTime(time.Now().AddDate(0, 0, -group_e.SUPPORT_LEVEL_PERIOD_DAY))
//
beginTime, endTime, period := group_m.GetSupportLevelTime(time.Now().AddDate(0, 0, -group_e.SUPPORT_LEVEL_PERIOD_DAY))
// //
beginTime, _, period := group_m.GetSupportLevelTime(time.Now())
beginTime
,
_
,
period
:=
group_m
.
GetSupportLevelTime
(
time
.
Now
())
// //endTime := time.Unix(16928436
00, 0)
endTime
:=
time
.
Unix
(
16932759
00
,
0
)
//
//
g := gift_m.GiftOperate{SceneType: gift_e.GroupSceneType, Model: model}
g
:=
gift_m
.
GiftOperate
{
SceneType
:
gift_e
.
GroupSceneType
,
Model
:
model
}
//
records, err := g.BatchGetConsumeByRange(beginTime, endTime)
records
,
err
:=
g
.
BatchGetConsumeByRange
(
beginTime
,
endTime
)
//
if err != nil {
if
err
!=
nil
{
//
model.Log.Errorf("CalcGroupSupport_OldData beginTime:%v, endTime:%v, err:%v", beginTime, endTime, err)
model
.
Log
.
Errorf
(
"CalcGroupSupport_OldData beginTime:%v, endTime:%v, err:%v"
,
beginTime
,
endTime
,
err
)
//
return
return
//
}
}
//
// 流水写入redis
// 流水写入redis
//
keyDiamond := rediskey.GetGroupSupportConsumeSummary(period)
keyDiamond
:=
rediskey
.
GetGroupSupportConsumeSummary
(
period
)
//
for _, r := range records {
for
_
,
r
:=
range
records
{
//
if r.SceneUid == "" || r.Consume <= 0 {
if
r
.
SceneUid
==
""
||
r
.
Consume
<=
0
{
//
continue
continue
//
}
}
//
_, err = model.RedisCluster.ZIncrBy(context.Background(), keyDiamond, float64(r.Consume), r.SceneUid).Result()
_
,
err
=
model
.
RedisCluster
.
ZIncrBy
(
context
.
Background
(),
keyDiamond
,
float64
(
r
.
Consume
),
r
.
SceneUid
)
.
Result
()
//
if err != nil {
if
err
!=
nil
{
//
model.Log.Errorf("CalcGroupSupport_OldData groupSupport key:%s, val:%d, member:%s, err:%v",
model
.
Log
.
Errorf
(
"CalcGroupSupport_OldData groupSupport key:%s, val:%d, member:%s, err:%v"
,
//
keyDiamond, r.Consume, r.SceneUid, err)
keyDiamond
,
r
.
Consume
,
r
.
SceneUid
,
err
)
//
}
}
//
}
}
//
err = redisCli.SetExpire(model.RedisCluster, keyDiamond, time.Hour*24*14) // 保留两周
err
=
redisCli
.
SetExpire
(
model
.
RedisCluster
,
keyDiamond
,
time
.
Hour
*
24
*
14
)
// 保留两周
//
if err != nil {
if
err
!=
nil
{
//
model.Log.Errorf("CalcGroupSupport_OldData groupSupport key:%s, err:%v", keyDiamond, err)
model
.
Log
.
Errorf
(
"CalcGroupSupport_OldData groupSupport key:%s, err:%v"
,
keyDiamond
,
err
)
//
return
return
//
}
}
//
// 支持者写入redis
// 支持者写入redis
//
for _, r := range records {
for
_
,
r
:=
range
records
{
//
if r.SceneUid == "" || r.C <= 0 {
if
r
.
SceneUid
==
""
||
r
.
C
<=
0
{
//
continue
continue
//
}
}
//
// 支持者列表
// 支持者列表
//
support := gift_m.GiftOperate{SceneType: gift_e.GroupSceneType, SceneUid: r.SceneUid, Model: model}
support
:=
gift_m
.
GiftOperate
{
SceneType
:
gift_e
.
GroupSceneType
,
SceneUid
:
r
.
SceneUid
,
Model
:
model
}
// uids, err := support.BatchGetSupportList(
beginTime, endTime)
uids
,
err
:=
support
.
BatchGetSupportList
(
model
,
beginTime
,
endTime
)
//
if err != nil {
if
err
!=
nil
{
//
model.Log.Errorf("CalcGroupSupport_OldData beginTime:%v, endTime:%v, imGroupId:%v, err:%v", beginTime, endTime, r.SceneUid, err)
model
.
Log
.
Errorf
(
"CalcGroupSupport_OldData beginTime:%v, endTime:%v, imGroupId:%v, err:%v"
,
beginTime
,
endTime
,
r
.
SceneUid
,
err
)
//
continue
continue
//
}
}
//
if len(uids) <= 0 {
if
len
(
uids
)
<=
0
{
//
continue
continue
//
}
}
//
// 支持者数量
// 支持者数量
//
keySupportNum := rediskey.GetGroupSupportCountSupporter(period, r.SceneUid)
keySupportNum
:=
rediskey
.
GetGroupSupportCountSupporter
(
period
,
r
.
SceneUid
)
//
for _, uid := range uids {
for
_
,
uid
:=
range
uids
{
//
err = model.RedisCluster.SAdd(context.Background(), keySupportNum, uid).Err()
err
=
model
.
RedisCluster
.
SAdd
(
context
.
Background
(),
keySupportNum
,
uid
)
.
Err
()
//
if err != nil {
if
err
!=
nil
{
//
model.Log.Errorf("CalcGroupSupport_OldData groupSupport key:%s, UserId:%d, err:%v", keySupportNum, uid, err)
model
.
Log
.
Errorf
(
"CalcGroupSupport_OldData groupSupport key:%s, UserId:%d, err:%v"
,
keySupportNum
,
uid
,
err
)
//
}
}
//
}
}
//
err = redisCli.SetExpire(model.RedisCluster, keySupportNum, time.Hour*24*14) // 保留两周
err
=
redisCli
.
SetExpire
(
model
.
RedisCluster
,
keySupportNum
,
time
.
Hour
*
24
*
14
)
// 保留两周
//
if err != nil {
if
err
!=
nil
{
//
model.Log.Errorf("AddSendGiftEventAsync groupSupport key:%s, err:%v", keySupportNum, err)
model
.
Log
.
Errorf
(
"AddSendGiftEventAsync groupSupport key:%s, err:%v"
,
keySupportNum
,
err
)
//
}
}
//
}
}
//
//
model.Log.Infof("CalcGroupSupport_OldData end")
model
.
Log
.
Infof
(
"CalcGroupSupport_OldData end"
)
//
})
})
//
//
c.Start()
c
.
Start
()
//
}
}
domain/model/gift_m/gift.go
View file @
2d0ca0c4
...
@@ -182,9 +182,9 @@ func (g *GiftOperate) BatchGetConsumeByRange(beginTime, endTime time.Time) ([]Sc
...
@@ -182,9 +182,9 @@ func (g *GiftOperate) BatchGetConsumeByRange(beginTime, endTime time.Time) ([]Sc
return
rows
,
nil
return
rows
,
nil
}
}
func
(
g
*
GiftOperate
)
BatchGetSupportList
(
beginTime
,
endTime
time
.
Time
)
([]
uint64
,
error
)
{
func
(
g
*
GiftOperate
)
BatchGetSupportList
(
model
*
domain
.
Model
,
beginTime
,
endTime
time
.
Time
)
([]
uint64
,
error
)
{
userIds
:=
make
([]
uint64
,
0
)
userIds
:=
make
([]
uint64
,
0
)
err
:=
g
.
DB
()
.
Model
(
g
)
.
err
:=
model
.
DB
()
.
Model
(
g
)
.
Select
(
"DISTINCT(send_user_id) AS user_id"
)
.
Select
(
"DISTINCT(send_user_id) AS user_id"
)
.
Where
(
g
)
.
Where
(
"created_time BETWEEN ? AND ?"
,
beginTime
,
endTime
)
.
Pluck
(
"user_id"
,
&
userIds
)
.
Error
Where
(
g
)
.
Where
(
"created_time BETWEEN ? AND ?"
,
beginTime
,
endTime
)
.
Pluck
(
"user_id"
,
&
userIds
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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