|
- <?php
- header("Access-Control-Allow-Origin:*");
- //载入配置文件和连接数据库
-
- require_once '../Common/Mysql.php';
-
- $njtpy_prod_array = array( 451023, 451024, 451025, 451026, 451027, 451028 );
- $njtpy_account_array = array( 156 );
-
- $pdo=conn();
- $order_id = trim($_POST['order_id']);
-
- $sql = "select
- a.order_id as main_order_id,
- a.order_description,
- b.order_id as son_order_id,
- b.prod_start_station_date as date,
- b.prod_start_station_time as time,
- a.customer_mobile as main_phone,
- a.customer_memo,
- a.customer_name,
- a.customer_id_no,
- b.create_user_id,
- b.order_price as order_price,
- b.run_bus_order_id as bus_no,
- b.run_bus_seat_name as seat_no,
- b.parent_prod_id as line_id,
- b.prod_start_station_area_name as start_area,
- b.prod_start_station_res_name as start_res,
- b.prod_end_station_area_name as end_area,
- b.prod_end_station_res_name as end_res
- from
- order_main as a,
- order_main as b
- where
- a.order_id in ( " . $order_id . " )
- and a.order_id = b.parent_order_id
- and a.cancel_flag = 0
- and b.cancel_flag = 0
- and b.order_prod_type = 82 ";
-
-
- $result = $pdo->query($sql);
- $order_info = $result->fetchAll(PDO::FETCH_ASSOC);
-
- //订单对应关系
- if(count($order_info) > 0){
- $order_view = array();
- foreach($order_info as $k => $v){
- $info_one = $v;
- if( in_array( $v["line_id"], $njtpy_prod_array ) ) {
- $info_one["supplier"] = 1;//njtpy
- } else {
- $info_one["supplier"] = 0;
- }
- $info_one["seat_no"] = mb_substr( $info_one["seat_no"], 1 );
- $son_name = explode('/',$v['customer_memo']);
- if( !in_array( $v["create_user_id"],$njtpy_account_array ) && false != $son_name && count($son_name) > 0 && trim($son_name[0]) != "" ) {
- if (!empty($v['customer_name']) && !empty($v['customer_id_no'])) {
- $son_name[] = $v['customer_name'] . "*" . $v['customer_id_no'];
- }
- $son_name = array_filter($son_name);
- $son_name = array_unique($son_name);
- ksort($son_name);
- } else {
- $son_name = array();
- $order_description = mb_substr($v['order_description'],0,mb_strlen($v['order_description'])-1);
- $order_des_array = explode(",", $order_description);
- $passenger_num = $order_des_array[count($order_des_array)-1];
- for( $index_temp = 0; $index_temp < $passenger_num; $index_temp++ ) {
- $son_name[] = $v['customer_name'] . "*" . $v['customer_id_no'];
- }
- }
- $son_name1 = array();
- foreach($son_name as $son_info){
- $son_name1[] = $son_info;
- }
- unset($info_one['customer_memo']);
- unset($info_one['customer_name']);
- unset($info_one['customer_id_no']);
- $order_view[$v['main_order_id']]['son_name'] = $son_name1;
- $order_view[$v['main_order_id']]['son_info'][] = $info_one;
- }
-
- //订单列表
- $order_list = array();
-
- foreach($order_view as $order_view_key => $order_view_value){
- if(!empty($order_view_value['son_name'][0])){
- foreach($order_view_value['son_name'] as $k => $v){
- $v_info = explode('*',$v);
- if(count($v_info) == 2 && isset($order_view_value['son_info'][$k])){
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]["supplier"] = $order_view_value['son_info'][$k]["supplier"];
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp'] = $order_view_value['son_info'][$k];
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp']['date'] = date("n月j日",strtotime($order_view_value['son_info'][$k]['date']));
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp']['son_name'] = $v_info[0];
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp']['son_idcard'] = $v_info[1];
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['start_area'] = $order_view_value['son_info'][$k]['start_area'];
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['end_area'] = $order_view_value['son_info'][$k]['end_area'];
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['order_price'] = $order_view_value['son_info'][$k]['order_price'];
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['bus_no'] = $order_view_value['son_info'][$k]['bus_no'];
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['seat_no'] = $order_view_value['son_info'][$k]['seat_no'];
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['date'] = date("n月j日",strtotime($order_view_value['son_info'][$k]['date']));
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['time'] = $order_view_value['son_info'][$k]['time'];
- 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'] == '千岛湖')){
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp']['start_res'] = '黄浦旅游集散站';
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp']['time'] = '07:30';
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['lp']['time'] = '07:30';
- }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'] == '千岛湖')){
- $order_list[$order_view_value['son_info'][$k]['son_order_id']]['tp']['start_res'] = '黄浦旅游集散站';
- }
- }
- }
- }
- }
-
- $order_list = array_merge($order_list);
- if(count($order_list) > 0){
- $code = 0;
- $info = "数据返回成功";
- $list = $order_list;
- $totalnum = count($order_list);
- //订单打印次数加1
- $sql = "update order_main set order_print_times = order_print_times+1 where order_id in (" . $order_id . ")";
- $result = $pdo->exec($sql);
- }else{
- $code = 2;
- $info = "订单均无乘客信息及身份证号";
- $list = "";
- $totalnum = 0;
- }
- }else{
- $code = 1;
- $info = "订单不存在或已过期";
- $list = "";
- $totalnum = 0;
- }
-
- $json['code'] = $code;
- $json['info'] = $info;
- $json['list'] = $list;
- $json['totalnum'] = $totalnum;
-
- echo json_encode($json);
-
-
- ?>
|