Dashboard.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\Admin;
  4. use app\admin\model\User;
  5. use app\common\controller\Backend;
  6. use app\common\model\Attachment;
  7. use fast\Date;
  8. use think\Db;
  9. /**
  10. * 控制台
  11. *
  12. * @icon fa fa-dashboard
  13. * @remark 用于展示当前系统中的统计数据、统计报表及重要实时数据
  14. */
  15. class Dashboard extends Backend
  16. {
  17. /**
  18. * 查看
  19. */
  20. public function index()
  21. {
  22. //今日
  23. $starttime = strtotime(date('Y-m-d'));
  24. $endtime = $starttime + 86400 - 1;
  25. $map = [
  26. 'paytime' => ['BETWEEN',[$starttime,$endtime]],
  27. 'status' => ['IN','1,2'],
  28. ];
  29. $today_order_amount = Db::name('order')->where($map)->sum('pay_fee');
  30. //七日
  31. $starttime = strtotime(date('Y-m-d')) - (86400*6);
  32. $endtime = $starttime + (86400*7) - 1;
  33. $map = [
  34. 'paytime' => ['BETWEEN',[$starttime,$endtime]],
  35. 'status' => ['IN','1,2'],
  36. ];
  37. $serventoday_order_amount = Db::name('order')->where($map)->sum('pay_fee');
  38. //全部
  39. $map = [
  40. 'status' => ['IN','1,2'],
  41. ];
  42. $alltoday_order_amount = Db::name('order')->where($map)->sum('pay_fee');
  43. $this->view->assign([
  44. 'today_order_amount' => $today_order_amount,
  45. 'serventoday_order_amount' => $serventoday_order_amount,
  46. 'alltoday_order_amount' => $alltoday_order_amount,
  47. ]);
  48. return $this->view->fetch();
  49. }
  50. }