Active.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Gold
  5. * Date: 2024/3/6
  6. * Time: 14:56
  7. */
  8. namespace app\user\controller;
  9. use app\common\model\User;
  10. use library\Controller;
  11. use think\Db;
  12. /**
  13. * 首页
  14. * Class Delivery
  15. * @package app\user\controller
  16. */
  17. class Active extends Controller
  18. {
  19. /**
  20. * 列表
  21. * @auth true
  22. * @menu true
  23. * @throws \think\Exception
  24. * @throws \think\db\exception\DataNotFoundException
  25. * @throws \think\db\exception\ModelNotFoundException
  26. * @throws \think\exception\DbException
  27. * @throws \think\exception\PDOException
  28. */
  29. public function index()
  30. {
  31. $startTime = date('Y-m-d') . ' 00:00:00'; // 获取今天的起始时间
  32. $endTime = date('Y-m-d') . ' 23:59:59'; // 获取今天的结束时间
  33. $usersTotal = User::count();
  34. $activeToday = Db::name('user_active_log')
  35. ->where('create_at','>',$startTime)
  36. ->where('create_at','<',$endTime)->count();
  37. $androidTotal = User::where(function ($query) {
  38. $query->where('facility_1','<>', null)->where('facility_1','<>', '');
  39. })->whereOr(function ($query) {
  40. $query->where('facility_3','<>', null)->where('facility_3','<>', '');
  41. })->count();
  42. $iosTotal = User::where(function ($query) {
  43. $query->where('facility_2','<>', null)->where('facility_2','<>', '');
  44. })->whereOr(function ($query) {
  45. $query->where('facility_4','<>', null)->where('facility_4','<>', '');
  46. })->count();
  47. $this->usersTotal = $usersTotal;
  48. $this->activeToday = $activeToday;
  49. $this->androidTotal = $androidTotal;
  50. $this->iosTotal = $iosTotal;
  51. $this->fetch();
  52. }
  53. }