diff --git a/Application/Admin/Controller/IndexController.class.php b/Application/Admin/Controller/IndexController.class.php index e71d40ed9..f0508f406 100644 --- a/Application/Admin/Controller/IndexController.class.php +++ b/Application/Admin/Controller/IndexController.class.php @@ -9,6 +9,7 @@ namespace Admin\Controller; use User\Api\UserApi as UserApi; +use Base\Repository\UserRepository; /** * 后台首页控制器 @@ -41,25 +42,31 @@ class IndexController extends AdminController { $data['group'] = get_auth_group_name($data['uid']); } } - $this->assign('data',$data); - $this->indextt(); + $this->assign('data',$data); + $this->indextt(); + $this->meta_title = '管理首页'; - // 日历 - $this->calendar(); - - // 折线图 - $this->foldLineDiagram($_REQUEST['start'],$_REQUEST['end'],$_REQUEST['num']); - - // 累计数据 - $user = D('User'); - $spend = D('Spend'); - $promote = D('Promote'); - $this->assign('user_count',$user->old()); - $this->assign('active_count',$user->active(['tab_user_login_record.login_time'=>['between',[mktime(0,0,0,date('m'),date('d')-7,date('Y')),mktime(0,0,0,date('m'),date('d'),date('Y'))-1]]])); - $this->assign('player_count',$spend->player()); - $this->assign('money_sum',$spend->totalAmount()); - $this->assign('promote_sum',$promote->total()); + // 日历 + $this->calendar(); + + // 折线图 + $this->foldLineDiagram($_REQUEST['start'],$_REQUEST['end'],$_REQUEST['num']); + + $userRepository = new UserRepository(); + $activeCount = $userRepository->getActiveUserCountRecently(7); + + + // 累计数据 + $user = D('User'); + $spend = D('Spend'); + $promote = D('Promote'); + $this->assign('user_count', $user->old()); + // $this->assign('active_count', $user->active(['tab_user_login_record.login_time'=>['between',[mktime(0,0,0,date('m'),date('d')-7,date('Y')),mktime(0,0,0,date('m'),date('d'),date('Y'))-1]]])); + $this->assign('active_count', $activeCount); + $this->assign('player_count', $spend->player()); + $this->assign('money_sum', $spend->totalAmount()); + $this->assign('promote_sum', $promote->total()); $this->display(); } diff --git a/Application/Admin/Model/UserModel.class.php b/Application/Admin/Model/UserModel.class.php index e5529b227..489b6a2db 100644 --- a/Application/Admin/Model/UserModel.class.php +++ b/Application/Admin/Model/UserModel.class.php @@ -1714,7 +1714,7 @@ class UserModel extends Model{ return $this->where($map)->count(); - } + } /* * 活跃用户总数 diff --git a/Application/Base/Repository/UserRepository.class.php b/Application/Base/Repository/UserRepository.class.php index bb2628551..87422ee91 100644 --- a/Application/Base/Repository/UserRepository.class.php +++ b/Application/Base/Repository/UserRepository.class.php @@ -527,4 +527,16 @@ class UserRepository return $this->assembleRecords($items, $gameIds, 'count', 'game_id'); } } + + public function getActiveUserCountRecently($dayCount = 1, $params = []) + { + $conditions = []; + $endTime = strtotime(date('Y-m-d 23:59:59')); + $beginTime = $endTime + 1 - $dayCount * 24 * 3600; + $conditions = ['login_time' => ['between', [$beginTime, $endTime]]]; + $item = M('user_login_record', 'tab_')->field('count(DISTINCT user_id) as count') + ->where($conditions) + ->find(); + return $item['count']; + } } \ No newline at end of file