Yesterdaydata.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\admin\controller\informational;
  3. use app\common\model\ShopCategory;
  4. use app\admin\traits\Curd;
  5. use app\common\controller\AdminController;
  6. use EasyAdmin\annotation\ControllerAnnotation;
  7. use EasyAdmin\annotation\NodeAnotation;
  8. use think\App;
  9. use think\facade\Db;
  10. use think\Model;
  11. /**
  12. * Class Admin
  13. * @package app\admin\controller\system
  14. * @ControllerAnnotation(title="昨日数据管理")
  15. */
  16. class Yesterdaydata extends AdminController
  17. {
  18. use Curd;
  19. public function __construct(App $app)
  20. {
  21. parent::__construct($app);
  22. $this->model = new ShopCategory();
  23. }
  24. /**
  25. * @NodeAnotation(title="后台数据列表")
  26. */
  27. public function index(){
  28. $res = [
  29. // 昨日数据
  30. 'yesterday'=>sr_getcurtime(time()-86400, 'Y年-m月-d日'),
  31. 'yesterday_register'=>Db::name('user')->whereDay('reg_time', 'yesterday')->count('id'),
  32. 'yesterday_recharge'=>Db::name('payment')->whereIn('order_type', [4,5])->where('state', 6)->whereDay('creat_at', 'yesterday')->sum('total_fee'),
  33. 'yesterday_withdraw'=>Db::name('withdraw_log')->where('status', 1)->whereDay('creat_at', 'yesterday')->sum('practical_money'),
  34. // 今日数据
  35. 'today'=>sr_getcurtime(time(), 'Y年-m月-d日'),
  36. 'today_register'=>Db::name('user')->whereDay('reg_time', 'today')->count('id'),
  37. 'today_recharge'=>Db::name('payment')->whereIn('order_type', [4,5])->where('state', 6)->whereDay('creat_at', 'today')->sum('total_fee'),
  38. 'today_withdraw'=>Db::name('withdraw_log')->where('status', 1)->whereDay('creat_at', 'today')->sum('practical_money'),
  39. ];
  40. $this->assign('res', $res);
  41. return $this->fetch();
  42. }
  43. }