修改代码

master
elf@home 5 years ago
parent c68716bbae
commit 1036589f3b

@ -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();
}

@ -1714,7 +1714,7 @@ class UserModel extends Model{
return $this->where($map)->count();
}
}
/*
* 活跃用户总数

@ -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'];
}
}
Loading…
Cancel
Save