Dashboard.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use app\common\model\UserRechargeLog;
  5. use think\Config;
  6. use think\Db;
  7. /**
  8. * 控制台
  9. *
  10. * @icon fa fa-dashboard
  11. * @remark 用于展示当前系统中的统计数据、统计报表及重要实时数据
  12. */
  13. class Dashboard extends Backend
  14. {
  15. //首页统计页
  16. public function index(){
  17. $todaystatime = strtotime(date('Y-m-d'));
  18. $todayendtime = $todaystatime + 86399;
  19. //今日抽奖总产出(钻石总数)、
  20. //开奖获得礼物的总钻石价值
  21. $egg_do_gift_price = Db::name('egg_do')->where('createtime','BETWEEN',[$todaystatime,$todayendtime])->sum('price');
  22. //房间数(在线/所有房间数)、
  23. $party_number = Db::name('party')->where('is_online',1)->count();
  24. $party_number_online = Db::name('party')->count();
  25. //app用户(今日/总注册人数/在线人数)、
  26. Db::name('user')->where('createtime','BETWEEN',[$todaystatime,$todayendtime])->count();
  27. Db::name('user')->count();
  28. Db::name('user')->where('is_online',1)->count();
  29. //充值(总/今日充值数量、今日待支付)、
  30. Db::name('rechar_order')->where('status',1)->sum('money');
  31. Db::name('rechar_order')->where('createtime','BETWEEN',[$todaystatime,$todayendtime])->where('status',1)->sum('money');
  32. Db::name('rechar_order')->where('createtime','BETWEEN',[$todaystatime,$todayendtime])->where('status',0)->sum('money');
  33. //平台总资产余额、
  34. Db::name('user')->sum('money');
  35. //钻石(平台总数量/今日充值数量))
  36. Db::name('user')->sum('jewel');
  37. Db::name('rechar_order')->where('createtime','BETWEEN',[$todaystatime,$todayendtime])->where('status',1)->sum('jewel');
  38. return $this->view->fetch();
  39. }
  40. /**
  41. * 查看
  42. */
  43. public function old_index()
  44. {
  45. $todayRechargeMoney = UserRechargeLog::whereTime('createtime', 'today')->sum('money');
  46. $yesterdayRechargeMoney = UserRechargeLog::whereTime('createtime', 'yesterday')->sum('money');
  47. $monthRechargeMoney = UserRechargeLog::whereTime('createtime', 'month')->sum('money');
  48. $lastMonthRechargeMoney = UserRechargeLog::whereTime('createtime', 'last month')->sum('money');
  49. $this->view->assign([
  50. 'todayRechargeMoney' => $todayRechargeMoney,
  51. 'yesterdayRechargeMoney' => $yesterdayRechargeMoney,
  52. 'monthRechargeMoney' => $monthRechargeMoney,
  53. 'lastMonthRechargeMoney' => $lastMonthRechargeMoney,
  54. ]);
  55. return $this->view->fetch();
  56. }
  57. /**
  58. * 查看
  59. */
  60. public function oindex()
  61. {
  62. $seventtime = \fast\Date::unixtime('day', -7);
  63. $paylist = $createlist = [];
  64. for ($i = 0; $i < 7; $i++) {
  65. $day = date("Y-m-d", $seventtime + ($i * 86400));
  66. $createlist[$day] = mt_rand(20, 200);
  67. $paylist[$day] = mt_rand(1, mt_rand(1, $createlist[$day]));
  68. }
  69. $hooks = config('addons.hooks');
  70. $uploadmode = isset($hooks['upload_config_init']) && $hooks['upload_config_init'] ? implode(',', $hooks['upload_config_init']) : 'local';
  71. $addonComposerCfg = ROOT_PATH . '/vendor/karsonzhang/fastadmin-addons/composer.json';
  72. Config::parse($addonComposerCfg, "json", "composer");
  73. $config = Config::get("composer");
  74. $addonVersion = isset($config['version']) ? $config['version'] : __('Unknown');
  75. // 获取订单信息
  76. $orderInfo = \app\common\model\DispatchOrder::where(["status" => ["gt", 0]])->select();
  77. $orderCount = 0;
  78. $orderamount = 0;
  79. $orderTodaylogin = 0;
  80. if ($orderInfo) foreach ($orderInfo as $k => $v) {
  81. $orderCount++;
  82. $orderamount = $orderamount + $v["price"] * $v["num"];
  83. if ($v["createtime"] > strtotime(date("Y-m-d 00:00:00"))) {
  84. $orderTodaylogin++;
  85. }
  86. }
  87. // 获取用户信息
  88. $userInfo = \app\common\model\User::where(["status" => "normal"])->select();
  89. $userCount = 0;
  90. $userTodaysignup = 0;
  91. $userTodaylogin = 0;
  92. if ($userInfo) foreach ($userInfo as $k => $v) {
  93. $userCount++;
  94. if ($v["createtime"] > strtotime(date("Y-m-d 00:00:00"))) {
  95. $userTodaylogin++;
  96. }
  97. if ($v["logintime"] > strtotime(date("Y-m-d 00:00:00"))) {
  98. $userTodaylogin++;
  99. }
  100. }
  101. $this->view->assign([
  102. 'totaluser' => $userCount,
  103. 'totalviews' => 219390,
  104. 'totalorder' => $orderCount,
  105. 'totalorderamount' => $orderamount,
  106. 'todayuserlogin' => $userTodaylogin,
  107. 'todayusersignup' => $userTodaysignup,
  108. 'todayorder' => $orderTodaylogin,
  109. 'unsettleorder' => 132,
  110. 'sevendnu' => '80%',
  111. 'sevendau' => '32%',
  112. 'paylist' => $paylist,
  113. 'createlist' => $createlist,
  114. 'addonversion' => $addonVersion,
  115. 'uploadmode' => $uploadmode
  116. ]);
  117. return $this->view->fetch();
  118. }
  119. }