ordersca.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace WY\app\controller\member;
  3. use WY\app\libs\Controller;
  4. if (!defined('WY_ROOT')) {
  5. exit;
  6. }
  7. class ordersca extends CheckUser
  8. {
  9. public function index()
  10. {
  11. $fdate = $this->req->get('fdate');
  12. $tdate = $this->req->get('tdate');
  13. $fdate = isset($_GET['fdate']) ? $fdate : date('Y-m-d');
  14. $tdate = isset($_GET['tdate']) ? $tdate : date('Y-m-d');
  15. $sort = $this->req->get('sort');
  16. $by = $this->req->get('by');
  17. $orderby = 'channelid desc';
  18. if ($by) {
  19. $orderby = $sort ? $by . ' desc' : $by . ' asc';
  20. }
  21. $cons = 'channelid<>? and userid = ? and is_state<=?';
  22. $consOR = '';
  23. $consArr = array(0, $_SESSION['login_userid'], 1);
  24. if ($fdate) {
  25. $cons .= $cons ? ' and ' : '';
  26. $cons .= 'addtime>=?';
  27. $consArr[] = strtotime($fdate);
  28. }
  29. if ($tdate) {
  30. $cons .= $cons ? ' and ' : '';
  31. $cons .= 'addtime<=?';
  32. $consArr[] = strtotime($tdate . ' 23:59:59');
  33. }
  34. $page = $this->req->get('p');
  35. $page = $page ? $page : 1;
  36. $pagesize = 20;
  37. $data = $this->model()->select('channelid')->from('orders')->groupby('channelid')->where(array('fields' => $cons, 'values' => $consArr))->fetchAll();
  38. $totalsize = count($data);
  39. $lists = array();
  40. if ($totalsize) {
  41. $totalpage = ceil($totalsize / $pagesize);
  42. $page = $page > $totalpage ? $totalpage : $page;
  43. $offset = ($page - 1) * $pagesize;
  44. $lists = $this->model()->select('channelid,sum(total_fee) as total_fee,count(userid) as total_orders,sum(realmoney*uprice) as total_income')->from('orders')->offset($offset)->limit($pagesize)->groupby('channelid')->orderby($orderby)->where(array('fields' => $cons, 'values' => $consArr))->fetchAll();
  45. }
  46. $data = array('title' => '通道分析', 'lists' => $lists, 'search' => array('fdate' => $fdate, 'tdate' => $tdate), 'by' => $by, 'sort' => $sort);
  47. $this->put('ordersca.php', $data);
  48. }
  49. }