作者 邓超

fob

@@ -18,6 +18,33 @@ use Model\folderSql; @@ -18,6 +18,33 @@ use Model\folderSql;
18 */ 18 */
19 class MailList extends Base { 19 class MailList extends Base {
20 20
  21 + /**
  22 + * 当前邮箱下指定的文件夹
  23 + * @param string $folder
  24 + * @return array
  25 + * @throws \Lib\Err
  26 + * @author:dc
  27 + * @time 2024/7/19 11:37
  28 + */
  29 + private function getFolderId(string $folder){
  30 + // 查询 文件夹
  31 + $folderList = db()->all(folderSql::all($this->getEmails('id')));
  32 + $folder_id = [];
  33 + // 文件夹id
  34 + if($folderList){
  35 + foreach ($folderList as $item){
  36 + if(folderAlias($item['folder']) == $folder){
  37 + $folder_id[] = $item['id'];
  38 + }
  39 + }
  40 + }
  41 + if(!$folder_id){
  42 + app()->e('folder_not_fount');
  43 + }
  44 +
  45 + return $folder_id;
  46 + }
  47 +
21 48
22 /** 49 /**
23 * 邮件列表 50 * 邮件列表
@@ -71,20 +98,8 @@ class MailList extends Base { @@ -71,20 +98,8 @@ class MailList extends Base {
71 $folder = '发件箱'; 98 $folder = '发件箱';
72 $extSql = "f"; 99 $extSql = "f";
73 } 100 }
74 - // 查询 文件夹  
75 - $folderList = db()->all(folderSql::all($this->getEmails('id')));  
76 - $folder_id = [];  
77 - // 文件夹id  
78 - if($folderList){  
79 - foreach ($folderList as $item){  
80 - if(folderAlias($item['folder']) == $folder){  
81 - $folder_id[] = $item['id'];  
82 - }  
83 - }  
84 - }  
85 - if(!$folder_id){  
86 - app()->e('folder_not_fount');  
87 - } 101 +
  102 + $folder_id = $this->getFolderId($folder);
88 103
89 //目录 104 //目录
90 $where['folder_id'] = $folder_id; 105 $where['folder_id'] = $folder_id;
@@ -185,13 +200,41 @@ class MailList extends Base { @@ -185,13 +200,41 @@ class MailList extends Base {
185 // 预热发件箱 200 // 预热发件箱
186 $where['folder'] = 'f'; 201 $where['folder'] = 'f';
187 $fCount = db()->count($sql.dbWhere($where)); 202 $fCount = db()->count($sql.dbWhere($where));
  203 +
  204 +
  205 +
  206 + $where = ['lists|email_id'=>$emails];
  207 + $where['folder_id'] = $this->getFolderId('发件箱');
188 // 发件箱 208 // 发件箱
  209 + $sql = "select count(*) from `lists` left join `fob_hot_mail` on `lists`.`id` = `fob_hot_mail`.`lists_id` where ISNULL(`lists_id`) and ";
  210 +
  211 + $faCount = db()->count($sql.dbWhere($where));
  212 +
  213 + // 垃圾箱
  214 + $where['folder_id'] = $this->getFolderId('垃圾箱');
  215 + $lajiCount = db()->count($sql.dbWhere($where));
189 216
190 // 收件箱 217 // 收件箱
  218 + $where['folder_id'] = $this->getFolderId('收件箱');
  219 + $shouCount = db()->count($sql.dbWhere($where));
  220 + // 未读
  221 + $where['seen'] = 0;
  222 + $seenCount = db()->count($sql.dbWhere($where));
  223 +
  224 + unset($where['seen']);
  225 +
  226 + // 星标
  227 + $where['flagged'] = 1;
  228 + $flaggedCount = db()->count($sql.dbWhere($where));
191 229
192 app()->_json([ 230 app()->_json([
193 - 's_count'=> $sCount,  
194 - 'f_count'=> $fCount, 231 + 'inbox'=> $shouCount,
  232 + 'send'=> $faCount,
  233 + 'unseen'=> $seenCount,
  234 + 'flagged' => $flaggedCount,
  235 + 'junk' => $lajiCount,
  236 + 'hot_inbox'=> $sCount,
  237 + 'hot_send'=> $fCount,
195 ]); 238 ]);
196 239
197 } 240 }