1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Gold
- * Date: 2024/3/6
- * Time: 14:56
- */
- namespace app\user\controller;
- use app\common\model\User;
- use library\Controller;
- use think\Db;
- /**
- * 首页
- * Class Delivery
- * @package app\user\controller
- */
- class Active extends Controller
- {
- /**
- * 列表
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function index()
- {
- $startTime = date('Y-m-d') . ' 00:00:00'; // 获取今天的起始时间
- $endTime = date('Y-m-d') . ' 23:59:59'; // 获取今天的结束时间
- $usersTotal = User::count();
- $activeToday = Db::name('user_active_log')
- ->where('create_at','>',$startTime)
- ->where('create_at','<',$endTime)->count();
- $androidTotal = User::where(function ($query) {
- $query->where('facility_1','<>', null)->where('facility_1','<>', '');
- })->whereOr(function ($query) {
- $query->where('facility_3','<>', null)->where('facility_3','<>', '');
- })->count();
- $iosTotal = User::where(function ($query) {
- $query->where('facility_2','<>', null)->where('facility_2','<>', '');
- })->whereOr(function ($query) {
- $query->where('facility_4','<>', null)->where('facility_4','<>', '');
- })->count();
- $this->usersTotal = $usersTotal;
- $this->activeToday = $activeToday;
- $this->androidTotal = $androidTotal;
- $this->iosTotal = $iosTotal;
- $this->fetch();
- }
- }
|