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.
 
 
 
 

147 lines
7.7 KiB

  1. <?php
  2. header("Access-Control-Allow-Origin:*");
  3. //载入配置文件和连接数据库
  4. require_once '../Common/Mysql.php';
  5. $njtpy_prod_array = array( 451023, 451024, 451025, 451026, 451027, 451028 );
  6. $njtpy_account_array = array( 156 );
  7. $pdo=conn();
  8. $order_id = trim($_POST['order_id']);
  9. $sql = "select
  10. a.order_id as main_order_id,
  11. a.order_description,
  12. b.order_id as son_order_id,
  13. b.prod_start_station_date as date,
  14. b.prod_start_station_time as time,
  15. a.customer_mobile as main_phone,
  16. a.customer_memo,
  17. a.customer_name,
  18. a.customer_id_no,
  19. b.create_user_id,
  20. b.order_price as order_price,
  21. b.run_bus_order_id as bus_no,
  22. b.run_bus_seat_name as seat_no,
  23. b.parent_prod_id as line_id,
  24. b.prod_start_station_area_name as start_area,
  25. b.prod_start_station_res_name as start_res,
  26. b.prod_end_station_area_name as end_area,
  27. b.prod_end_station_res_name as end_res
  28. from
  29. order_main as a,
  30. order_main as b
  31. where
  32. a.order_id in ( " . $order_id . " )
  33. and a.order_id = b.parent_order_id
  34. and a.cancel_flag = 0
  35. and b.cancel_flag = 0
  36. and b.order_prod_type = 82 ";
  37. $result = $pdo->query($sql);
  38. $order_info = $result->fetchAll(PDO::FETCH_ASSOC);
  39. //订单对应关系
  40. if(count($order_info) > 0){
  41. $order_view = array();
  42. foreach($order_info as $k => $v){
  43. $info_one = $v;
  44. if( in_array( $v["line_id"], $njtpy_prod_array ) ) {
  45. $info_one["supplier"] = 1;//njtpy
  46. } else {
  47. $info_one["supplier"] = 0;
  48. }
  49. $info_one["seat_no"] = mb_substr( $info_one["seat_no"], 1 );
  50. $son_name = explode('/',$v['customer_memo']);
  51. if( !in_array( $v["create_user_id"],$njtpy_account_array ) && false != $son_name && count($son_name) > 0 && trim($son_name[0]) != "" ) {
  52. if (!empty($v['customer_name']) && !empty($v['customer_id_no'])) {
  53. $son_name[] = $v['customer_name'] . "*" . $v['customer_id_no'];
  54. }
  55. $son_name = array_filter($son_name);
  56. $son_name = array_unique($son_name);
  57. ksort($son_name);
  58. } else {
  59. $son_name = array();
  60. $order_description = mb_substr($v['order_description'],0,mb_strlen($v['order_description'])-1);
  61. $order_des_array = explode(",", $order_description);
  62. $passenger_num = $order_des_array[count($order_des_array)-1];
  63. for( $index_temp = 0; $index_temp < $passenger_num; $index_temp++ ) {
  64. $son_name[] = $v['customer_name'] . "*" . $v['customer_id_no'];
  65. }
  66. }
  67. $son_name1 = array();
  68. foreach($son_name as $son_info){
  69. $son_name1[] = $son_info;
  70. }
  71. unset($info_one['customer_memo']);
  72. unset($info_one['customer_name']);
  73. unset($info_one['customer_id_no']);
  74. $order_view[$v['main_order_id']]['son_name'] = $son_name1;
  75. $order_view[$v['main_order_id']]['son_info'][] = $info_one;
  76. }
  77. //订单列表
  78. $order_list = array();
  79. foreach($order_view as $order_view_key => $order_view_value){
  80. if(!empty($order_view_value['son_name'][0])){
  81. foreach($order_view_value['son_name'] as $k => $v){
  82. $v_info = explode('*',$v);
  83. if(count($v_info) == 2 && isset($order_view_value['son_info'][$k])){
  84. $order_list[$order_view_value['son_info'][$k]['son_order_id']]["supplier"] = $order_view_value['son_info'][$k]["supplier"];
  85. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp'] = $order_view_value['son_info'][$k];
  86. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp']['date'] = date("n月j日",strtotime($order_view_value['son_info'][$k]['date']));
  87. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp']['son_name'] = $v_info[0];
  88. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp']['son_idcard'] = $v_info[1];
  89. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['start_area'] = $order_view_value['son_info'][$k]['start_area'];
  90. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['end_area'] = $order_view_value['son_info'][$k]['end_area'];
  91. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['order_price'] = $order_view_value['son_info'][$k]['order_price'];
  92. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['bus_no'] = $order_view_value['son_info'][$k]['bus_no'];
  93. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['seat_no'] = $order_view_value['son_info'][$k]['seat_no'];
  94. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['date'] = date("n月j日",strtotime($order_view_value['son_info'][$k]['date']));
  95. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['time'] = $order_view_value['son_info'][$k]['time'];
  96. if($order_view_value['son_info'][$k]['start_res'] == '旅游集散总站' && ($order_view_value['son_info'][$k]['start_area'] == '上海市' || $order_view_value['son_info'][$k]['start_area'] == '上海' ) && ($order_view_value['son_info'][$k]['end_area'] == '千岛湖镇' || $order_view_value['son_info'][$k]['end_area'] == '千岛湖')){
  97. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp']['start_res'] = '黄浦旅游集散站';
  98. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp']['time'] = '07:30';
  99. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['time'] = '07:30';
  100. }elseif($order_view_value['son_info'][$k]['end_res'] == '旅游集散总站' && ($order_view_value['son_info'][$k]['end_area'] == '上海市' || $order_view_value['son_info'][$k]['end_area'] == '上海') && ($order_view_value['son_info'][$k]['start_area'] == '千岛湖镇' || $order_view_value['son_info'][$k]['start_area'] == '千岛湖')){
  101. $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp']['start_res'] = '黄浦旅游集散站';
  102. }
  103. }
  104. }
  105. }
  106. }
  107. $order_list = array_merge($order_list);
  108. if(count($order_list) > 0){
  109. $code = 0;
  110. $info = "数据返回成功";
  111. $list = $order_list;
  112. $totalnum = count($order_list);
  113. //订单打印次数加1
  114. $sql = "update order_main set order_print_times = order_print_times+1 where order_id in (" . $order_id . ")";
  115. $result = $pdo->exec($sql);
  116. }else{
  117. $code = 2;
  118. $info = "订单均无乘客信息及身份证号";
  119. $list = "";
  120. $totalnum = 0;
  121. }
  122. }else{
  123. $code = 1;
  124. $info = "订单不存在或已过期";
  125. $list = "";
  126. $totalnum = 0;
  127. }
  128. $json['code'] = $code;
  129. $json['info'] = $info;
  130. $json['list'] = $list;
  131. $json['totalnum'] = $totalnum;
  132. echo json_encode($json);
  133. ?>