正在显示
1 个修改的文件
包含
22 行增加
和
8 行删除
| @@ -22,23 +22,35 @@ class AutoMail { | @@ -22,23 +22,35 @@ class AutoMail { | ||
| 22 | */ | 22 | */ |
| 23 | private function start(){ | 23 | private function start(){ |
| 24 | 24 | ||
| 25 | + $old = redis()->get('prev_auto_mail_keyword',[]); | ||
| 26 | + | ||
| 25 | $filter = isAiAutoMail(true,true); | 27 | $filter = isAiAutoMail(true,true); |
| 26 | 28 | ||
| 29 | + redis()->set('prev_auto_mail_keyword',$filter,86400); | ||
| 30 | + | ||
| 31 | + $q = array_diff($filter,$old); | ||
| 32 | + // 差集 | ||
| 33 | + if(!$q){ | ||
| 34 | + return 0; | ||
| 35 | + } | ||
| 36 | + | ||
| 27 | $es = es('email_lists_copy'); | 37 | $es = es('email_lists_copy'); |
| 28 | 38 | ||
| 29 | $not_must = []; | 39 | $not_must = []; |
| 30 | - foreach ($filter as $f){ | 40 | + foreach ($q as $f){ |
| 31 | list($t,$str) = $f; | 41 | list($t,$str) = $f; |
| 32 | if($t==2){ | 42 | if($t==2){ |
| 33 | $not_must[] = ["match_phrase"=>["subject"=>$str]]; | 43 | $not_must[] = ["match_phrase"=>["subject"=>$str]]; |
| 44 | + | ||
| 34 | }elseif ($t==1){ | 45 | }elseif ($t==1){ |
| 35 | $not_must[] = ["match_phrase"=>["from.email"=>$str]]; | 46 | $not_must[] = ["match_phrase"=>["from.email"=>$str]]; |
| 47 | + | ||
| 36 | } | 48 | } |
| 37 | } | 49 | } |
| 38 | 50 | ||
| 39 | // 查询自动回的邮件 | 51 | // 查询自动回的邮件 |
| 40 | $lists = $es->search([ | 52 | $lists = $es->search([ |
| 41 | - "_source" => ["uuid"], | 53 | + "_source" => ["uuid","subject","from"], |
| 42 | "query"=>[ | 54 | "query"=>[ |
| 43 | "constant_score"=>[ | 55 | "constant_score"=>[ |
| 44 | "filter"=>[ | 56 | "filter"=>[ |
| @@ -48,6 +60,7 @@ class AutoMail { | @@ -48,6 +60,7 @@ class AutoMail { | ||
| 48 | ["term"=>["is_auto" => 0]], // 非auto | 60 | ["term"=>["is_auto" => 0]], // 非auto |
| 49 | ["term"=>["is_hots" => 0]], // 非预热 | 61 | ["term"=>["is_hots" => 0]], // 非预热 |
| 50 | ["term"=>["deleted" => 0]], // 非删除 | 62 | ["term"=>["deleted" => 0]], // 非删除 |
| 63 | + ["term"=>["source" => 2]], // 非删除 | ||
| 51 | // 自动关键字 | 64 | // 自动关键字 |
| 52 | [ | 65 | [ |
| 53 | "bool" => [ | 66 | "bool" => [ |
| @@ -60,14 +73,15 @@ class AutoMail { | @@ -60,14 +73,15 @@ class AutoMail { | ||
| 60 | ] | 73 | ] |
| 61 | ] | 74 | ] |
| 62 | ] | 75 | ] |
| 63 | - ],0,1000,[],1000); | 76 | + ],0,1000,['udate'=>'desc'],1000); |
| 64 | 77 | ||
| 65 | foreach ($lists['hits']['hits']??[] as $list){ | 78 | foreach ($lists['hits']['hits']??[] as $list){ |
| 66 | - $id = intval($list['_source']['uuid']??0); | ||
| 67 | - if($id){ | ||
| 68 | - _echo("id = ".$id); | ||
| 69 | - redis()->rPush('sync_to_es',$id); | ||
| 70 | - } | 79 | + $list = $list['_source']; |
| 80 | + $id = intval($list['uuid']??0); | ||
| 81 | + if($id && isAiAutoMail($list['from']['email'],$list['subject'])){ | ||
| 82 | + _echo("id = ".$id); | ||
| 83 | + redis()->rPush('sync_to_es',$id); | ||
| 84 | + } | ||
| 71 | } | 85 | } |
| 72 | 86 | ||
| 73 | } | 87 | } |
-
请 注册 或 登录 后发表评论