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
a1f7661b
Commit
a1f7661b
authored
Mar 10, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
势力等级即将过期
parent
a80e1c20
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
0 deletions
+67
-0
group_power_exp.go
cron/group_cron/group_power_exp.go
+7
-0
groupPowerExpireNotice.go
domain/event/group_power_ev/groupPowerExpireNotice.go
+26
-0
group_info.go
domain/model/groupPower_m/group_info.go
+12
-0
event_init.go
domain/service/event_s/event_init.go
+22
-0
No files found.
cron/group_cron/group_power_exp.go
View file @
a1f7661b
...
...
@@ -3,6 +3,7 @@ package group_cron
import
(
"git.hilo.cn/hilo-common/domain"
"github.com/robfig/cron"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/model/groupPower_m"
)
...
...
@@ -26,5 +27,11 @@ func GroupPowerExpClear() {
model
.
Log
.
Errorf
(
"ClearGroupPowerGrade fail:%v"
,
err
)
}
})
// 每月20号发家族即将过期通知
spec
=
"0 0 0 20 * ?"
_
=
c
.
AddFunc
(
spec
,
func
()
{
var
model
=
domain
.
CreateModelNil
()
_
=
group_power_ev
.
PublishGroupPowerExpireNotice
(
model
,
&
group_power_ev
.
GroupPowerExpireNoticeEvent
{})
})
c
.
Start
()
}
domain/event/group_power_ev/groupPowerExpireNotice.go
0 → 100644
View file @
a1f7661b
package
group_power_ev
import
(
"git.hilo.cn/hilo-common/domain"
)
//注册监听
var
groupPowerExpireNoticeListen
=
new
(
domain
.
EventBase
)
type
GroupPowerExpireNoticeEvent
struct
{
}
//添加领域事件,在每个领域模型中init中添加,因为这是静态业务,非动态的。
func
AddGroupPowerExpireNoticeSync
(
callback
func
(
model
*
domain
.
Model
,
event
interface
{})
error
)
{
domain
.
AddEventSync
(
groupPowerExpireNoticeListen
,
callback
)
}
//加入到异步操作中
func
AddGroupPowerExpireNoticeAsync
(
callback
func
(
model
*
domain
.
Model
,
event
interface
{})
error
)
{
domain
.
AddEventAsync
(
groupPowerExpireNoticeListen
,
callback
)
}
//领域事件发布
func
PublishGroupPowerExpireNotice
(
model
*
domain
.
Model
,
event
interface
{})
error
{
return
domain
.
PublishEvent
(
groupPowerExpireNoticeListen
,
model
,
event
)
}
domain/model/groupPower_m/group_info.go
View file @
a1f7661b
...
...
@@ -3,6 +3,7 @@ package groupPower_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"hilo-group/_const/enum/groupPower_e"
)
type
GroupPowerInfo
struct
{
...
...
@@ -55,3 +56,14 @@ func GetGroupPowerUser(model *domain.Model, groupPowerId mysql.ID) ([]*GroupPowe
}
return
m
[
groupPowerId
],
nil
}
// 获取所有家族的主
func
GetAllGroupPowerOwners
(
model
*
domain
.
Model
)
([]
mysql
.
ID
,
error
)
{
var
userIds
[]
mysql
.
ID
if
err
:=
model
.
DB
()
.
Model
(
GroupPowerUser
{})
.
Select
(
"user_id"
)
.
Where
(
"role = ?"
,
groupPower_e
.
GroupPowerUserRoleMgr
)
.
Find
(
&
userIds
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"GetAllGroupPowerOwners fail:%v"
,
err
)
return
userIds
,
err
}
return
userIds
,
nil
}
domain/service/event_s/event_init.go
View file @
a1f7661b
...
...
@@ -191,6 +191,28 @@ func GroupPowerEvents() {
}
return
nil
})
// 势力等级即将过期
group_power_ev
.
AddGroupPowerExpireNoticeAsync
(
func
(
model
*
domain
.
Model
,
e
interface
{})
error
{
model
.
Log
.
Infof
(
"msg AddGroupPowerExpireNoticeAsync"
)
powerOwners
,
err
:=
groupPower_m
.
GetAllGroupPowerOwners
(
model
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"AddGroupPowerExpireNoticeAsync fail:%v"
,
err
)
return
err
}
userMaps
,
err
:=
user_m
.
GetUserMapByIds
(
model
,
powerOwners
)
if
err
!=
nil
{
return
err
}
for
uid
,
u
:=
range
userMaps
{
if
err
:=
msg_m
.
NewUserRecord
(
model
,
uid
,
msg_e
.
GroupPowerExpireNotice
,
""
,
0
,
""
,
""
,
""
,
""
,
""
)
.
Persistent
();
err
!=
nil
{
model
.
Log
.
Errorf
(
"msg AddGroupPowerExpireNoticeAsync NewUserRecord err:%v"
,
err
)
return
nil
}
msg_m
.
SendEmasMsgAssistant
(
model
,
u
.
ExternalId
,
u
.
DeviceType
)
}
return
nil
})
}
func
GroupEvents
()
{
...
...
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