You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

88 lines
3.3 KiB

  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Steven
  5. * Date: 2016/8/25
  6. * Time: 20:18
  7. * 根据出发地、目的地、日期获取班次信息
  8. */
  9. require_once __DIR__.'/common.php';
  10. class runList extends virtifyUsers
  11. {
  12. public function getRunList($PAGE, $PAGE_SIZE, $RUN_DATE, $RUN_LINE)
  13. {
  14. $pdo = conn();
  15. $pdo1 = conn();
  16. if($RUN_DATE==date("Y-m-d",time()))
  17. {
  18. $RUN_DATE=date("Y-m-d H:i",time());
  19. }else
  20. {
  21. $RUN_DATE=date('Y-m-d H:i',strtotime($RUN_DATE));
  22. }
  23. $sql = "CALL SP_CHOICE_KICKET('1','" . $PAGE . "','" . $PAGE_SIZE . "','','','" . $RUN_DATE . "','','" . $RUN_LINE . "')";
  24. if (is_object($pdo)) {
  25. $stmt = $pdo->query($sql);
  26. $i = 1;
  27. if ($stmt) {
  28. $data['code'] = '0';
  29. $data['info'] = '';
  30. do {
  31. $rowset = $stmt->fetchAll(PDO::FETCH_ASSOC);
  32. if ($i == 1) {
  33. $data['currpage'] = $rowset[0]['currpage'];
  34. $data['total_page'] = $rowset[0]['total_page'];
  35. $data['total'] = $rowset[0]['total'];
  36. $data['page_size'] = $rowset[0]['page_size'];
  37. } else if ($i == 2) {
  38. $ticket = array();
  39. foreach ($rowset as $k => $v) { //遍历班次,车次,库存相加,班次归类。
  40. $ticket_info = $v;
  41. if (!isset($ticket[$v['run_id']])) {
  42. $ticket[$v['run_id']] = $ticket_info;
  43. $sql = "select prod_id from opera_product where parent_id = " . $ticket[$v['run_id']]['prod_id'] . " and ticket_mark = 1 and cancel_flag = 0";
  44. $result = $pdo1->query($sql);
  45. $ticket_id = $result->fetchAll(PDO::FETCH_ASSOC);
  46. $result->closeCursor();
  47. $ticket[$v['run_id']]['ticket_id'] = $ticket_id[0]['prod_id'];
  48. } else {
  49. $ticket[$v['run_id']]['stock'] += $v['stock'];
  50. }
  51. $ticket = array_values($ticket);
  52. }
  53. $data['total'] = count($ticket);
  54. $data['total_page'] = ceil(count($ticket) / $data['page_size']);
  55. $data['ticket'] = $ticket;
  56. } else {
  57. }
  58. $i++;
  59. } while ($stmt->nextRowset());
  60. } else {
  61. $data['code'] = '1';
  62. $data['info'] = '查询失败';
  63. }
  64. if ($stmt) {
  65. $stmt->closeCursor();
  66. }
  67. }
  68. if (is_array($data)) {
  69. return json_encode($data);
  70. }
  71. }
  72. }
  73. $RUN_LINE = $_POST['prod_id'];
  74. $PAGE = isset($_POST['page']) ? $_POST['page'] : 1;
  75. $PAGE_SIZE = isset($_POST['page_size']) ? $_POST['page_size'] : 5;
  76. $RUN_DATE = isset($_POST['startDate']) ? $_POST['startDate'] : date('Y-m-d', time());
  77. if (!$RUN_LINE) {
  78. return false;
  79. }
  80. $runList = new runList();
  81. $res = $runList->getRunList($PAGE, $PAGE_SIZE, $RUN_DATE, $RUN_LINE);
  82. echo $res;