GameContinuedTsMulti.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. include_once dirname(__FILE__) . '/../main.php';
  3. $params = query_paras();
  4. //$params = $_POST['date'];
  5. $dates = $params['date']['ts'];
  6. $uid = $params['date']['uid'];
  7. $zoneid = $params['date']['zoneid'];
  8. $dataset= new stdClass();
  9. foreach ($dates as $date) {
  10. $tableName = "tab_op_log" . $date;
  11. $dic = new stdClass();
  12. if (daoInst()->tableExist($tableName)) {
  13. $arr = daoInst()->select("*")->from($tableName)
  14. ->where('cmd')->eq(6903)
  15. ->andWhere('zoneid')->eq($zoneid)
  16. ->andWhere('uid')->eq($uid)
  17. ->fetchAll();
  18. $lastItem = null;
  19. $list = array();
  20. $index = 1;
  21. $num = 0;
  22. foreach ($arr as $item) {
  23. if ($lastItem != null) {
  24. $list[] = $lastItem;
  25. if (strtotime($item->ts) - strtotime($lastItem->ts) > 20 * 60) {
  26. $timeDic = new stdClass();
  27. $timeDic->startTs = strtotime($list[0]->ts);
  28. $timeDic->endTs = strtotime($list[count($list) - 1]->ts);
  29. $timeDic->durationTs = strtotime($list[count($list) - 1]->ts) - strtotime($list[0]->ts);
  30. $dic->$index = $timeDic;
  31. $index += 1;
  32. $list = array();
  33. }
  34. }
  35. $num += 1;
  36. $lastItem = $item;
  37. if (count($arr) == $num) {
  38. $list[] = $item;
  39. $timeDic = new stdClass();
  40. $timeDic->startTs = strtotime($list[0]->ts);
  41. $timeDic->endTs = strtotime($list[count($list) - 1]->ts);
  42. $timeDic->durationTs = strtotime($list[count($list) - 1]->ts) - strtotime($list[0]->ts);
  43. $dic->$index = $timeDic;
  44. break;
  45. }
  46. }
  47. $dataset->$date=$dic;
  48. }
  49. }
  50. echo Resp::ret($dataset);
  51. //echo json_encode($result);