作者 邓超

fob

... ... @@ -18,6 +18,33 @@ use Model\folderSql;
*/
class MailList extends Base {
/**
* 当前邮箱下指定的文件夹
* @param string $folder
* @return array
* @throws \Lib\Err
* @author:dc
* @time 2024/7/19 11:37
*/
private function getFolderId(string $folder){
// 查询 文件夹
$folderList = db()->all(folderSql::all($this->getEmails('id')));
$folder_id = [];
// 文件夹id
if($folderList){
foreach ($folderList as $item){
if(folderAlias($item['folder']) == $folder){
$folder_id[] = $item['id'];
}
}
}
if(!$folder_id){
app()->e('folder_not_fount');
}
return $folder_id;
}
/**
* 邮件列表
... ... @@ -71,20 +98,8 @@ class MailList extends Base {
$folder = '发件箱';
$extSql = "f";
}
// 查询 文件夹
$folderList = db()->all(folderSql::all($this->getEmails('id')));
$folder_id = [];
// 文件夹id
if($folderList){
foreach ($folderList as $item){
if(folderAlias($item['folder']) == $folder){
$folder_id[] = $item['id'];
}
}
}
if(!$folder_id){
app()->e('folder_not_fount');
}
$folder_id = $this->getFolderId($folder);
//目录
$where['folder_id'] = $folder_id;
... ... @@ -185,13 +200,41 @@ class MailList extends Base {
// 预热发件箱
$where['folder'] = 'f';
$fCount = db()->count($sql.dbWhere($where));
$where = ['lists|email_id'=>$emails];
$where['folder_id'] = $this->getFolderId('发件箱');
// 发件箱
$sql = "select count(*) from `lists` left join `fob_hot_mail` on `lists`.`id` = `fob_hot_mail`.`lists_id` where ISNULL(`lists_id`) and ";
$faCount = db()->count($sql.dbWhere($where));
// 垃圾箱
$where['folder_id'] = $this->getFolderId('垃圾箱');
$lajiCount = db()->count($sql.dbWhere($where));
// 收件箱
$where['folder_id'] = $this->getFolderId('收件箱');
$shouCount = db()->count($sql.dbWhere($where));
// 未读
$where['seen'] = 0;
$seenCount = db()->count($sql.dbWhere($where));
unset($where['seen']);
// 星标
$where['flagged'] = 1;
$flaggedCount = db()->count($sql.dbWhere($where));
app()->_json([
's_count'=> $sCount,
'f_count'=> $fCount,
'inbox'=> $shouCount,
'send'=> $faCount,
'unseen'=> $seenCount,
'flagged' => $flaggedCount,
'junk' => $lajiCount,
'hot_inbox'=> $sCount,
'hot_send'=> $fCount,
]);
}
... ...