"1", "info" => "用户未登录")); exit ; } //$user_id=1; //取消订单原因 if(isset($_GET['reason'])){ $reason=$_GET['reason']; $order_id=$_GET['order_id']; $clock=$_GET['clock']; // $return_data = array(); // $return_data["code"] = 1; // $return_data["info"] = $reason; $pdo_insert = conn(); $sql = "insert into order_comment(ORDER_ID,COMMENT_TXT,CREATE_TIME) VALUES ({$order_id},'{$reason}','{$clock}')"; $result = $pdo_insert->exec($sql); } if ($method == "cancelOrder") { $order_id = isset($_GET['order_id']) ? $_GET['order_id'] : ""; $pdo = conn(); $list_d = Find($order_id); if($list_d['prod_id'] == 449862 || $list_d['prod_id'] == 449867 || $list_d['prod_id'] == 450039 || $list_d['prod_id'] == 450043 || $list_d['prod_id'] == 450541 || $list_d['prod_id'] == 450546 ){ $result = post2('http://wx.zhizhuchuxing.com/ZZDZ2/application/custom_made/control.php',array('type' =>'order_refund','order_id'=>$order_id)); $result = (array)json_decode($result,true); }else{ $sql = "CALL SP_CANCEL_ORDER(" . $user_id . "," . $order_id . ")"; writeLog('cancelOrder= sql='.$sql); $result = $pdo -> query($sql); if( false != $result ) { $rowset=$result->fetchAll(PDO::FETCH_ASSOC); $result = array(); $result['code'] = $rowset[0]['errorcode']; } } if($result){ if(isset($result['code']) && $result['code'] == 0){ $rowset['code'] ='0'; $rowset['info'] ='退票成功'; $data['code'] ='0'; $data['info'] = '退票成功'; $pdo_insert = conn(); $current_time = date("Y-m-d H:i:s"); $cancel_reason = "取消原因:".$reason; $sql = "insert into order_opera_log(order_id,opera_user_id,opera_type,opera_time,opera_detail,opera_platform) VALUES ({$order_id},$user_id,2,'{$current_time}','{$cancel_reason}','CS系统')"; $result = $pdo_insert->exec($sql); $post_data['order_id'] = "{$order_id}"; $post_data['order_status'] = "460"; $temp=post2("http://". CS_DOMAIN. "/st-xm/Api/add_order_status_log.php",$post_data); //在这里加入run_x重排,该取消订单所在的车次的run_x数据 $re_data=array(); $re_data['order_id']=$order_id; $temp2=post2("http://". CS_DOMAIN. "/api1.0/run_x_reorder.php",$re_data); $data['extra']=json_decode($temp2); }else{ $data['code']=isset($rowset[0]['errorcode'])?$rowset[0]['errorcode']:"499"; $data['info']=isset($rowset[0]['errorinfo'])?$rowset[0]['errorinfo']:"未从数据库中获得返回值"; $rowset['code'] = $data['code']; $rowset['info'] = $data['info']; $result -> closeCursor(); } // echo json_encode($data);exit(); }else{ $data['code']="500"; $data['info']="数据库错误"; echo json_encode($data);exit(); } if (is_array($rowset) && $rowset['code'] == 0 && SEND_MESSAGE == true) { $res_content = get_msg_info($order_id); $name = isset($res_content[0])?$res_content[0]:""; $tel = isset($res_content[1])?$res_content[1]:""; $content = isset($res_content[2])?$res_content[2]:""; // $content = "单号:" . $order_id . ',订单状态变更为' . $order_status . "随机数" . rand(1, 10000); writeLog("巴士取消短信模板内容:【" . $content . "】"); //..取消发短信 $response=null; $send_success="-100"; // $response = sendTelMessage($tel, $name, $content, $order_id); // writeLog(json_encode($response)); // $send_success = (int)$response; $comment_type=0; $comment_text=""; $sql1 = "CALL HT_ADD_MSG_COMMENT(".$user_id.",'addmsg'," . $order_id . "," . $comment_type . ",'" . $comment_text . "','" . $tel . "','" . $content . "','" . date("Y-m-d H:i:s") . "',{$send_success})"; $result1 = $pdo -> query($sql1); $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC); $result1 -> closeCursor(); writeLog("order_list.php HT_ADD_MSG_COMMENT()::" . $sql1); } echo json_encode($data);exit(); }else if($method=="getOrderORG"){ $pdo=conn(); // $sql="SELECT ORG_ID AS org_id ,ORG_NAME as soure FROM base_organization where cancel_flag=0;"; $sql="SELECT ID AS org_id ,SUPPLIER_NAME as soure FROM base_supplier where cancel_flag=0 AND SUPPLIER_TYPE=301"; $main_corp_id = isset($_COOKIE["user_main_corp"]) ? $_COOKIE["user_main_corp"] : 0; if( $main_corp_id > 0 ) { $sql .= " AND MAIN_CORP_ID IN(0,{$main_corp_id}) "; } if( $main_corp_id != 3 ) { $sql .= " AND MAIN_CORP_ID NOT IN(3) "; } $result=$pdo->query($sql); $rowset=array("code"=>"0","info"=>""); $rowset['order_ORG_List']=$result->fetchAll(PDO::FETCH_ASSOC); $result->closeCursor(); echo json_encode($rowset);exit(); } else { $timelimit = isset($_GET['timelimit']) ? $_GET['timelimit'] : ''; $starttime = isset($_GET['starttime']) ? $_GET['starttime'] : ''; $endtime = isset($_GET['endtime']) ? $_GET['endtime'] : ''; $ordersource = isset($_GET['ordersource']) ? (empty($_GET['ordersource']) ? 0 : $_GET['ordersource']) : 0; $orderstatus = isset($_GET['orderstatus']) ? (empty($_GET['orderstatus']) ? 0 : $_GET['orderstatus']) : 0; $paystatus = isset($_GET['paystatus']) ? (empty($_GET['paystatus']) ? -1 : $_GET['paystatus']) : -1; $bus_type= isset($_GET['bus_type']) ? (empty($_GET['bus_type']) ? -1 : $_GET['bus_type']) : -1; $billingstatus = isset($_GET['billingstatus']) ? $_GET['billingstatus'] : ''; $mealbounce = isset($_GET['mealbounce']) ? $_GET['mealbounce'] : ''; $refund = isset($_GET['refund']) ? $_GET['refund'] : ''; $moresearch = isset($_GET['moresearch']) ? trim($_GET['moresearch']) : ''; $export = isset($_GET['export']) ? $_GET['export'] : ''; //2016-07-15新增 $start_area=isset($_GET['start_area']) ? $_GET['start_area'] : ''; $end_area=isset($_GET['end_area']) ? $_GET['end_area'] : ''; $line=isset($_GET['line']) ? $_GET['line'] : ''; //..暂未加入存储过程 $currpage = isset($_GET['currpage']) ? (empty($_GET['currpage']) ? 1 : $_GET['currpage']) : 1; $pagesize = isset($_GET['pagesize']) ? (empty($_GET['pagesize']) ? 10 : $_GET['pagesize']) : 10; $pdo = conn(); $sql = "CALL XM_ORDER_GET_LIST(".$user_id.",'" . $timelimit . "','" . $starttime . "','" . $endtime . "'," . $ordersource . "," . $orderstatus . "," . $paystatus . ",'" . $billingstatus . "','" . $mealbounce . "','" . $refund . "','" . $moresearch . "','" . $export . "'," . $currpage . "," . $pagesize . ",'".$line."','".$start_area."','".$end_area."','".$bus_type."')"; writeLog('order_list.php -- sql== '.$sql); $result = $pdo -> query($sql); if( false == $result ) { echo json_encode(array("code" => "0", "info" => "", "searchInfo" => array()));exit(); } $data = array(); do { $rowset = $result -> fetchAll(PDO::FETCH_ASSOC); if ($rowset) { $data[] = $rowset; } } while ($result->nextRowset()); $count = count($data); // print_r(json_encode($data[3]));exit(); if ($count == 1 && isset($data[0][0]['code']) && $data[0][0]['code'] != 0) { echo json_encode($data[0][0]); } else if ($count == 4) { // } else if ($count > 0) { $data1 = array(); $data2 = array(); $data3 = array(); $order_id_array = array(); $data1=isset($data[1])?$data[1]:array(); foreach($data[1] as $k => $v){ $order_id_array[]=$v['parent_orderNo']; } $pdo2 = conn(); $search_extra_sql = " SELECT * FROM order_extra_info WHERE order_id IN (".implode(",",$order_id_array).") "; $result2 = $pdo2->query($search_extra_sql); $order_extra_array = $result2->fetchAll(); if( $order_extra_array != false && count($order_extra_array) > 0 ) { $order_extra_array2 = array(); foreach ( $order_extra_array as $order_extra_info ) { $order_extra_array2[$order_extra_info["order_id"]] = $order_extra_info; } $order_extra_array = $order_extra_array2; } $data1_temp = array(); $disp_pay_type = array("221" => "授信支付", "232" => "天猫旗舰店支付", "275" => "授信支付", "278" => "微信支付"); foreach( $data1 as $k=>$data1_info ) { if( isset($order_extra_array[$data1_info["M_ID"]]) ) { $data1_info["hotel_price"] = $order_extra_array[$data1_info["M_ID"]]["hotel_price"]; $data1_info["gate_price"] = $order_extra_array[$data1_info["M_ID"]]["gate_price"]; $extra_info_array = array(); if( isset($data1_info["hotel_price"]) && mb_strlen($data1_info["hotel_price"]) > 0 ) { $extra_info_array[] ="酒店:".$data1_info["hotel_price"]; } if( isset($data1_info["gate_price"]) && mb_strlen($data1_info["gate_price"]) > 0 ) { $extra_info_array[] ="门票:".$data1_info["gate_price"]; } $data1_info["seat"] .= "[br /]".implode(" ", $extra_info_array); } if( $data1_info["org_id"] == 17 or $data1_info["org_id"]== 28){ $data1_info["pay_type"] = "授信支付"; //携程与去哪儿汽车票均显示授信支付方式 $data1_temp[] = $data1_info; }else{ $data1_info["pay_type"] = isset($disp_pay_type[$data1_info["pay_type"]]) ? $disp_pay_type[$data1_info["pay_type"]] : ""; $data1_temp[] = $data1_info; } } $data1 = $data1_temp; // echo json_encode($data[1]);exit(); $json = array("code" => "0", "info" => ""); $json['totalTickets'] = $data[2][0]['num']; $json['totalPages'] = $data[2][0]['pagecount']; $json['currentpage'] = isset($data[2][0]['CURRENTPAGE']) ? $data[2][0]['CURRENTPAGE'] : "1"; $json['pagesize'] = $data[2][0]['PAGESIZE']; $json['orderSource'] = $data[0]; $json['orderList'] = array_values($data1); // print_r($data1);echo "
"; $or_st = array(); $or_st['status_all'] = $data[2][0]['num']; foreach ($data[3] as $da) { $or_st[$da['order_status']] = $da['order_cnt']; } $json['orderStatus'][] = $or_st; // $json['orderStatus'][$data[3]['order_status']]= // $row_count_array = array(); // foreach ($data[1] as $k => $v) { // if (!isset($row_count_array[$v["order_status"]])) { // $row_count_array[$v["order_status"]] = 0; // } // $row_count_array[$v["order_status"]]++; // } // $sum = (string)count($data[1]); // if ($sum == "0") { // $sum = ""; // } // $row_count_array['status_all'] = $data[2][0]['num']; // if (count($row_count_array) > 0) { // $json['orderStatus'][] = $row_count_array; // } else { // $json['orderStatus'][] = array(); // } //echo json_encode($data1); echo json_encode($json); } else { echo json_encode(array("code" => "0", "info" => "", "searchInfo" => array())); } } function get_msg_info($ORDER_ID) { $msg_pdo = conn(); $msg_sql = "CALL SP_GET_MESSAGE_TEMPLATE('" . $ORDER_ID . "')"; $content = ''; if (is_object($msg_pdo)) { $msg_result = $msg_pdo -> query($msg_sql); $i = 1; $data = array(); if ($msg_result) { $data['code'] = "0"; $data['info'] = ""; do { $row = $msg_result -> fetchAll(PDO::FETCH_ASSOC); if ($i == 1) { $data['seat'] = isset($row) ? $row : array(); } else if ($i == 2) { $data['run_info'] = isset($row) ? $row : array(); } else if ($i == 3) { $data['driver'] = isset($row) ? $row : array(); } else { } $i++; } while($msg_result->nextRowset()); } $json_obj = json_decode(json_encode($data), TRUE); $seat = isset($json_obj['seat'][0])?$json_obj['seat'][0]:array(); $run_info = isset($json_obj['run_info'][0])?$json_obj['run_info'][0]:array(); $driver = isset($json_obj['driver'][0])?$json_obj['driver'][0]:array(); //取消 $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已成功退票,期待下次再为您服务!"; if ($seat) { $seat_x = $seat['seat_x']; $seat_y = $seat['seat_y']; $seat_name = $seat['seat_name']; $order_main_id = $seat['order_main_id']; } if ($run_info) { $order_count = $run_info['order_count']; $start_date = $run_info['start_date']; $start_time = $run_info['start_time']; $parent_order_id = $run_info['parent_order_id']; $end_date = $run_info['end_date']; $start_area = $run_info['start_area']; $end_area = $run_info['end_area']; $res_name = $run_info['res_name']; $prod_name=$run_info['prod_name']; $prod_name="标准票"; $customer_name = $run_info['customer_name']; $customer_mobile = $run_info['customer_mobile']; $start_end_date = $start_date . "," . $start_time; $content = str_replace("{出发地}", $start_area, $content); $content = str_replace("{目的地}", $end_area, $content); $content = str_replace("{出发日期 出发时间}", $start_end_date, $content); $content = str_replace("{票种名}", $prod_name, $content); $content = str_replace("{张数}", $order_count, $content); } if ($driver) { $bus_no = $driver['bus_no']; $driver_name = $driver['driver_name']; $driver_mobile = $driver['driver_mobile']; } return array(isset($customer_name)?$customer_name:"", isset($customer_mobile)?$customer_mobile:"", isset($content)?$content:"短信错误!!!"); } } function post2($url, $data){//file_get_content $postdata = http_build_query( $data ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $result = file_get_contents($url, false, $context); return $result; } function Find($order_id){ $pdo= conn(); $sql = "select order_description,order_price,order_pay_main_id " . "from order_main " . "where order_id=".$order_id; $result=$pdo->query($sql); $rowset = $result -> fetchAll(PDO::FETCH_ASSOC); $order_price = $rowset[0];//订单总价格 订单票的数量 $sql = "SELECT DISTINCT order_description,parent_order_id,run_date,run_id,run_time,run_bus_order_id,prod_id,parent_prod_id,PROD_START_STATION_AREA_NAME,PROD_START_STATION_RES_NAME,PROD_END_STATION_AREA_NAME,PROD_END_STATION_RES_NAME FROM `order_main` where PARENT_ORDER_ID=".$order_id; $result=$pdo->query($sql); $rowset = $result -> fetchAll(PDO::FETCH_ASSOC); $order_station = $rowset[0];//订单来往地址 订单时间 订单好 if(empty($order_station)) return false; $array_order_desc=array(); $arr_temp = explode('|',$order_price['order_description']); $arr=array(); foreach ($arr_temp as $k=>$v2) { if(!empty($v2)) $array_order_desc[]= explode (',', $v2); //订单票 * 数量 } $list = array(); //上海(黄浦旅游集散站) - 乌镇(西栅1号停车场)//反的数组 $list['station'] = $order_station['PROD_START_STATION_AREA_NAME'].'('.$order_station['PROD_START_STATION_RES_NAME'].')' .'-'.$order_station['PROD_END_STATION_AREA_NAME'].'('.$order_station['PROD_END_STATION_RES_NAME'].')'; $list['start_station']=$order_station['PROD_START_STATION_AREA_NAME']; $list['end_station']=$order_station['PROD_END_STATION_AREA_NAME']; $list['start_res_name'] = $order_station['PROD_START_STATION_RES_NAME']; $list['end_res_name'] = $order_station['PROD_END_STATION_RES_NAME']; $list['run_date'] = $order_station['run_date']; $list['run_time'] = $order_station['run_date'].' '.$order_station['run_time']; $list['count']=''; $list['tic_num'] = 0; foreach ($array_order_desc as $v){ $list['count'] .= ' '.$v[0].' × '.$v[2]; $list['tic_num'] +=$v[2] ; } $list['order_price'] = $order_price['order_price']; $sql = "select pay_serial_number from order_pay_detail where pay_main_id =".$order_price['order_pay_main_id']; $result=$pdo->query($sql); $rowset = $result -> fetchAll(PDO::FETCH_ASSOC); $list['pay_num'] = $rowset[0]['pay_serial_number']; $list['line_id'] = $order_station['parent_prod_id']; $list['run_id'] = $order_station['run_id'];//run_bus_order_id $list['run_bus_order_id'] = $order_station['run_bus_order_id'];//parent_order_id $list['parent_order_id'] = $order_station['parent_order_id']; $list['prod_id'] = $order_station['prod_id']; return $list; } exit();