正在显示
1 个修改的文件
包含
91 行增加
和
0 行删除
cmd/hot_mail_3.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +use Model\listsSql; | ||
4 | + | ||
5 | + | ||
6 | +/** | ||
7 | + * 把预热的邮件进行归档处理 减少数量量 | ||
8 | + * @author:dc | ||
9 | + * @time 2025/1/17 17:10 | ||
10 | + * Class HotMail | ||
11 | + */ | ||
12 | +class HotMailArchive { | ||
13 | + | ||
14 | + public function __construct(){ | ||
15 | + $this->db = db(); | ||
16 | + $this->start(); | ||
17 | + } | ||
18 | + | ||
19 | + /** | ||
20 | + * shopk那边的预热邮箱 | ||
21 | + * @var array | ||
22 | + */ | ||
23 | + private $hotEmail = []; | ||
24 | + | ||
25 | + /** | ||
26 | + * @var \Lib\Db|\Lib\DbPool | ||
27 | + */ | ||
28 | + private $db; | ||
29 | + | ||
30 | + | ||
31 | + /** | ||
32 | + * @author:dc | ||
33 | + * @time 2024/7/18 14:04 | ||
34 | + */ | ||
35 | + private function start(){ | ||
36 | + _echo('启动预热邮件归档处理 '.getmypid()); | ||
37 | + | ||
38 | + $id = 0; | ||
39 | + while (1){ | ||
40 | + $id = $this->run($id); | ||
41 | + if($id === 0){ | ||
42 | + break; | ||
43 | + } | ||
44 | + } | ||
45 | + | ||
46 | + } | ||
47 | + | ||
48 | + | ||
49 | + private function run($id):int { | ||
50 | + | ||
51 | + $list = $this->db->first(\Model\listsSql::first(dbWhere(['id.>'=>$id,'is_hots'=>1]))); | ||
52 | + if(!$list){ | ||
53 | + return 0; | ||
54 | + } | ||
55 | + _echo('正在移动 '.$list['id']); | ||
56 | + $ret = $this->db->throw()->insert('lists_hot',$list,false); | ||
57 | +// if($ret){ | ||
58 | +// $this->db->delete(listsSql::$table,['id'=>$list['id']]); | ||
59 | +// } | ||
60 | + return $list['id']; | ||
61 | + | ||
62 | + } | ||
63 | + | ||
64 | + | ||
65 | +} | ||
66 | + | ||
67 | + | ||
68 | +include_once "../vendor/autoload.php"; | ||
69 | + | ||
70 | +new HotMailArchive(); | ||
71 | + | ||
72 | +_echo('执行完成 等待下次执行'); | ||
73 | +// | ||
74 | +//swoole_set_process_name('hot-email-run-man'); | ||
75 | +// | ||
76 | +//$pm = new Swoole\Process\Manager(); | ||
77 | +// | ||
78 | +//$pm->addBatch(3,function (){ | ||
79 | +// | ||
80 | +// swoole_set_process_name('hot-email-run'); | ||
81 | +// | ||
82 | +// include_once "../vendor/autoload.php"; | ||
83 | +// | ||
84 | +// new HotMail(); | ||
85 | +// | ||
86 | +// exit(); | ||
87 | +//},true); | ||
88 | +// | ||
89 | +//$pm->start(); | ||
90 | + | ||
91 | + |
-
请 注册 或 登录 后发表评论