action.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. include_once dirname(__FILE__) . '/../main.php';
  3. $GET = query_paras();
  4. $date = $GET['date'];
  5. $date1 = $GET['date1'];
  6. $isnew = $GET['isnew'];
  7. $isold = $GET['isold'];
  8. $islost = $GET['islost'];
  9. $pageNumber = $GET['pageNumber'];
  10. $pageSize = $GET['pageSize'];
  11. $start = ($pageNumber - 1) * $pageSize;
  12. $count = 0;
  13. $arr = array();
  14. $tabName = 'tab_rolename';
  15. if ($isnew > 0) { // 新增
  16. $count = daoInst()->select('*')->from($tabName)
  17. ->where('ts')->ge($date . " 00:00:00")
  18. ->andWhere('ts')->le($date1 . " 23:59:59")
  19. ->count();
  20. $arr = daoInst()->select('*')->from($tabName)
  21. ->where('ts')->ge($date . " 00:00:00")
  22. ->andWhere('ts')->le($date1 . " 23:59:59")
  23. ->limit($start . "," . $pageSize)
  24. ->fetch_array();
  25. } else if ($isold > 0) { // 留存
  26. $count = daoInst()->select('*')->from($tabName)
  27. ->where('lastlogin')->ge($date . " 00:00:00")
  28. ->andWhere('lastlogin')->le($date1 . " 23:59:59")
  29. ->count();
  30. $arr = daoInst()->select('*')->from($tabName)
  31. ->where('lastlogin')->ge($date . " 00:00:00")
  32. ->andWhere('lastlogin')->le($date1 . " 23:59:59")
  33. ->limit($start . "," . $pageSize)
  34. ->fetch_array();
  35. } else if ($islost > 0) { // 流失
  36. $count = daoInst()->select('*')->from($tabName)
  37. ->where('lastlogin')->ge($date . " 00:00:00")
  38. ->andWhere('lastlogin')->le($date1 . " 23:59:59")
  39. ->andWhere('to_days(from_unixtime(`ts`))')->eq('to_days(from_unixtime(`lastlogin`))')
  40. ->count();
  41. $arr = daoInst()->select('*')->from($tabName)
  42. ->where('lastlogin')->ge($date . " 00:00:00")
  43. ->andWhere('lastlogin')->le($date1 . " 23:59:59")
  44. ->andWhere('to_days(from_unixtime(`ts`))')->eq('to_days(from_unixtime(`lastlogin`))')
  45. ->limit($start . "," . $pageSize)
  46. ->fetch_array();
  47. }
  48. $result = new stdClass();
  49. $result->total = $count;
  50. $result->rows = $arr;
  51. echo json_encode($result);