切换导航条
此项目
正在载入...
登录
周海龙
/
mail-serve
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
邓超
8 months ago
提交
7cc24d680fc3ca59065da99cc07ad3f906494ae1
1 个父辈
cf0e8a61
x
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
128 行增加
和
63 行删除
cmd/hot_mail.php
cmd/hot_mail_2.php
cmd/hot_mail.php
查看文件 @
7cc24d6
...
...
@@ -41,7 +41,7 @@ class HotMail {
private
function
start
(){
_echo
(
'启动预热邮件处理 '
.
getmypid
());
if
(
redis
()
->
add
(
'hot_mail_sync'
,
1
,
6
0
)){
if
(
redis
()
->
add
(
'hot_mail_sync'
,
1
,
3
0
)){
$fob
=
$this
->
getFobHotEmail
();
// 把黑格自己的也算进去
...
...
@@ -63,68 +63,12 @@ class HotMail {
}
catch
(
Throwable
$e
){}
}
$maxId
=
$this
->
db
->
value
(
"select `id` from `lists` order by `id` desc limit 1"
);
$id
=
0
;
while
(
1
){
$ids
=
[];
for
(
$i
=
0
;
$i
<
1000
;
$i
++
){
$ids
[]
=
$i
+
$id
;
}
$id
=
end
(
$ids
);
redis
()
->
rPush
(
'hot_check_ids'
,
implode
(
','
,
$ids
));
if
(
$id
>
$maxId
){
break
;
}
}
}
while
(
1
){
$ids
=
redis
()
->
lPop
(
'hot_check_ids'
);
if
(
$ids
){
$ids
=
explode
(
','
,
$ids
);
$this
->
run
(
$ids
);
}
else
{
echo
'等待'
.
PHP_EOL
;
co
::
sleep
(
2
);
}
}
echo
'已执行完成'
.
PHP_EOL
;
echo
date
(
'd H:i:s'
)
.
' ==》 已执行完成'
.
PHP_EOL
;
}
private
$folder
=
[];
private
function
run
(
$id
){
$list
=
$this
->
db
->
all
(
\Model\listsSql
::
all
(
dbWhere
([
'id'
=>
$id
,
'is_hots'
=>
0
]),
'`id`,`from`,`to`,`folder_id`'
));
foreach
(
$list
as
$item
){
if
(
empty
(
$this
->
folder
[
$item
[
'folder_id'
]])){
$this
->
folder
[
$item
[
'folder_id'
]]
=
folderAlias
(
$this
->
db
->
value
(
\Model\folderSql
::
first
(
$item
[
'folder_id'
],
'folder'
)));
}
// 是否是发件箱
if
(
$this
->
folder
[
$item
[
'folder_id'
]]
==
'发件箱'
){
$w
=
[
'email'
=>
explode
(
','
,
$item
[
'to'
])];
}
else
{
$w
=
[
'email'
=>
$item
[
'from'
]];
}
// 是否在 预热邮箱中
if
(
$this
->
db
->
cache
(
300
)
->
count
(
'select count(*) from `hot_mail` where '
.
dbWhere
(
$w
))){
$ret
=
$this
->
db
->
update
(
listsSql
::
$table
,[
'is_hots'
=>
1
],
dbWhere
([
'id'
=>
$item
[
'id'
]]));
echo
date
(
'd H:i:s'
)
.
' ==》 '
.
$item
[
'id'
]
.
':'
.
$ret
.
"
\n
"
;
}
}
}
/**
* 获取预热邮箱
* shopk的
...
...
@@ -134,7 +78,7 @@ class HotMail {
*/
private
function
getHotEmail
(
$t
=
'e'
)
:
array
{
$url
[
'e'
]
=
'https://oa.shopk.com/api/mail/preheat'
;
$url
[
'w'
]
=
'https://oa.shopk.com/api/mail/write?iswrite=1'
;
$url
[
'w'
]
=
'https://oa.shopk.com/api/mail/write?iswrite=1
&id=11321
'
;
$data
=
@
file_get_contents
(
$url
[
$t
]);
if
(
$data
){
...
...
@@ -174,15 +118,18 @@ swoole_set_process_name('hot-email-run-man');
$pm
=
new
Swoole\Process\Manager
();
$pm
->
addBatch
(
1
0
,
function
(){
$pm
->
addBatch
(
1
,
function
(){
swoole_set_process_name
(
'hot-email-run'
);
include_once
"../vendor/autoload.php"
;
new
HotMail
();
// 执行完了暂停5分钟在执行
sleep
(
120
);
while
(
1
){
new
HotMail
();
// 执行完了暂停5分钟在执行
sleep
(
40
);
}
},
true
);
$pm
->
start
();
...
...
cmd/hot_mail_2.php
0 → 100644
查看文件 @
7cc24d6
<?php
use
Model\listsSql
;
/**
* 处理预热邮箱
* @author:dc
* @time 2024/9/4 11:02
* Class HotMail
*/
class
HotMail
{
public
function
__construct
(){
$this
->
db
=
db
();
$this
->
start
();
}
/**
* shopk那边的预热邮箱
* @var array
*/
private
$hotEmail
=
[];
/**
* @var \Lib\Db|\Lib\DbPool
*/
private
$db
;
/**
* @author:dc
* @time 2024/7/18 14:04
*/
private
function
start
(){
_echo
(
'启动预热邮件处理 '
.
getmypid
());
if
(
redis
()
->
add
(
'hot_mail_sync'
,
1
,
60
)){
$maxId
=
$this
->
db
->
value
(
"select `id` from `lists` order by `id` desc limit 1"
);
$id
=
0
;
while
(
1
){
$ids
=
[];
for
(
$i
=
0
;
$i
<
1000
;
$i
++
){
$ids
[]
=
$i
+
$id
;
}
$id
=
end
(
$ids
);
redis
()
->
rPush
(
'hot_check_ids'
,
implode
(
','
,
$ids
));
if
(
$id
>
$maxId
){
break
;
}
}
}
while
(
1
){
$ids
=
redis
()
->
lPop
(
'hot_check_ids'
);
if
(
$ids
){
$ids
=
explode
(
','
,
$ids
);
$this
->
run
(
$ids
);
}
else
{
echo
'等待'
.
PHP_EOL
;
co
::
sleep
(
2
);
}
}
}
private
$folder
=
[];
private
function
run
(
$id
){
$list
=
$this
->
db
->
all
(
\Model\listsSql
::
all
(
dbWhere
([
'id'
=>
$id
,
'is_hots'
=>
0
]),
'`id`,`from`,`to`,`folder_id`'
));
foreach
(
$list
as
$item
){
if
(
empty
(
$this
->
folder
[
$item
[
'folder_id'
]])){
$this
->
folder
[
$item
[
'folder_id'
]]
=
folderAlias
(
$this
->
db
->
value
(
\Model\folderSql
::
first
(
$item
[
'folder_id'
],
'folder'
)));
}
// 是否是发件箱
if
(
$this
->
folder
[
$item
[
'folder_id'
]]
==
'发件箱'
){
$w
=
[
'email'
=>
explode
(
','
,
$item
[
'to'
])];
}
else
{
$w
=
[
'email'
=>
$item
[
'from'
]];
}
// 是否在 预热邮箱中
if
(
$this
->
db
->
cache
(
300
)
->
count
(
'select count(*) from `hot_mail` where '
.
dbWhere
(
$w
))){
$ret
=
$this
->
db
->
update
(
listsSql
::
$table
,[
'is_hots'
=>
1
],
dbWhere
([
'id'
=>
$item
[
'id'
]]));
echo
date
(
'd H:i:s'
)
.
' ==》 '
.
$item
[
'id'
]
.
':'
.
$ret
.
"
\n
"
;
}
}
}
}
swoole_set_process_name
(
'hot-email-run-man'
);
$pm
=
new
Swoole\Process\Manager
();
$pm
->
addBatch
(
10
,
function
(){
swoole_set_process_name
(
'hot-email-run'
);
include_once
"../vendor/autoload.php"
;
new
HotMail
();
exit
();
},
true
);
$pm
->
start
();
...
...
请
注册
或
登录
后发表评论