main.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace WY\app\controller\member;
  3. use WY\app\libs\Controller;
  4. use WY\app\model\Bill;
  5. if (!defined('WY_ROOT')) {
  6. exit;
  7. }
  8. class main extends CheckUser
  9. {
  10. public function index()
  11. {
  12. $where = array('fields' => 'is_state=? and cid=?', 'values' => array('1', '2'));
  13. $notice = $this->model()->select()->from('arlist')->limit(10)->where($where)->orderby('id desc')->fetchAll();
  14. $bill = new Bill();
  15. $income = $bill->beforeUserIncome($_SESSION['login_userid'], 0);
  16. $unpaid = $income + $this->userData['unpaid'];
  17. $where = array('fields' => 'userid=? and is_state<? and addtime>=?', 'values' => array($_SESSION['login_userid'], 2, strtotime(date('Y-m-d'))));
  18. $today_orders = $this->model()->select()->from('orders')->where($where)->count();
  19. $today_income = $bill->todayUserIncome($_SESSION['login_userid'], 0);
  20. $unpaid += $today_income;
  21. $wherepay = array('fields' => 'userid=? and is_agent=?', 'values' => array($_SESSION['login_userid'], 0));
  22. $payments = $this->model()->select()->from('payments')->where($wherepay)->limit(5)->orderby('id desc')->fetchAll();
  23. $page = $this->req->get('p');
  24. $page = $page ? intval($page) : 1;
  25. $pagesize = 5;
  26. $offset = ($page - 1) * $pagesize;
  27. $where = array('fields' => 'userid=? and addtime>=?', 'values' => array($_SESSION['login_userid'], time() - 60 * 60 * 24 * 7));
  28. $lists = array();
  29. if ($totalsize = $this->model()->from('userlogs')->where($where)->count()) {
  30. $totalpage = ceil($totalsize / $pagesize);
  31. $lists = $this->model()->select()->from('userlogs')->where($where)->limit($pagesize)->offset($offset)->orderby('id desc')->fetchAll();
  32. }
  33. $data = array('title' => '商户中心', 'notice' => $notice, 'today_orders' => $today_orders, 'today_income' => $today_income, 'unpaid' => $unpaid, 'payments' => $payments, 'lists' => $lists);
  34. $this->put('index.php', $data);
  35. }
  36. }