選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

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