Dashboard.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\RechargeModel;
  4. use app\api\controller\Order;
  5. use app\api\controller\User;
  6. use app\api\model\OrderModel;
  7. use app\api\model\QueueModel;
  8. use app\api\model\UsersModel;
  9. use app\common\controller\Backend;
  10. use think\Config;
  11. use think\Db;
  12. /**
  13. * 控制台
  14. *
  15. * @icon fa fa-dashboard
  16. * @remark 用于展示当前系统中的统计数据、统计报表及重要实时数据
  17. */
  18. class Dashboard extends Backend
  19. {
  20. /**
  21. * 查看
  22. */
  23. public function index()
  24. {
  25. $seventtime = \fast\Date::unixtime('day', -7);
  26. $paylist = $createlist = [];
  27. for ($i = 0; $i < 7; $i++) {
  28. $day = date("Y-m-d", $seventtime + ($i * 86400));
  29. $createlist[$day] = mt_rand(20, 200);
  30. $paylist[$day] = mt_rand(1, mt_rand(1, $createlist[$day]));
  31. }
  32. $hooks = config('addons.hooks');
  33. $uploadmode = isset($hooks['upload_config_init']) && $hooks['upload_config_init'] ? implode(',', $hooks['upload_config_init']) : 'local';
  34. $addonComposerCfg = ROOT_PATH . '/vendor/karsonzhang/fastadmin-addons/composer.json';
  35. Config::parse($addonComposerCfg, "json", "composer");
  36. $config = Config::get("composer");
  37. $addonVersion = isset($config['version']) ? $config['version'] : __('Unknown');
  38. // VIP开通次数
  39. $vipBuyNum = \app\admin\model\Viplog::where('pay_status', 1)->count();
  40. // 排队次数
  41. $queueNum = QueueModel::where('pay_status', 1)->count();
  42. // 排队总收入
  43. $queueIncome = QueueModel::where('pay_status', 1)->sum('amount');
  44. // 排队总支出
  45. $queueOut = QueueModel::where('pay_status', 1)->sum('income');
  46. // 话费充值次数
  47. $rechargeNum = RechargeModel::where('pay_status', 1)->count();
  48. // 话费充值收入
  49. $rechargeIncome = RechargeModel::where('pay_status', 1)->sum('final_fee');
  50. // 话费充值支出
  51. $rechargeOut = RechargeModel::where('pay_status', 1)->sum('price');
  52. // 待发货订单
  53. $dafaihuo = OrderModel::where('state', 2)->count();
  54. // 退款订单
  55. $tuikuan = OrderModel::where('state', 4)->count();
  56. // 商城总收入
  57. $zongmongey = OrderModel::where('state', 6)->sum('money');
  58. // 提现总支出
  59. $tixian = Db::name('cash_log')->where('state', 2)->sum('money');
  60. // 会员总数
  61. $totaluser = Db::name('users')->count();
  62. // 普通会员总数
  63. $pt = UsersModel::where('user_level',1)->count();
  64. // 店长总数
  65. $dianzhang = UsersModel::where('user_level',2)->count();
  66. // 经理总数
  67. $jingli = UsersModel::where('user_level',3)->count();
  68. // 总监总数
  69. $zongjian = UsersModel::where('user_level',4)->count();
  70. // 董事总数
  71. $dongshi = UsersModel::where('user_level',5)->count();
  72. // vip会员总数
  73. $vip = UsersModel::where('user_level',6)->count();
  74. $this->view->assign([
  75. 'totaluser' => $totaluser,
  76. 'totalviews' => $pt,
  77. 'totalorder' => $dianzhang,
  78. 'totalorderamount' => $jingli,
  79. 'todayuserlogin' => $zongjian,
  80. 'todayusersignup' => $dongshi,
  81. 'todayorder' => 2324,
  82. 'unsettleorder' => 132,
  83. 'sevendnu' => '80%',
  84. 'vip' => $vip,
  85. 'paylist' => $paylist,
  86. 'createlist' => $createlist,
  87. 'addonversion' => $addonVersion,
  88. 'uploadmode' => $uploadmode,
  89. 'vipBuyNum' => $vipBuyNum,
  90. 'queueIncome' => $queueIncome,
  91. 'queueOut' => $queueOut,
  92. 'rechargeIncome' => $rechargeIncome,
  93. 'rechargeNum' => $rechargeNum,
  94. 'rechargeOut' => $rechargeOut,
  95. 'daifahuo' => $dafaihuo,
  96. 'tuikuan' => $tuikuan,
  97. 'zongmoney' => $zongmongey,
  98. 'tixian' => $tixian,
  99. ]);
  100. return $this->view->fetch();
  101. }
  102. }