作者 邓超

统计

@@ -245,28 +245,56 @@ class Home extends Base { @@ -245,28 +245,56 @@ class Home extends Base {
245 245
246 $where = []; 246 $where = [];
247 247
  248 +
  249 + $start_time = app()->request('start_time',0,'intval');
  250 + $end_time = app()->request('end_time',0,'intval');
  251 +// if($start_time || $end_time){
  252 +// $where['email_id'] = $this->getEmails('id');
  253 +// }
  254 +
  255 + if($start_time){
  256 + $where['_'][] = '`udate` >= '.$start_time;
  257 + }
  258 + if($end_time){
  259 + $where['_'][] = '`udate` <= '.$end_time;
  260 + }
  261 +
  262 + $where['_'] = implode(' and ',$where['_']);
  263 +
248 $where['folder_id'] = []; 264 $where['folder_id'] = [];
249 265
250 // 目录 266 // 目录
251 - $folder = app()->request('folder', '收件箱');  
252 - $folderList = db()->all(folderSql::all($where['email_id'])); 267 + $folderList = db()->all(folderSql::all($this->getEmails('id')));
253 268
254 // 文件夹id 269 // 文件夹id
255 - if ($folderList) {  
256 foreach ($folderList as $item) { 270 foreach ($folderList as $item) {
257 - if ($item['folder'] == $folder) { 271 + if ($item['folder'] == '收件箱') {
258 $where['folder_id'][] = $item['id']; 272 $where['folder_id'][] = $item['id'];
259 } 273 }
260 } 274 }
261 - } 275 +
262 276
263 // 软删 277 // 软删
264 $where['deleted'] = 0; 278 $where['deleted'] = 0;
265 279
266 // 总数 280 // 总数
267 - $total = db()->count(listsSql::listCount(dbWhere($where))); 281 + $inbox = db()->cache(3600)->count(listsSql::listCount(dbWhere($where)));
  282 + // 未读
  283 + $where['seen'] = 0;
  284 + $unseen = db()->cache(3600)->count(listsSql::listCount(dbWhere($where)));
  285 +
  286 +
  287 + $where['folder_id'] = [];
  288 + foreach ($folderList as $item) {
  289 + if ($item['folder'] == '收件箱') {
  290 + $where['folder_id'][] = $item['id'];
  291 + }
  292 + }
  293 + unset($where['seen']);
  294 + //发件箱
  295 + $send = db()->cache(3600)->count(listsSql::listCount(dbWhere($where)));
268 296
269 - app()->_json(['total'=>$total]); 297 + app()->_json(['inbox'=>$inbox,'unseen'=>$unseen,'send'=>$send]);
270 } 298 }
271 299
272 /** 300 /**