作者 张关杰

server

... ... @@ -86,7 +86,7 @@ class SyncToEsCmd {
public function handler(){
$es = es(); // 第一个库,即将丢弃
// $es = es(); // 第一个库,即将丢弃
$es2 = es('email_lists_copy'); // 第二个库 新
while (!$this->isStop()){
... ... @@ -94,7 +94,7 @@ class SyncToEsCmd {
$id = redis()->lPop('sync_to_es');
$code = 500;
if($id){
// redis()->rPush('sync_to_es2',$id);
redis()->rPush('sync_to_es2',$id);
$doc_id = '';
try {
... ... @@ -136,7 +136,7 @@ class SyncToEsCmd {
$code = $es2->save($doc_id,$data);
// 这个验证数据没问题后会丢弃
$code = $es->save($doc_id,$data);
// $code = $es->save($doc_id,$data);
}
... ...
... ... @@ -69,7 +69,7 @@ class MailListV2Es2 extends Base {
// $where['is_hots'] = 0;
// 项目id
$where['postid'] = intval(app()->request('postid'))?:-1;
$where['postid'] = intval(app()->request('postid',-1));
$where['folder_as_int'] = 404; // 搜索那个文件夹
if($folder=='收件箱'){
$where['is_hots'] = 0;
... ... @@ -187,8 +187,8 @@ class MailListV2Es2 extends Base {
}
}
logs('lists '.json_encode(['query'=>['constant_score'=>['filter'=>$query]]]));
$result = $this->es->search(['query'=>['constant_score'=>['filter'=>$query]]],($page-1) * $limit,$limit,['udate'=>"desc"]);
// logs('lists '.json_encode(['query'=>['constant_score'=>['filter'=>$query]]]));
$result = $this->es->search(['query'=>['constant_score'=>['filter'=>$query]]],($page-1) * $limit,$limit,['udate'=>"desc"],(($where['is_hots']??0)==1||($where['is_auto']??0)==1||$folder=='垃圾箱')?10000:true);
$total = $result['hits']['total']['value']??0;
... ... @@ -252,23 +252,28 @@ class MailListV2Es2 extends Base {
$assign = app()->request('assign');
// 说明是子账号
if(!empty($assign['assign'])){
return [
'bool' => [
'should' =>[
[
if(!empty($assign['from'])){
$f = [
'query_string'=>[
'query'=>(str_contains($folder, '发件箱')?'to':'from.email').':('.implode(' OR ',array_map(function($e){return '"'.$e.'"';},$assign['from'])).')'
]
],
];
}
$r = [
'bool' => [
'should' =>[
[
'terms'=>[
'email_id'=>$assign['email_id']
'email_id'=>$assign['email_id']??[0]
]
]
]
]
];
if(!empty($f)){
$r['bool']['should'][] = $f;
}
return $r;
}
return [];
... ... @@ -283,7 +288,7 @@ class MailListV2Es2 extends Base {
if(!empty($assign['assign'])){
return [
'terms'=>[
'email_id'=>$assign['email_id']?:[-1]
'email_id'=>($assign['email_id']??[0])?:[-1]
]
];
}
... ... @@ -304,7 +309,7 @@ class MailListV2Es2 extends Base {
'bool'=>[
'must'=>[
['term'=>['deleted'=>0]],
['term'=>['postid'=>app()->request('postid',-1)]],
['term'=>['postid'=> intval(app()->request('postid',-1))]],
['term'=>['source'=>2]],
]
]
... ... @@ -395,8 +400,15 @@ class MailListV2Es2 extends Base {
$body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]];
if($this->assignSql3($folder))
$body['query']['bool']['must'][] = $this->assignSql3($folder);
logs('hot hot:'.json_encode($body));
return $this->es->count($body);
// logs('hot hot:'.json_encode($body));
// return $this->es->count($body);
$key = 'hot_count:'.md5(json_encode($body));
$a = redis()->get($key);
if(!is_numeric($a)){
$a = $this->es->count($body);
redis()->set($key,$a,strtotime(date('Y-m-d',strtotime("+1 day"))) - time());
}
return $a;
}
private function countMail($body,$folder,$seen=null){
... ... @@ -427,7 +439,16 @@ class MailListV2Es2 extends Base {
$body['query']['bool']['must'][] = ['term'=>['is_hots'=>0]];
$body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]];
if($this->assignSql($folder)) $body['query']['bool']['must'][] = $this->assignSql($folder);
logs('count :'.json_encode($body));
// logs('count :'.json_encode($body));
if($folder=='垃圾箱'){
$key = 'laji_count:'.md5(json_encode($body));
$a = redis()->get($key);
if(!is_numeric($a)){
$a = $this->es->count($body);
redis()->set($key,$a,strtotime(date('Y-m-d',strtotime("+1 day"))) - time());
}
return $a;
}
return $this->es->count($body);
}
... ...
... ... @@ -18,8 +18,8 @@ return [
// 这个是单独处理的 aicc那边的应用
'v2/lists' => [\Controller\v2\Home::class, 'lists'],
// 黑格专用路由
'fob/lists' => [\Controller\fob_ai\MailListV2Es::class, 'lists'],
'fob/count' => [\Controller\fob_ai\MailListV2Es::class, 'count'],// 统计数量
'fob/lists' => [\Controller\fob_ai\MailListV2Es2::class, 'lists'],
'fob/count' => [\Controller\fob_ai\MailListV2Es2::class, 'count'],// 统计数量
// 查询es的
'fob/es/lists' => [\Controller\fob_ai\MailListV2Es::class, 'lists'],
... ...
... ... @@ -188,7 +188,7 @@ class SyncMail {
] as $em){
if(str_contains($login->getMessage(), $em)){
if(redis()->incr('err_mail:'.$this->emailId(),1800)>2){
if(redis()->incr('err_mail:'.$this->emailId(),1800)>2 || strpos($this->email['email'],'@gmail.com')){
$this->db->update(
\Model\emailSql::$table,
['pwd_error'=>1],
... ...