Home.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\partner\controller;
  3. use app\partner\BaseController;
  4. use app\common\model\User as UserModel;
  5. use app\common\model\Broker as BrokerModel;
  6. class Home extends BaseController
  7. {
  8. public function index()
  9. {
  10. return view('index', [
  11. 'access_partner' => session('access_partner'),
  12. ]);
  13. }
  14. public function console()
  15. {
  16. $partnerid = $this->access_partner['id'];
  17. $brokerids = BrokerModel::where('pid|id', '=', $partnerid)->column('id');
  18. $stime = strtotime(date("Y-m-d"), time());
  19. $tuserCount = UserModel::whereIn('brokerid', $brokerids)->where('brokerid', '<>', 0)->where('createtime', 'between', [$stime, $stime + 86400])->count();
  20. $yuserCount = UserModel::whereIn('brokerid', $brokerids)->where('brokerid', '<>', 0)->where('createtime', 'between', [$stime - 86400, $stime])->count();
  21. $userCount = UserModel::whereIn('brokerid', $brokerids)->where('brokerid', '<>', 0)->count();
  22. $brokerCount = BrokerModel::where('pid', '=', $partnerid)->count();
  23. $partnerIncome = BrokerModel::whereIn('id',$brokerids)->sum('income');
  24. $partnerIncomeTotal = BrokerModel::whereIn('id',$brokerids)->sum('income_total');
  25. return view('home/console', [
  26. 'tuserCount' => $tuserCount,
  27. 'yuserCount' => $yuserCount,
  28. 'userCount' => $userCount,
  29. 'brokerCount' => $brokerCount,
  30. 'partnerIncome' => $partnerIncome,
  31. 'partnerIncomeTotal' => $partnerIncomeTotal,
  32. 'partner' => $this->access_partner,
  33. ]);
  34. }
  35. }