| 
...
 | 
...
 | 
@@ -22,23 +22,35 @@ class AutoMail { | 
| 
 | 
 | 
      */
 | 
| 
 | 
 | 
     private function start(){
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         $old = redis()->get('prev_auto_mail_keyword',[]);
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         $filter = isAiAutoMail(true,true);
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         redis()->set('prev_auto_mail_keyword',$filter,86400);
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         $q = array_diff($filter,$old);
 | 
| 
 | 
 | 
         // 差集
 | 
| 
 | 
 | 
         if(!$q){
 | 
| 
 | 
 | 
             return 0;
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         $es = es('email_lists_copy');
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         $not_must = [];
 | 
| 
 | 
 | 
         foreach ($filter as $f){
 | 
| 
 | 
 | 
         foreach ($q as $f){
 | 
| 
 | 
 | 
             list($t,$str) = $f;
 | 
| 
 | 
 | 
             if($t==2){
 | 
| 
 | 
 | 
                 $not_must[] = ["match_phrase"=>["subject"=>$str]];
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
             }elseif ($t==1){
 | 
| 
 | 
 | 
                 $not_must[] = ["match_phrase"=>["from.email"=>$str]];
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
             }
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         // 查询自动回的邮件
 | 
| 
 | 
 | 
         $lists = $es->search([
 | 
| 
 | 
 | 
             "_source"  => ["uuid"],
 | 
| 
 | 
 | 
             "_source"  => ["uuid","subject","from"],
 | 
| 
 | 
 | 
             "query"=>[
 | 
| 
 | 
 | 
                 "constant_score"=>[
 | 
| 
 | 
 | 
                     "filter"=>[
 | 
| 
...
 | 
...
 | 
@@ -48,6 +60,7 @@ class AutoMail { | 
| 
 | 
 | 
                                 ["term"=>["is_auto" =>  0]], // 非auto
 | 
| 
 | 
 | 
                                 ["term"=>["is_hots" =>  0]], // 非预热
 | 
| 
 | 
 | 
                                 ["term"=>["deleted" =>  0]], // 非删除
 | 
| 
 | 
 | 
                                 ["term"=>["source" =>  2]], // 非删除
 | 
| 
 | 
 | 
                                 // 自动关键字
 | 
| 
 | 
 | 
                                 [
 | 
| 
 | 
 | 
                                     "bool"  =>  [
 | 
| 
...
 | 
...
 | 
@@ -60,11 +73,12 @@ class AutoMail { | 
| 
 | 
 | 
                     ]
 | 
| 
 | 
 | 
                 ]
 | 
| 
 | 
 | 
             ]
 | 
| 
 | 
 | 
         ],0,1000,[],1000);
 | 
| 
 | 
 | 
         ],0,1000,['udate'=>'desc'],1000);
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         foreach ($lists['hits']['hits']??[] as $list){
 | 
| 
 | 
 | 
             $id = intval($list['_source']['uuid']??0);
 | 
| 
 | 
 | 
             if($id){
 | 
| 
 | 
 | 
             $list = $list['_source'];
 | 
| 
 | 
 | 
             $id = intval($list['uuid']??0);
 | 
| 
 | 
 | 
              if($id && isAiAutoMail($list['from']['email'],$list['subject'])){
 | 
| 
 | 
 | 
                  _echo("id = ".$id);
 | 
| 
 | 
 | 
                  redis()->rPush('sync_to_es',$id);
 | 
| 
 | 
 | 
              }
 | 
...
 | 
...
 | 
 |