1, "iflogin" => 1, "info" => "用户未登录")); exit; } //$_POST['iffirst']=''; //if(isset($_POST['order_id'])){}; //require_once '../../Common/Mysql.php'; //$_POST['ifback']=0; $back_order_id = 0; if ($_POST || 1) { $method = isset($_POST['iffirst']) ? $_POST['iffirst'] : "1"; $order_id = isset($_POST['order_id']) ? $_POST['order_id'] : "452074"; $ifback = "0"; $to_order_id = $order_id; //$order_id=204351; $pdo = conn(); $sql_s = "select * from to_from where to_orderid=" . $order_id . " or back_orderid=" . $order_id; $result = $pdo->query($sql_s); $rowset = $result->fetchAll(PDO::FETCH_ASSOC); $result->closeCursor(); if ($rowset) { $ifback = 1; $to_order_id = $rowset[0]['to_orderid']; $back_order_id = $rowset[0]['back_orderid']; if ($method == "0") { // $sql = "CALL SP_CANCEL_ORDER(" . 0 . "," . $to_order_id . ")"; // $result = $pdo->query($sql); // $return = $result->fetchAll(PDO::FETCH_ASSOC); // // // $sql = "CALL SP_CANCEL_ORDER(" . 0 . "," . $back_order_id . ")"; // $result = $pdo->query($sql); // $return2 = $result->fetchAll(PDO::FETCH_ASSOC); $send_post_data = array( "order_id" => $to_order_id, "user_id" => $user_id, "if_link" => 0, "cancel_reason" => "分销商取消", 'opera_platform' => 'SFX系统' ); $temp=httpRequest($cancel_url,$send_post_data); $send_post_data2 = array( "order_id" => $back_order_id, "user_id" => $user_id, "if_link" => 0, "cancel_reason" => "分销商取消", 'opera_platform' => 'SFX系统' ); $temp=httpRequest($cancel_url,$send_post_data2); $list['to'] = Find($to_order_id); $list['back'] = Find($back_order_id); if ($list['to'] && Find($back_order_id)) { $result->closeCursor(); $sql = "insert into order_refund(`order_id`,`price`,`pay_serial_number`) values(" . $back_order_id . "," . ($list['back']['order_price'] + $list['to']['order_price']) . ",'" . $list['back']['pay_num'] . "')"; $result = $pdo->query($sql); $result->closeCursor(); //取消订单 // $post_data['order_id'] = $to_order_id . ',' . $back_order_id; // $post_data['order_status'] = 460; // httpRequest("http://cs.zhizhuchuxing.com/st-xm/Api/add_order_status_log.php", $post_data); // // $pdo_insert = conn(); // $current_time = date("Y-m-d H:i:s"); // $cancel_reason = "取消原因:分销商取消"; // $sql = "insert into order_opera_log(order_id,opera_user_id,opera_type,opera_time,opera_detail,opera_platform) VALUES ({$to_order_id},$user_id,2,'{$current_time}','{$cancel_reason}','分销系统')"; // $result = $pdo_insert->exec($sql); // $sql = "insert into order_opera_log(order_id,opera_user_id,opera_type,opera_time,opera_detail,opera_platform) VALUES ({$back_order_id},$user_id,2,'{$current_time}','{$cancel_reason}','分销系统')"; // $result = $pdo_insert->exec($sql); $code = 0; $info = 'success'; $massge = '订单已取消'; $list = $list; } // } } else { $list['to'] = Find($to_order_id); $time_cut = strtotime($list['to']['run_time']) - time(); $list['back'] = Find($back_order_id); if ($list['to'] && Find($back_order_id)) { $code = 0; $info = 'success'; $massge = '成功'; $list = $list; if ($time_cut <= 1800) { $code = 1; $info = 'fail'; $massge = '开车前30分钟禁止退票,请刷新页面确认时间'; $list = ""; } } else { $code = 1; $info = 'fail'; $massge = '失败'; $list = ""; } } // $time_cut = strtotime($list['to']['run_time'])-time(); ///时间在开场30分钟前可以退票 } else { //单程情况 if ($method == "0") { $pdo = conn(); // $sql = "CALL SP_CANCEL_ORDER(" . 0 . "," . $order_id . ")"; // $result = $pdo->query($sql); // $return = $result->fetchAll(PDO::FETCH_ASSOC); // if(isset($return[0]['@errorcode']) && $return[0]['@errorcode']=='-1'){ // $code =1; // $info = 'fail'; // $massge = '失败'; // $list = ""; // }else{ $send_post_data = array( "order_id" => $order_id, "user_id" => $user_id, "if_link" => 0, "cancel_reason" => "分销商取消", 'opera_platform' => 'SFX系统' ); $temp=httpRequest($cancel_url,$send_post_data); $list = Find($order_id); // // $result->closeCursor(); $sql = " insert into order_refund(`order_id`,`price`,`pay_serial_number`) values(" . $order_id . "," . $list['order_price'] . ",'" . $list['pay_num'] . "')"; $result = $pdo->query($sql); $result->closeCursor(); //取消订单 // $post_data['order_id'] = $order_id; // $post_data['order_status'] = 460; // httpRequest("http://cs.zhizhuchuxing.com/st-xm/Api/add_order_status_log.php", $post_data); // // $pdo_insert = conn(); // $current_time = date("Y-m-d H:i:s"); // $cancel_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}','分销系统')"; // $result = $pdo_insert->exec($sql); $code = 0; $info = 'success'; $massge = '订单已取消'; $list = $list; // } } else { if ($list = Find($order_id)) { $code = 0; $info = 'success'; $massge = '成功'; $list = $list; $time_cut = strtotime($list['run_time']) - time(); if ($time_cut <= 1800) { $code = 1; $info = 'fail'; $massge = '开车前30分钟禁止退票'; $list = ""; } } else { $code = 1; $info = 'fail'; $massge = '失败'; $list = ""; } } //$time_cut = strtotime($list['run_time'])-time(); ///时间在开场30分钟前可以退票 } } else { $code = 1; $info = 'fail'; $massge = '失败'; $list = ""; } $json['ifback'] = $ifback; $json['code'] = $code; $json['info'] = $massge; $json['order_id'] = $to_order_id; $json['back_order_id'] = $back_order_id; $json['massge'] = $massge; $json['list'] = $list; echo json_encode($json); die; 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_time,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'] = ''; foreach ($array_order_desc as $v) { if( !isset($v[2]) ) { continue; } $list['count'] .= ' ' . $v[0] . ' × ' . $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']; return $list; }