| 
...
 | 
...
 | 
@@ -110,9 +110,26 @@ class SyncToEsCmd { | 
| 
 | 
 | 
                     list($doc_id,$data) = $data;
 | 
| 
 | 
 | 
                     // 主库
 | 
| 
 | 
 | 
                     $this->toDataEs('email_lists_copy',$id,$doc_id,$data);
 | 
| 
 | 
 | 
                     // 个人邮箱的情况
 | 
| 
 | 
 | 
                     if(!$data['postid']){
 | 
| 
 | 
 | 
                         $postids = $this->getPostids($data['email_id']);
 | 
| 
 | 
 | 
                         if($postids){
 | 
| 
 | 
 | 
                             foreach ($postids as $postid){
 | 
| 
 | 
 | 
                                 $data['postid'] = $postid;
 | 
| 
 | 
 | 
                                 $data['source'] = 1;
 | 
| 
 | 
 | 
                                 // 分库 个人邮箱
 | 
| 
 | 
 | 
                                 $this->toDataEs('email_lists_branch_'.$data['postid'],$id,$doc_id,$data);
 | 
| 
 | 
 | 
                             }
 | 
| 
 | 
 | 
                         }else{
 | 
| 
 | 
 | 
                             // 分库 其他 非fob数据源
 | 
| 
 | 
 | 
                             $this->toDataEs('email_lists_branch_0',$id,$doc_id,$data);
 | 
| 
 | 
 | 
                         }
 | 
| 
 | 
 | 
                     }else{
 | 
| 
 | 
 | 
                         // 分库
 | 
| 
 | 
 | 
                         $this->toDataEs('email_lists_branch_'.$data['postid'],$id,$doc_id,$data);
 | 
| 
 | 
 | 
                     }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
                 }
 | 
| 
 | 
 | 
             }else{
 | 
| 
 | 
 | 
                 // 没有数据时暂停1秒
 | 
| 
 | 
 | 
                 sleep(1);
 | 
| 
...
 | 
...
 | 
@@ -122,6 +139,24 @@ class SyncToEsCmd { | 
| 
 | 
 | 
     }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     /**
 | 
| 
 | 
 | 
      * 个人邮箱情况
 | 
| 
 | 
 | 
      * @param $email_id
 | 
| 
 | 
 | 
      * @author:dc
 | 
| 
 | 
 | 
      * @time 2025/8/5 14:53
 | 
| 
 | 
 | 
      */
 | 
| 
 | 
 | 
     private function getPostids($email_id){
 | 
| 
 | 
 | 
         $postids = $this->fob_db->throw()->cache(300)->all("select `post_id` from `e_mail_binds` where `source` = 1 and `email_id` = {$email_id} and `deleted_at` is null");
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         if($postids){
 | 
| 
 | 
 | 
             return array_column($postids,'post_id');
 | 
| 
 | 
 | 
         }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         return [];
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     }
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
     /**
 | 
| 
 | 
 | 
      * @param $id
 | 
| 
 | 
 | 
      * @param $is_check_body
 | 
| 
 | 
 | 
      * @return array|false
 | 
| 
...
 | 
...
 | 
@@ -309,8 +344,8 @@ class SyncToEsCmd { | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         //每60秒验证一次
 | 
| 
 | 
 | 
         if(redis()->add('fob_bind_mail_times_check:'.$email_id,1,60)){
 | 
| 
 | 
 | 
             $lastpostid = $this->fob_db->throw()->value("select `post_id` from `e_mail_binds_log` where `email_id` = '{$email_id}' order by `id` desc limit 1");
 | 
| 
 | 
 | 
             $thelast = $this->fob_db->throw()->first("select * from `e_mail_binds` where `email_id` = '{$email_id}' and `deleted_at` is null order by `id` desc limit 1");
 | 
| 
 | 
 | 
             $lastpostid = $this->fob_db->throw()->value("select `post_id` from `e_mail_binds_log` where `source` = 2 and `email_id` = '{$email_id}' order by `id` desc limit 1");
 | 
| 
 | 
 | 
             $thelast = $this->fob_db->throw()->first("select * from `e_mail_binds` where `source` = 2 and `email_id` = '{$email_id}' and `deleted_at` is null order by `id` desc limit 1");
 | 
| 
 | 
 | 
             if(!$thelast){
 | 
| 
 | 
 | 
                 return [0,0];
 | 
| 
 | 
 | 
             }
 | 
| 
...
 | 
...
 | 
@@ -338,7 +373,7 @@ class SyncToEsCmd { | 
| 
 | 
 | 
         // 查询历史记录
 | 
| 
 | 
 | 
         $times = redis()->getSet('fob_bind_mail_times3:'.$email_id,300,function ($email_id){
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
             $times = $this->fob_db->throw()->all("select `post_id`,`bind_time`,`source` from `e_mail_binds_log` where `email_id` = {$email_id} order by `bind_time` desc ");
 | 
| 
 | 
 | 
             $times = $this->fob_db->throw()->all("select `post_id`,`bind_time`,`source` from `e_mail_binds_log` where `source` = 2 and `email_id` = {$email_id} order by `bind_time` desc ");
 | 
| 
 | 
 | 
             if(!$times){
 | 
| 
 | 
 | 
                 return [];
 | 
| 
 | 
 | 
             }
 | 
| 
...
 | 
...
 | 
@@ -361,7 +396,7 @@ class SyncToEsCmd { | 
| 
 | 
 | 
         // 没有找到历史,就找绑定表
 | 
| 
 | 
 | 
         if(empty($data)){
 | 
| 
 | 
 | 
             $data = redis()->getSet('fob_bind_mail3:'.$email_id,300,function ($email_id){
 | 
| 
 | 
 | 
                 return $this->fob_db->throw()->first("select `post_id`,`source` from `e_mail_binds` where `email_id` = '{$email_id}' and `deleted_at` is null order by `id` desc limit 1");
 | 
| 
 | 
 | 
                 return $this->fob_db->throw()->first("select `post_id`,`source` from `e_mail_binds` where `source` = 2 and `email_id` = '{$email_id}' and `deleted_at` is null order by `id` desc limit 1");
 | 
| 
 | 
 | 
             },$email_id);
 | 
| 
 | 
 | 
 
 | 
| 
 | 
 | 
         }
 | 
...
 | 
...
 | 
 |