作者 张关杰

server

@@ -86,7 +86,7 @@ class SyncToEsCmd { @@ -86,7 +86,7 @@ class SyncToEsCmd {
86 86
87 public function handler(){ 87 public function handler(){
88 88
89 - $es = es(); // 第一个库,即将丢弃 89 + // $es = es(); // 第一个库,即将丢弃
90 $es2 = es('email_lists_copy'); // 第二个库 新 90 $es2 = es('email_lists_copy'); // 第二个库 新
91 91
92 while (!$this->isStop()){ 92 while (!$this->isStop()){
@@ -94,7 +94,7 @@ class SyncToEsCmd { @@ -94,7 +94,7 @@ class SyncToEsCmd {
94 $id = redis()->lPop('sync_to_es'); 94 $id = redis()->lPop('sync_to_es');
95 $code = 500; 95 $code = 500;
96 if($id){ 96 if($id){
97 - // redis()->rPush('sync_to_es2',$id); 97 + redis()->rPush('sync_to_es2',$id);
98 98
99 $doc_id = ''; 99 $doc_id = '';
100 try { 100 try {
@@ -136,7 +136,7 @@ class SyncToEsCmd { @@ -136,7 +136,7 @@ class SyncToEsCmd {
136 $code = $es2->save($doc_id,$data); 136 $code = $es2->save($doc_id,$data);
137 137
138 // 这个验证数据没问题后会丢弃 138 // 这个验证数据没问题后会丢弃
139 - $code = $es->save($doc_id,$data); 139 + // $code = $es->save($doc_id,$data);
140 140
141 } 141 }
142 142
@@ -69,7 +69,7 @@ class MailListV2Es2 extends Base { @@ -69,7 +69,7 @@ class MailListV2Es2 extends Base {
69 69
70 // $where['is_hots'] = 0; 70 // $where['is_hots'] = 0;
71 // 项目id 71 // 项目id
72 - $where['postid'] = intval(app()->request('postid'))?:-1; 72 + $where['postid'] = intval(app()->request('postid',-1));
73 $where['folder_as_int'] = 404; // 搜索那个文件夹 73 $where['folder_as_int'] = 404; // 搜索那个文件夹
74 if($folder=='收件箱'){ 74 if($folder=='收件箱'){
75 $where['is_hots'] = 0; 75 $where['is_hots'] = 0;
@@ -187,8 +187,8 @@ class MailListV2Es2 extends Base { @@ -187,8 +187,8 @@ class MailListV2Es2 extends Base {
187 } 187 }
188 } 188 }
189 189
190 - logs('lists '.json_encode(['query'=>['constant_score'=>['filter'=>$query]]]));  
191 - $result = $this->es->search(['query'=>['constant_score'=>['filter'=>$query]]],($page-1) * $limit,$limit,['udate'=>"desc"]); 190 + // logs('lists '.json_encode(['query'=>['constant_score'=>['filter'=>$query]]]));
  191 + $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);
192 192
193 193
194 $total = $result['hits']['total']['value']??0; 194 $total = $result['hits']['total']['value']??0;
@@ -252,23 +252,28 @@ class MailListV2Es2 extends Base { @@ -252,23 +252,28 @@ class MailListV2Es2 extends Base {
252 $assign = app()->request('assign'); 252 $assign = app()->request('assign');
253 // 说明是子账号 253 // 说明是子账号
254 if(!empty($assign['assign'])){ 254 if(!empty($assign['assign'])){
255 - return [  
256 - 'bool' => [  
257 - 'should' =>[  
258 - [ 255 + if(!empty($assign['from'])){
  256 + $f = [
259 'query_string'=>[ 257 'query_string'=>[
260 'query'=>(str_contains($folder, '发件箱')?'to':'from.email').':('.implode(' OR ',array_map(function($e){return '"'.$e.'"';},$assign['from'])).')' 258 'query'=>(str_contains($folder, '发件箱')?'to':'from.email').':('.implode(' OR ',array_map(function($e){return '"'.$e.'"';},$assign['from'])).')'
261 ] 259 ]
262 - ], 260 + ];
  261 + }
  262 + $r = [
  263 + 'bool' => [
  264 + 'should' =>[
263 [ 265 [
264 'terms'=>[ 266 'terms'=>[
265 - 'email_id'=>$assign['email_id'] 267 + 'email_id'=>$assign['email_id']??[0]
266 ] 268 ]
267 ] 269 ]
268 ] 270 ]
269 ] 271 ]
270 ]; 272 ];
271 - 273 + if(!empty($f)){
  274 + $r['bool']['should'][] = $f;
  275 + }
  276 + return $r;
272 } 277 }
273 278
274 return []; 279 return [];
@@ -283,7 +288,7 @@ class MailListV2Es2 extends Base { @@ -283,7 +288,7 @@ class MailListV2Es2 extends Base {
283 if(!empty($assign['assign'])){ 288 if(!empty($assign['assign'])){
284 return [ 289 return [
285 'terms'=>[ 290 'terms'=>[
286 - 'email_id'=>$assign['email_id']?:[-1] 291 + 'email_id'=>($assign['email_id']??[0])?:[-1]
287 ] 292 ]
288 ]; 293 ];
289 } 294 }
@@ -304,7 +309,7 @@ class MailListV2Es2 extends Base { @@ -304,7 +309,7 @@ class MailListV2Es2 extends Base {
304 'bool'=>[ 309 'bool'=>[
305 'must'=>[ 310 'must'=>[
306 ['term'=>['deleted'=>0]], 311 ['term'=>['deleted'=>0]],
307 - ['term'=>['postid'=>app()->request('postid',-1)]], 312 + ['term'=>['postid'=> intval(app()->request('postid',-1))]],
308 ['term'=>['source'=>2]], 313 ['term'=>['source'=>2]],
309 ] 314 ]
310 ] 315 ]
@@ -395,8 +400,15 @@ class MailListV2Es2 extends Base { @@ -395,8 +400,15 @@ class MailListV2Es2 extends Base {
395 $body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]]; 400 $body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]];
396 if($this->assignSql3($folder)) 401 if($this->assignSql3($folder))
397 $body['query']['bool']['must'][] = $this->assignSql3($folder); 402 $body['query']['bool']['must'][] = $this->assignSql3($folder);
398 - logs('hot hot:'.json_encode($body));  
399 - return $this->es->count($body); 403 + // logs('hot hot:'.json_encode($body));
  404 + // return $this->es->count($body);
  405 + $key = 'hot_count:'.md5(json_encode($body));
  406 + $a = redis()->get($key);
  407 + if(!is_numeric($a)){
  408 + $a = $this->es->count($body);
  409 + redis()->set($key,$a,strtotime(date('Y-m-d',strtotime("+1 day"))) - time());
  410 + }
  411 + return $a;
400 } 412 }
401 413
402 private function countMail($body,$folder,$seen=null){ 414 private function countMail($body,$folder,$seen=null){
@@ -427,7 +439,16 @@ class MailListV2Es2 extends Base { @@ -427,7 +439,16 @@ class MailListV2Es2 extends Base {
427 $body['query']['bool']['must'][] = ['term'=>['is_hots'=>0]]; 439 $body['query']['bool']['must'][] = ['term'=>['is_hots'=>0]];
428 $body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]]; 440 $body['query']['bool']['must'][] = ['term'=>['folder_as_int'=>folder2int($folder)]];
429 if($this->assignSql($folder)) $body['query']['bool']['must'][] = $this->assignSql($folder); 441 if($this->assignSql($folder)) $body['query']['bool']['must'][] = $this->assignSql($folder);
430 - logs('count :'.json_encode($body)); 442 + // logs('count :'.json_encode($body));
  443 + if($folder=='垃圾箱'){
  444 + $key = 'laji_count:'.md5(json_encode($body));
  445 + $a = redis()->get($key);
  446 + if(!is_numeric($a)){
  447 + $a = $this->es->count($body);
  448 + redis()->set($key,$a,strtotime(date('Y-m-d',strtotime("+1 day"))) - time());
  449 + }
  450 + return $a;
  451 + }
431 return $this->es->count($body); 452 return $this->es->count($body);
432 } 453 }
433 454
@@ -18,8 +18,8 @@ return [ @@ -18,8 +18,8 @@ return [
18 // 这个是单独处理的 aicc那边的应用 18 // 这个是单独处理的 aicc那边的应用
19 'v2/lists' => [\Controller\v2\Home::class, 'lists'], 19 'v2/lists' => [\Controller\v2\Home::class, 'lists'],
20 // 黑格专用路由 20 // 黑格专用路由
21 - 'fob/lists' => [\Controller\fob_ai\MailListV2Es::class, 'lists'],  
22 - 'fob/count' => [\Controller\fob_ai\MailListV2Es::class, 'count'],// 统计数量 21 + 'fob/lists' => [\Controller\fob_ai\MailListV2Es2::class, 'lists'],
  22 + 'fob/count' => [\Controller\fob_ai\MailListV2Es2::class, 'count'],// 统计数量
23 23
24 // 查询es的 24 // 查询es的
25 'fob/es/lists' => [\Controller\fob_ai\MailListV2Es::class, 'lists'], 25 'fob/es/lists' => [\Controller\fob_ai\MailListV2Es::class, 'lists'],
@@ -188,7 +188,7 @@ class SyncMail { @@ -188,7 +188,7 @@ class SyncMail {
188 ] as $em){ 188 ] as $em){
189 if(str_contains($login->getMessage(), $em)){ 189 if(str_contains($login->getMessage(), $em)){
190 190
191 - if(redis()->incr('err_mail:'.$this->emailId(),1800)>2){ 191 + if(redis()->incr('err_mail:'.$this->emailId(),1800)>2 || strpos($this->email['email'],'@gmail.com')){
192 $this->db->update( 192 $this->db->update(
193 \Model\emailSql::$table, 193 \Model\emailSql::$table,
194 ['pwd_error'=>1], 194 ['pwd_error'=>1],