Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
ic_server_welfare
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9097fac0
authored
Oct 23, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
判断通知开关
parent
f7f2c0c3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
13 deletions
app/Tasks/SendNoticeTask.php
common
storage/laravels.json
storage/laravels.pid
app/Tasks/SendNoticeTask.php
View file @
9097fac0
...
...
@@ -2,6 +2,7 @@
namespace
App\Tasks
;
use
Common\Model\RedisModel
;
use
Hhxsv5\LaravelS\Swoole\Task\Task
;
use
Illuminate\Support\Facades\Log
;
...
...
@@ -10,35 +11,37 @@ class SendNoticeTask extends Task
private
$data
;
private
$PushTask
=
false
;
private
$TaskNum
;
public
function
__construct
(
$keyword
,
$data
,
$toUser
,
$TaskNum
=
1
,
$is_ignore
=
0
)
public
function
__construct
(
$keyword
,
$data
,
$toUser
,
$TaskNum
=
1
,
$is_ignore
=
0
)
{
if
(
is_array
(
$data
))
{
$data
=
json_encode
(
$data
);
}
$this
->
data
=
[
'data'
=>
$data
,
'touser'
=>
$toUser
,
'data'
=>
$data
,
'touser'
=>
$toUser
,
'is_ignore'
=>
$is_ignore
,
'keyword'
=>
$keyword
'keyword'
=>
$keyword
,
];
$this
->
TaskNum
=
$TaskNum
;
}
// 处理任务的逻辑,运行在Task进程中,不能投递任务
public
function
handle
()
{
// return true;
$time
=
date
(
'H'
);
if
(
20
<
$time
||
$time
<
9
)
{
//不发通知时段处理
$switches
=
$this
->
getNotificationSwitches
(
$this
->
data
[
'touser'
]);
if
(
$switches
[
'sys_msg'
]
==
0
)
{
//不发通知时段处理
return
true
;
}
try
{
$Url
=
config
(
'website.IC_AUTH_API'
)
.
'/hprose/HttpSendMsg'
;
$Url
=
config
(
'website.IC_AUTH_API'
)
.
'/hprose/HttpSendMsg'
;
$res
=
json_decode
(
reportCurl
(
$Url
,
$this
->
data
,
true
,
[
'MsgToken:fg368hjk4567wtbk8'
]),
true
);
if
(
!
isset
(
$res
[
'errcode'
])
||
$res
[
'errcode'
]
!==
0
)
{
ErrorLog
(
ErrorCode
(
001
,
9
),
'消息系统消息发送失败'
);
$this
->
PushTask
=
true
;
}
return
true
;
}
catch
(
\Exception
$e
)
{
SendErrMsg
(
$e
);
...
...
@@ -51,7 +54,7 @@ class SendNoticeTask extends Task
{
//消息推送失败,任务重试,第一次为4分钟后,第二次为10分钟后,第三次为18分钟后
if
(
$this
->
PushTask
===
true
&&
$this
->
TaskNum
<
4
)
{
$this
->
TaskNum
++
;
$this
->
TaskNum
++
;
$task
=
new
SendNoticeTask
(
$this
->
data
[
'keyword'
],
$this
->
data
[
'data'
],
...
...
@@ -59,8 +62,21 @@ class SendNoticeTask extends Task
$this
->
TaskNum
,
$this
->
data
[
'is_ignore'
]
);
$task
->
delay
(
60
*
2
*
$this
->
TaskNum
);
$task
->
delay
(
60
*
2
*
$this
->
TaskNum
);
Task
::
deliver
(
$task
);
}
}
//获取通知开关,目前只有系统通知被用到
private
function
getNotificationSwitches
(
$userId
)
{
$redis
=
new
RedisModel
();
$user
=
json_decode
(
$redis
->
hget
(
'ic_user'
,
$userId
),
true
);
$result
=
[];
//不存在代表是不可以接受通知的
$result
[
'sys_msg'
]
=
array_get
(
$user
,
'sys_msg'
,
0
);
$result
[
'activity_msg'
]
=
array_get
(
$user
,
'activity_msg'
,
0
);
return
$result
;
}
}
common
@
6a492b76
Subproject commit
8428774c731bbcd89366d7d698daf57579f0b53b
Subproject commit
6a492b76f3938205ed9d94cd12b81d66feea657d
storage/laravels.json
View file @
9097fac0
This diff is collapsed.
Click to expand it.
storage/laravels.pid
View file @
9097fac0
2930
\ No newline at end of file
18312
\ No newline at end of file
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