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.
 
 
 
 
 

236 lines
8.6 KiB

  1. <?php
  2. header("Access-Control-Allow-Origin:*");
  3. /**
  4. * User: Miracle
  5. * Date: 2016/8/24
  6. * Time: 11:00
  7. * 出行详情接口
  8. */
  9. date_default_timezone_set('PRC');
  10. //$MAIN_CREATE_USER_ID=$_COOKIE['user_id'];
  11. //获得用户名
  12. $member_id = $_COOKIE['user_id'];
  13. //获得用户名
  14. //$member_id = '1732';
  15. $list_going = array();
  16. require_once '../../Common/Mysql.php';
  17. //即将出行数据列表
  18. //当获得的用户名不为空
  19. $disney_prod =get_dsnprod();
  20. //苏州线路 152738 152745 西塘乌镇线路 152690 152703
  21. $disney_prod = array_merge($disney_prod,array('152738','152745','152690','152703'));
  22. //定制巴士
  23. $DZBS =array('449860','449865','450036','450037' );
  24. if (!empty($member_id)) {
  25. $sql = "SELECT ORDER_ID,ORDER_DESCRIPTION,ORDER_PRICE FROM ORDER_MAIN WHERE member_id=" . $member_id . " AND CANCEL_FLAG=0 AND PARENT_ORDER_ID=0 AND ORDER_STATUS in (146,147) and order_prod_type in (81,82) order by run_date DESC,RUN_TIME desc";
  26. $pdo = conn();
  27. $result = $pdo -> query($sql);
  28. $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
  29. //var_dump($rowset);
  30. $i = 0;
  31. foreach ($rowset as $temp) {
  32. $order_id = $temp['ORDER_ID'];
  33. $order_info = $temp["ORDER_DESCRIPTION"];
  34. $temp_temp = explode(',', $order_info);
  35. $seat_type = str_replace("票", "", $temp_temp[0]);
  36. //座位类型
  37. $seat_num = str_replace("|", "", $temp_temp[2]);
  38. //座位数量
  39. $sql = "SELECT order_status,parent_prod_id,RUN_ID,RUN_DATE,RUN_TIME,RUN_BUS_ORDER_ID,PROD_START_STATION_RES_NAME,PROD_START_STATION_AREA_NAME,PROD_END_STATION_RES_NAME,PROD_END_STATION_AREA_NAME,PROD_END_STATION_TIME_MINUTES,PROD_START_STATION_TIME_MINUTES FROM ORDER_MAIN WHERE PARENT_ORDER_ID=" . $temp["ORDER_ID"] . " AND CANCEL_FLAG=0";
  40. $pdo = conn();
  41. $result = $pdo -> query($sql);
  42. $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
  43. //var_dump($rowset);
  44. $time = $rowset[0]["RUN_TIME"];
  45. $date = $rowset[0]["RUN_DATE"];
  46. $temp_time = $date . " " . $time;
  47. $start_time = strtotime($temp_time);
  48. $now_time = time();
  49. if ($start_time >= $now_time) {
  50. //将要出行的订单
  51. $order_start_date = date("n月j日", $start_time);
  52. //日期
  53. $order_start_time = $time;
  54. //时间
  55. $weekarray = array("日", "一", "二", "三", "四", "五", "六");
  56. //先定义一个数组
  57. $start_week = "星期" . $weekarray[date("w",$start_time)];
  58. if (date('Y-m-d', time()) == $date) {
  59. $start_week = "今天";
  60. }
  61. $list_going[$i]["week"] = $start_week;
  62. $list_going[$i]["year"] = $date;
  63. $run_time_start = $rowset[0]["PROD_START_STATION_TIME_MINUTES"];
  64. $run_time_end = $rowset[0]["PROD_END_STATION_TIME_MINUTES"];
  65. $order_hour = floor(($run_time_end - $run_time_start) / 60);
  66. //小时
  67. $order_min = ($run_time_end - $run_time_start) % 60;
  68. //分钟
  69. $order_used_time = $order_hour . "时" . $order_min . "分";
  70. //耗时
  71. $order_start_res_name = $rowset[0]["PROD_START_STATION_RES_NAME"];
  72. //起始res名字
  73. $order_start_area_name = $rowset[0]["PROD_START_STATION_AREA_NAME"];
  74. //起始地区名字
  75. $order_end_res_name = $rowset[0]["PROD_END_STATION_RES_NAME"];
  76. //终点res名字
  77. $order_end_area_name = $rowset[0]["PROD_END_STATION_AREA_NAME"];
  78. //检票状态
  79. if($rowset[0]['order_status'] ==146){
  80. $check ='0';
  81. }else{
  82. $check = '1';
  83. }
  84. //是否显示二维码
  85. if(in_array($rowset[0]['parent_prod_id'], $disney_prod)){
  86. $ercode = '1';
  87. }else{
  88. $ercode = '0';
  89. }
  90. if(in_array($rowset[0]['parent_prod_id'], $DZBS)){
  91. $ifdzbs = '1'; //是定制巴士
  92. }else{
  93. $ifdzbs = '0';
  94. }
  95. //终点地区名字
  96. $sql = "SELECT SEND_BUS_NO,SEND_DRIVER_NAME,SEND_DRIVER_MOBILE FROM RUN_BUS WHERE CANCEL_FLAG=0 AND RUN_ID=" . $rowset[0]["RUN_ID"] . " AND BUS_ORDER_ID=" . $rowset[0]["RUN_BUS_ORDER_ID"];
  97. $pdo = conn();
  98. $result = $pdo -> query($sql);
  99. $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
  100. //var_dump($rowset);
  101. $order_bus_no = "";
  102. //车牌号
  103. $order_driver_name = "";
  104. //司机名称
  105. if (!empty($rowset[0]["SEND_BUS_NO"])) {
  106. $driver_mobile = $rowset[0]['SEND_DRIVER_MOBILE'];
  107. $order_bus_no = $rowset[0]["SEND_BUS_NO"];
  108. $order_driver_name = $rowset[0]["SEND_DRIVER_NAME"];
  109. $sql = "SELECT b.PROPERTY FROM base_resource a LEFT JOIN `base_resource_property` b on a.RES_ID =b.RES_ID where b.TYPE_ID=283 and a.RES_NAME ='".$order_bus_no."'";
  110. //$pdo = conn();
  111. $result = $pdo -> query($sql);
  112. $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
  113. $time_cut =strtotime($date.' '.$time) - time();
  114. if(isset($rowset[0]['PROPERTY']) && $time_cut<1800){
  115. $ifgps ='1';
  116. }else if($time_cut<1800){
  117. if(!getposition($order_bus_no)){
  118. $ifgps ='3';//没有gps
  119. }else{
  120. $ifgps ='1';
  121. }
  122. }else{
  123. $ifgps = '0';//没有到时间
  124. }
  125. } else {
  126. $ifgps ='2'; //没有排车
  127. $order_bus_no = "暂未指派";
  128. $order_driver_name = "暂未指派";
  129. }
  130. $list_going[$i]["ifdzbs"] = $ifdzbs;
  131. $list_going[$i]["ifgps"] = $ifgps;
  132. $list_going[$i]["driver_mobile"] = $driver_mobile;
  133. $list_going[$i]["order_id"] = $order_id;
  134. $list_going[$i]["2bcode"] = $ercode;
  135. $list_going[$i]["ifcheck"] = $check;
  136. $list_going[$i]["order_driver_name"] = $order_driver_name;
  137. $list_going[$i]["order_bus_no"] = $order_bus_no;
  138. $list_going[$i]["order_end_area_name"] = $order_end_area_name;
  139. $list_going[$i]["order_end_res_name"] = $order_end_res_name;
  140. $list_going[$i]["order_start_area_name"] = $order_start_area_name;
  141. $list_going[$i]["order_start_res_name"] = $order_start_res_name;
  142. $list_going[$i]["order_used_time"] = $order_used_time;
  143. $list_going[$i]["order_start_time"] = $order_start_time;
  144. $list_going[$i]["order_start_date"] = $order_start_date;
  145. $list_going[$i]["seat_num"] = $seat_num;
  146. $list_going[$i]["seat_type"] = $seat_type;
  147. $i++;
  148. }
  149. }
  150. if (empty($list_going)) {
  151. $jason_array = array();
  152. $jason_array["code"] = "0";
  153. $jason_array["info"] = array();
  154. $jason_array["list"] = "";
  155. echo json_encode($jason_array);
  156. exit();
  157. } else {
  158. $jason_array = array();
  159. $jason_array["code"] = "0";
  160. $jason_array["info"] = "查询成功";
  161. $temp_temp_temp = strtotime($list_going["0"]["year"]) - 86400 + 64800;
  162. if (time() > $temp_temp_temp) {
  163. $list_going["0"]["year"] = "即将出行";
  164. }
  165. $jason_array["list"] = $list_going;
  166. echo json_encode($jason_array);
  167. exit();
  168. }
  169. } else {
  170. //输入用户名为空
  171. $jason_array = array();
  172. $jason_array["code"] = "1";
  173. $jason_array["info"] = "查询失败";
  174. $jason_array["list"] = "";
  175. echo json_encode($jason_array);
  176. exit();
  177. }
  178. function get_dsnprod(){
  179. $msg_pdo = conn();
  180. $msg_sql = "CALL SP_GET_MESSAGE_TEMPLATE('1')";
  181. $content = '';
  182. if (is_object($msg_pdo)) {
  183. $msg_result = $msg_pdo -> query($msg_sql);
  184. $i = 1;
  185. $data = array();
  186. if ($msg_result) {
  187. $data['code'] = "0";
  188. $data['info'] = "";
  189. do {
  190. $row = $msg_result -> fetchAll(PDO::FETCH_ASSOC);
  191. if ($i == 1) {
  192. $data['seat'] = isset($row) ? $row : array();
  193. } else if ($i == 2) {
  194. $data['run_info'] = isset($row) ? $row : array();
  195. } else if ($i == 3) {
  196. $data['driver'] = isset($row) ? $row : array();
  197. } else if($i==4){
  198. $data['dsn_prod']=isset($row) ? $row : array();
  199. }else if($i==5){
  200. $data['zhou_su_prod']=isset($row) ? $row : array();
  201. }
  202. $i++;
  203. } while($msg_result->nextRowset());
  204. }
  205. $json_obj = json_decode(json_encode($data), TRUE);
  206. }
  207. foreach($data['dsn_prod'] as $temp){
  208. $dsn_arr_prod[]=$temp['prod_id'];
  209. }
  210. return $dsn_arr_prod;
  211. }