作者 邓超

es

@@ -110,8 +110,25 @@ class SyncToEsCmd { @@ -110,8 +110,25 @@ class SyncToEsCmd {
110 list($doc_id,$data) = $data; 110 list($doc_id,$data) = $data;
111 // 主库 111 // 主库
112 $this->toDataEs('email_lists_copy',$id,$doc_id,$data); 112 $this->toDataEs('email_lists_copy',$id,$doc_id,$data);
113 - // 分库  
114 - $this->toDataEs('email_lists_branch_'.$data['postid'],$id,$doc_id,$data); 113 + // 个人邮箱的情况
  114 + if(!$data['postid']){
  115 + $postids = $this->getPostids($data['email_id']);
  116 + if($postids){
  117 + foreach ($postids as $postid){
  118 + $data['postid'] = $postid;
  119 + $data['source'] = 1;
  120 + // 分库 个人邮箱
  121 + $this->toDataEs('email_lists_branch_'.$data['postid'],$id,$doc_id,$data);
  122 + }
  123 + }else{
  124 + // 分库 其他 非fob数据源
  125 + $this->toDataEs('email_lists_branch_0',$id,$doc_id,$data);
  126 + }
  127 + }else{
  128 + // 分库
  129 + $this->toDataEs('email_lists_branch_'.$data['postid'],$id,$doc_id,$data);
  130 + }
  131 +
115 } 132 }
116 }else{ 133 }else{
117 // 没有数据时暂停1秒 134 // 没有数据时暂停1秒
@@ -122,6 +139,24 @@ class SyncToEsCmd { @@ -122,6 +139,24 @@ class SyncToEsCmd {
122 } 139 }
123 140
124 /** 141 /**
  142 + * 个人邮箱情况
  143 + * @param $email_id
  144 + * @author:dc
  145 + * @time 2025/8/5 14:53
  146 + */
  147 + private function getPostids($email_id){
  148 + $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");
  149 +
  150 + if($postids){
  151 + return array_column($postids,'post_id');
  152 + }
  153 +
  154 + return [];
  155 +
  156 + }
  157 +
  158 +
  159 + /**
125 * @param $id 160 * @param $id
126 * @param $is_check_body 161 * @param $is_check_body
127 * @return array|false 162 * @return array|false
@@ -309,8 +344,8 @@ class SyncToEsCmd { @@ -309,8 +344,8 @@ class SyncToEsCmd {
309 344
310 //每60秒验证一次 345 //每60秒验证一次
311 if(redis()->add('fob_bind_mail_times_check:'.$email_id,1,60)){ 346 if(redis()->add('fob_bind_mail_times_check:'.$email_id,1,60)){
312 - $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");  
313 - $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"); 347 + $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");
  348 + $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");
314 if(!$thelast){ 349 if(!$thelast){
315 return [0,0]; 350 return [0,0];
316 } 351 }
@@ -338,7 +373,7 @@ class SyncToEsCmd { @@ -338,7 +373,7 @@ class SyncToEsCmd {
338 // 查询历史记录 373 // 查询历史记录
339 $times = redis()->getSet('fob_bind_mail_times3:'.$email_id,300,function ($email_id){ 374 $times = redis()->getSet('fob_bind_mail_times3:'.$email_id,300,function ($email_id){
340 375
341 - $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 "); 376 + $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 ");
342 if(!$times){ 377 if(!$times){
343 return []; 378 return [];
344 } 379 }
@@ -361,7 +396,7 @@ class SyncToEsCmd { @@ -361,7 +396,7 @@ class SyncToEsCmd {
361 // 没有找到历史,就找绑定表 396 // 没有找到历史,就找绑定表
362 if(empty($data)){ 397 if(empty($data)){
363 $data = redis()->getSet('fob_bind_mail3:'.$email_id,300,function ($email_id){ 398 $data = redis()->getSet('fob_bind_mail3:'.$email_id,300,function ($email_id){
364 - 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"); 399 + 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");
365 },$email_id); 400 },$email_id);
366 401
367 } 402 }