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 == "2") { $list['to'] = Find($to_order_id); $time_cut = strtotime($list['to']['run_time'])-time(); $list['back'] = Find($back_order_id); $time_cut2 = strtotime($list['back']['run_time'])-time(); if($time_cut<=1800){ $code ='1'; $info = '开车前30分钟禁止退票'; $massge = '开车前30分钟禁止退票,请刷新页面确认时间'; $list = ""; }else{ $sql = "CALL SP_CANCEL_ORDER(" . 0 . "," . $to_order_id . ")"; $result = $pdo -> query($sql); $rowset = $result -> fetchAll(PDO::FETCH_ASSOC); $result -> closeCursor(); $sql = "CALL SP_CANCEL_ORDER(" . 0 . "," . $back_order_id . ")"; $result2 = $pdo -> query($sql); $rowset2 = $result2 -> fetchAll(PDO::FETCH_ASSOC); if(!isset($rowset[0]['errorinfo'])){ $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); $code = '0'; $info = 'success'; $massge = '成功'; }else{ $code = '1'; $info = $rowset[0]['errorinfo']; $massge = $rowset[0]['errorinfo']; } } } // $time_cut = time()-strtotime($list['to']['run_time']); ///时间在开场30分钟前可以退票 }else{ //单程情况 if ($method == "2") { $pdo = conn(); $list = Find($order_id); $time_cut = strtotime($list['run_time'])-time(); if($time_cut<=1800){ $code ='1'; $info = 'fail'; $massge = '开车前30分钟禁止退票'; $list = ""; }else{ $sql = "CALL SP_CANCEL_ORDER(" . 0 . "," . $order_id . ")"; $result = $pdo -> query($sql); $rowset = $result -> fetchAll(PDO::FETCH_ASSOC); $result -> closeCursor(); if(!isset($rowset[0]['errorinfo'])){ $sql = " insert into order_refund(`order_id`,`price`,`pay_serial_number`) values(".$order_id.",".$list['order_price'].",'".$list['pay_num']."')"; $pdo ->query($sql); $code = '0'; $info = 'success'; $massge = '订单已取消'; }else{ $code = '1'; $info =$rowset[0]['errorinfo']; $massge = $rowset[0]['errorinfo']; } } $result -> closeCursor(); } //$time_cut = time()-strtotime($list['run_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; 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){ $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; }