作者 邓超

重新同步

... ... @@ -29,17 +29,21 @@ class AutoMail {
echo date('Y-m-d H:i:s');
echo "\n";
$at = 0;
if(redis()->get('resync_to_es_inbox') == 1){
redis()->set('resync_to_es_inbox',2,3600);
$this->es = es();
while (true){
$postid = redis()->lPop('resync_to_es_inbox_list');
if (!is_numeric($postid)){
break;
}
if(redis()->add('resync_to_es_inbox:'.$postid,1,$postid?600:7200)){
if (!$postid){
$post_ids = fob_mysql()->all("select `post_id` from `e_mail_binds` group by `post_id`");
if($post_ids){
$post_ids = array_column($post_ids,'post_id','post_id');
}
$this->es = es();
}else{
$post_ids = [$postid];
}
foreach ($post_ids as $post_id){
$total = $this->essss(0,$post_id,0);
... ... @@ -48,8 +52,10 @@ class AutoMail {
$at += $total + $autoTotal;
}
redis()->set('resync_to_es_inbox',2,600);
}
}
echo "总数量 {$at} ";
echo "end ";
echo date('Y-m-d H:i:s');
... ...
... ... @@ -1137,11 +1137,19 @@ class Home extends Base {
* @time 2025/9/18 16:50
*/
public function resync_to_es(){
if(redis()->add('resync_to_es_inbox',1,600)){
app()->e('请求成功,请等待5-15分钟');
}else{
$postid = (int) app()->request('postid');
if(redis()->has('resync_to_es_inbox:'.$postid)){
app()->e('失败,请等待10分钟后在重试');
}
$h = (int) date('H');
if(!$postid && $h>=6&& $h<=18){
app()->e('刷所有项目只能在早6点前或晚18点后');
}
redis()->rPush('resync_to_es_inbox_list',$postid);
app()->e('请求成功,请等待5-15分钟');
}
... ...