正在显示
3 个修改的文件
包含
23 行增加
和
7 行删除
@@ -218,13 +218,14 @@ function create_coroutine(array &$cid,int &$isRunMaxCNum,$worker_id){ | @@ -218,13 +218,14 @@ function create_coroutine(array &$cid,int &$isRunMaxCNum,$worker_id){ | ||
218 | function sync($worker_id=0){ | 218 | function sync($worker_id=0){ |
219 | // 需要同步的id | 219 | // 需要同步的id |
220 | $id = redis()->lPop('sync_email_lists'); | 220 | $id = redis()->lPop('sync_email_lists'); |
221 | - _echo($worker_id.': 协程('.co::getCid().'):抢到 '.$id); | ||
222 | 221 | ||
223 | if(!$id){ | 222 | if(!$id){ |
224 | co::sleep(1); | 223 | co::sleep(1); |
225 | return -1; | 224 | return -1; |
226 | } | 225 | } |
227 | 226 | ||
227 | + _echo($worker_id.': 协程('.co::getCid().'):抢到 '.$id); | ||
228 | + | ||
228 | $email = db()->first(\Model\emailSql::first($id)); | 229 | $email = db()->first(\Model\emailSql::first($id)); |
229 | if(!$email){ | 230 | if(!$email){ |
230 | return 0; | 231 | return 0; |
@@ -61,19 +61,23 @@ class Mail { | @@ -61,19 +61,23 @@ class Mail { | ||
61 | $folder['name'] = explode('/',$folder['parseFolder']); | 61 | $folder['name'] = explode('/',$folder['parseFolder']); |
62 | $pid = 0; | 62 | $pid = 0; |
63 | foreach ($folder['id'] as $k=>$item){ | 63 | foreach ($folder['id'] as $k=>$item){ |
64 | - // 插入到数据库 | ||
65 | - $pid = $db->insert( | ||
66 | - folderSql::$table, | ||
67 | - [ | 64 | + $data = [ |
68 | 'email_id' => $email_id, | 65 | 'email_id' => $email_id, |
69 | 'folder' => $folder['name'][$k], | 66 | 'folder' => $folder['name'][$k], |
70 | 'origin_folder' => $item, | 67 | 'origin_folder' => $item, |
71 | 'pid' => $pid | 68 | 'pid' => $pid |
72 | - ] | ||
73 | - ,false | 69 | + ]; |
70 | + | ||
71 | + if(!$db->value(folderSql::has($data))){ | ||
72 | + // 插入到数据库 | ||
73 | + $pid = $db->insert( | ||
74 | + folderSql::$table, | ||
75 | + $data, | ||
76 | + false | ||
74 | ); | 77 | ); |
75 | } | 78 | } |
76 | } | 79 | } |
80 | + } | ||
77 | $db->commit(); | 81 | $db->commit(); |
78 | 82 | ||
79 | } | 83 | } |
@@ -25,6 +25,17 @@ class folderSql { | @@ -25,6 +25,17 @@ class folderSql { | ||
25 | } | 25 | } |
26 | 26 | ||
27 | 27 | ||
28 | + /** | ||
29 | + * 是否存在,存在则返回 id | ||
30 | + * @param $where | ||
31 | + * @return string | ||
32 | + * @author:dc | ||
33 | + * @time 2023/2/18 11:48 | ||
34 | + */ | ||
35 | + public static function has($where){ | ||
36 | + return "select `id` from `".self::$table."` where ".dbWhere($where); | ||
37 | + } | ||
38 | + | ||
28 | 39 | ||
29 | 40 | ||
30 | 41 |
-
请 注册 或 登录 后发表评论