作者 邓超

统计

... ... @@ -245,28 +245,56 @@ class Home extends Base {
$where = [];
$start_time = app()->request('start_time',0,'intval');
$end_time = app()->request('end_time',0,'intval');
// if($start_time || $end_time){
// $where['email_id'] = $this->getEmails('id');
// }
if($start_time){
$where['_'][] = '`udate` >= '.$start_time;
}
if($end_time){
$where['_'][] = '`udate` <= '.$end_time;
}
$where['_'] = implode(' and ',$where['_']);
$where['folder_id'] = [];
// 目录
$folder = app()->request('folder', '收件箱');
$folderList = db()->all(folderSql::all($where['email_id']));
$folderList = db()->all(folderSql::all($this->getEmails('id')));
// 文件夹id
if ($folderList) {
foreach ($folderList as $item) {
if ($item['folder'] == $folder) {
$where['folder_id'][] = $item['id'];
}
foreach ($folderList as $item) {
if ($item['folder'] == '收件箱') {
$where['folder_id'][] = $item['id'];
}
}
// 软删
$where['deleted'] = 0;
// 总数
$total = db()->count(listsSql::listCount(dbWhere($where)));
$inbox = db()->cache(3600)->count(listsSql::listCount(dbWhere($where)));
// 未读
$where['seen'] = 0;
$unseen = db()->cache(3600)->count(listsSql::listCount(dbWhere($where)));
$where['folder_id'] = [];
foreach ($folderList as $item) {
if ($item['folder'] == '收件箱') {
$where['folder_id'][] = $item['id'];
}
}
unset($where['seen']);
//发件箱
$send = db()->cache(3600)->count(listsSql::listCount(dbWhere($where)));
app()->_json(['total'=>$total]);
app()->_json(['inbox'=>$inbox,'unseen'=>$unseen,'send'=>$send]);
}
/**
... ...