1, "info" => "用户未登录")); exit ; } $currpage = isset($_POST['currpage'])?$_POST['currpage']:'1'; $pagesize = isset($_POST['pagesize'])?$_POST['pagesize']:'1000'; $list_start= ($currpage-1)*$pagesize; $condition=''; if($_POST){ $condition=array(); //定义条件数组 //接受条件数据 $time_style = isset($_POST['time_style'])?$_POST['time_style']:''; //timestyle=1 代表创建时间 =2 代表是出发时间 $start_time=isset($_POST['start_time'])?$_POST['start_time']:''; $end_time=isset($_POST['end_time'])?$_POST['end_time']:''; $start_area=isset($_POST['start_area'])?$_POST['start_area']:''; $end_area=isset($_POST['end_area'])?$_POST['end_area']:''; $product_type=isset($_POST['product_type'])?$_POST['product_type']:''; //票种类 0.256.255.257 0为空 256穿梭巴士,255直通巴士 $order_id=isset($_POST['order_id'])?$_POST['order_id']:''; //订单号 1,2,3, 1 为 订单号 2 为客户姓名 3 为客户手机号 $order_condition=isset($_POST['condition'])?$_POST['condition']:''; if($time_style==1){ empty($start_time)?null:$condition[]=' and a.create_time >= "'.$start_time.' 00:00:00"'; //创建时间条件筛选 empty($end_time)?null:$condition[]=' and a.create_time <= "'.$end_time.' 23:59:00"'; }elseif($time_style==2){ empty($start_time)?null:$condition[]=' and a.run_date >= "'.$start_time.' 00:00:00"'; // 出发时间筛选 empty($end_time)?null:$condition[]=' and a.run_date <= "'.$end_time.' 23:59:00"'; } empty($start_area)?null:$condition[]=' and PROD_START_STATION_AREA_NAME like "%'.$start_area.'%" '; empty($end_area)?null:$condition[]=' and PROD_END_STATION_AREA_NAME like "%'.$end_area.'%" '; empty($product_type)?null:$condition[]=' and bus_type='.$product_type; if(!empty($order_condition)){ if($order_id==1) $condition[]=' and a.PARENT_ORDER_ID='.$order_condition; if($order_id==2) $condition[]=' and a.customer_name = '.$order_condition; if($order_id=3) $condition[]=' and a.customer_mobile = '.$order_condition; } if(isset($_POST['order_status'])){ $_POST['order_status']!=0?$condition[]=' and order_status='.$_POST['order_status']:null; } $condition= implode('', $condition); //订单状态条件 148 已取消 146 已出票 147已出行 } //$order_status=isset($_POST['order_status'])?$condition[]=' and order_status='.$_POST['order_status']:null; //var_dump($condition);die; $pdo= conn(); $sql="select a.order_id " . "from order_main as a " . "where a.PARENT_ORDER_ID=0 and CANCEL_FLAG=0 "; $result=$pdo->query($sql); $json=array(); do { $rowset = $result -> fetchAll(PDO::FETCH_ASSOC); if ($rowset) { $json = $rowset; } } while ($result->nextRowset()); foreach ($json as $v) { $json2[]=$v['order_id']; } $sql = "select DISTINCT PARENT_ORDER_ID" . " from order_main a left join OPERA_PRODUCT b on a.parent_prod_id = b. prod_id "//and main_create_user_id =".$user_id." . "where PARENT_ORDER_ID in(". implode(",", $json2).") $condition and order_prod_type = 82 order by a.create_time desc";//and PARENT_ORDER_ID = 203839 //echo $sql; //die; $result_id=$pdo->query($sql); $json_id=array(); $json=array(); do { $rowset = $result_id -> fetchAll(PDO::FETCH_ASSOC); if ($rowset) { $json = $rowset; } } while ($result_id->nextRowset()); if(empty($json)){ $data = (array("code" => "0", "info" => "此条件下没有订单","list_count"=>0, "searchInfo" =>array())); echo json_encode($data); die; } foreach ($json as $v) { if(isset($v['PARENT_ORDER_ID'])); $json_id[]=$v['PARENT_ORDER_ID']; } //条件筛选后的订单编号 //echo $sql; //var_dump($json_id);die; $sql="select a.order_description,a.ORDER_PAY_MAIN_ID,a.order_id,a.customer_name,a.customer_mobile,a.order_price,a.order_status,a.create_time,a.prod_id " . "from order_main as a " . "where a.PARENT_ORDER_ID=0 ";//on a.order_id=b.order_id $result=$pdo->query($sql); $data=array(); do { $rowset = $result -> fetchAll(PDO::FETCH_ASSOC); if ($rowset) { $data[] = $rowset; // } } while ($result->nextRowset()); $order_info=array(); foreach ($data[0] as $v) { $order_info[$v['order_id']]=$v; //价格手机 姓名 run_time pay_time } $array_order_desc=array(); foreach ($data[0] as $v) { $arr_temp = explode('|',$v['order_description']); $arr=array(); foreach ($arr_temp as $k=>$v2) { if(!empty($v2)) $arr[]= explode (',', $v2); } if(mb_strpos($arr['0'][0], '往返')){ $arr[0]['ifback']=1; $array_order_desc[$v['order_id']]=$arr; //订单票 * 数量 }else{ $arr[0]['ifback']=0; $array_order_desc[$v['order_id']]=$arr; } } //var_dump($array_order_desc);die; $sql3="select 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 in (". implode(",", $json_id).")"; $result3=$pdo->query($sql3); $rowset3 = $result3 -> fetchAll(PDO::FETCH_ASSOC); foreach ($rowset3 as $v) { $station[$v['parent_order_id']]=$v;//上车站下车站 详情 } //获取支付方式 $sql2="select a.ORDER_ID,b.PAY_TYPE_ID_1,c.TYPE_NAME from (ORDER_MAIN a left join ORDER_PAY_DETAIL b on a.ORDER_PAY_MAIN_ID=b.pay_main_id) left join dict_type c on c.id=b.PAY_TYPE_ID_1 " . " where a.ORDER_ID in (". implode(",", $json_id).")"; $result2=$pdo->query($sql2); do { $rowset2 = $result2 -> fetchAll(PDO::FETCH_ASSOC); if ($rowset2) { $pay_type[] = $rowset2; } } while ($result2->nextRowset()); foreach ($pay_type[0] as $v) { $pay_type_arr[$v['ORDER_ID']]=$v['TYPE_NAME']; //支付方式 } //支付状态 $sql4="select a.ORDER_ID,a.order_status,c.TYPE_NAME from (ORDER_MAIN a left join ORDER_PAY_DETAIL b on a.ORDER_PAY_MAIN_ID=b.pay_main_id) left join dict_type c on c.id=a.ORDER_STATUS " . " where a.ORDER_ID in (". implode(",", $json_id).")"; $result4=$pdo->query($sql4); do { $rowset4 = $result4 -> fetchAll(PDO::FETCH_ASSOC); if ($rowset4) { $order_sta[] = $rowset4; } } while ($result4->nextRowset()); foreach ($order_sta[0] as $v) { $order_status[$v['ORDER_ID']]=$v['TYPE_NAME']; //订单的状态 } $array_order_list=array(); //echo count($pay_type_arr),'--', count($json_id); //var_dump($array_order_desc);die; foreach ($json_id as $v) { $tic=''; foreach($array_order_desc[$v] as $v1){ if( !isset($v1[2]) ) { continue; } $tic.= $v1[0].'×'.$v1[2].' '; if(isset($v1['ifback'])) $ifback=$v1['ifback']; } $array_order_list[]=array( 'order_id' =>$v, 'create_time' =>$order_info[$v]['create_time'], 'product_info' =>$station[$v]['PROD_START_STATION_AREA_NAME'].'('.$station[$v]['PROD_START_STATION_RES_NAME'].')'.'-'.$station[$v]['PROD_END_STATION_AREA_NAME'].'('.$station[$v]['PROD_END_STATION_RES_NAME'].')'.' '.$tic, 'start_station_area' => $station[$v]['PROD_START_STATION_AREA_NAME'], 'start_station_name' => $station[$v]['PROD_START_STATION_RES_NAME'], 'end_station_area' => $station[$v]['PROD_END_STATION_AREA_NAME'], 'end_station_name' => $station[$v]['PROD_END_STATION_RES_NAME'], 'run_time' =>$station[$v]['run_date'].' '.$station[$v]['run_time'], 'customer_info'=>$order_info[$v]['customer_name'].' '.$order_info[$v]['customer_mobile'], 'order_pay' =>$order_info[$v]['order_price'], 'order_pay_type' =>$pay_type_arr[$v], 'order_status' => $order_status[$v], 'ifback' => $ifback ); } $list_count= count($array_order_list); //echo $list_count; $array_order_list=array_slice($array_order_list, $list_start,$pagesize); $data = (array("code" => "0", "info" => "","list_count"=>$list_count, "searchInfo" =>$array_order_list)); echo json_encode($data);