...
|
...
|
@@ -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);
|
|
|
}
|
|
|
|
...
|
...
|
|