1, "iflogin" => 1, "info" => "用户未登录")); exit; } $currpage = isset($_POST['currpage']) ? $_POST['currpage'] : '1'; $pagesize = isset($_POST['pagesize']) ? $_POST['pagesize'] : '10'; $list_start = ($currpage - 1) * $pagesize; $condition = ''; if ($_POST) { $condition = array(); //定义条件数组 //接受条件数据 $time_style = isset($_POST['time_style']) ? $_POST['time_style'] : ''; //timestyle=1 代表创建时间 =2 代表是出发时间 if ($user_id >= 65 && $user_id <= 113 && $user_id != 106 && $user_id != 107) { $start_time = isset($_POST['start_time']) ? $_POST['start_time'] > '2016-09-01' ? $_POST['start_time'] : '2016-09-01' : '2016-09-01'; } else { $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:01"'; //创建时间条件筛选 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 . '"'; // 出发时间筛选 empty($end_time) ? null : $condition[] = ' and a.run_date <= "' . $end_time . '"'; } 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 . '%" '; if ($product_type == 257) { $condition[] = ' and order_prod_type in (258,259) '; } else { empty($product_type) ? null : $condition[] = ' and bus_type=' . $product_type; } if ($order_id == 1 || $order_id == 2 || $order_id == 3) { if ($order_id == 1) $condition[] = ' and a.PARENT_ORDER_ID like "%' . $order_condition . '%"'; if ($order_id == 2) $condition[] = ' and a.customer_name like "%' . $order_condition . '%"'; if ($order_id == 3) $condition[] = ' and a.customer_mobile like "%' . $order_condition . '%"'; } $condition2 = ''; if (isset($_POST['order_status'])) { $_POST['order_status'] != 0 ? $condition2 = ' and order_status=' . $_POST['order_status'] : null; } $condition = implode('', $condition); //订单状态条件 148 已取消 146 已出票 147已出行 } //echo $condition;die; //$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 ORDER_BOOK_STATUS=1 and CANCEL_FLAG=0 and outside_sale_org_id =" . $order_from_org_id . " $condition2 "; $result = $pdo->query($sql); $json = array(); do { $rowset = $result->fetchAll(PDO::FETCH_ASSOC); if ($rowset) { $json = $rowset; } } while ($result->nextRowset()); if (empty($json)) { $data = (array("code" => "0", "info" => "此条件下没有订单", "list_count" => 0, "searchInfo" => array())); echo json_encode($data); die; } foreach ($json as $v) { $json2[] = $v['order_id']; } $sql = "select DISTINCT PARENT_ORDER_ID,line_type as bus_type" . " from order_main a left join opera_line b on a.parent_prod_id = b. line_id "//and main_create_user_id =".$user_id." . "where PARENT_ORDER_ID in(" . implode(",", $json2) . ") " . $condition . " order by a.create_time desc";//and PARENT_ORDER_ID = 203839 //echo $sql; //die; $result_id = $pdo->query($sql); $json_id = array(); $json = array(); $bus_type = array(); do { $rowset = $result_id->fetchAll(PDO::FETCH_ASSOC); if ($rowset) { $json = $rowset; } } while ($result_id->nextRowset()); //var_dump($json);die; 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']; $bus_type[$v['PARENT_ORDER_ID']] = $v['bus_type']; } //条件筛选后的订单编号 //echo $sql; //var_dump($json_id);die; $sql = "select a.prod_name,a.order_prod_type,a.order_description,a.ORDER_PAY_MAIN_ID,a.order_id,a.customer_name,a.customer_mobile,a.customer_id_type,a.customer_id_no,a.order_price,a.order_status,a.create_time,a.prod_id " . "from order_main as a " . "where a.PARENT_ORDER_ID=0 and a.ORDER_ID in (" . implode(",", $json_id) . ")";//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); } $array_order_desc[$v['order_id']] = $arr; } //var_dump($array_order_desc);die; $sql3 = "select parent_order_id,PROD_START_STATION_DATE as run_date,PROD_START_STATION_TIME as 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']; //订单的状态 $order_status_id[$v['ORDER_ID']] = $v['order_status'];//订单的状态 } $array_order_list = array(); //echo count($pay_type_arr),'--', count($json_id); //var_dump($array_order_desc);die; $top_org_id = $_COOKIE['top_org_id']; foreach ($json_id as $v) { $tic = ''; if ($order_info[$v]['order_prod_type'] == 258 || $order_info[$v]['order_prod_type'] == 259) { foreach ($array_order_desc[$v] as $v1) { if( !isset($v1[2]) ) { continue; } $tic .= str_replace('迪士尼剧场', '', $v1[0]) . '×' . $v1[2] . ' '; if (isset($v1['ifback'])) $ifback = $v1['ifback']; } $product_info = $order_info[$v]['prod_name'] . '
' . $tic; $ifdisn = 1; if ($order_info[$v]['order_prod_type'] == 258) { $type = "迪士尼门票"; } else { $type = "迪士尼剧场"; } if ($top_org_id != 0) { $go_to = 0;//不显示 } else { if ($order_status_id[$v] == 145) { $time_cut = time() - strtotime($order_info[$v]['create_time']); if ($time_cut > 600) { $go_to = 0; } else { $go_to = 1; } } else { $go_to = '0'; } } } else { if ($bus_type[$v] == 255) { $type = "直通巴士"; } else { $type = "穿梭巴士"; } foreach ($array_order_desc[$v] as $v1) { if(isset($v1[2])){ $tic .= str_replace('票', '', $v1[0]) . '×' . $v1[2] . ' '; }else{ continue; $tic .= str_replace('票', '', $v1[0]); } if (isset($v1['ifback'])) $ifback = $v1['ifback']; } $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; $ifdisn = 0; //退票 去支付 空 if ($top_org_id != 0) { $time_cut = strtotime($station[$v]['run_date'] . ' ' . $station[$v]['run_time'] . ':01') - time(); if ($order_status_id[$v] == 146) { if ($time_cut < 1800) { $go_to = 0; } else { $go_to = 2;//退票 } } else { $go_to = 0; } } else { $time_cut = strtotime($station[$v]['run_date'] . ' ' . $station[$v]['run_time'] . ':01') - time(); if ($order_status_id[$v] == 146) { if ($time_cut < 1800) { $go_to = 0; } else { $go_to = 0;//退票 } } else { $time_cut = time() - strtotime($order_info[$v]['create_time']); if ($time_cut > 600) { $go_to = 0; } else { if ($order_status_id[$v] == 145) $go_to = 1; else $go_to = 0; } } } } // if($order_info[$v]['order_prod_type']==258 || $order_info[$v]['order_prod_type']==259){ // foreach($array_order_desc[$v] as $v1){ // $tic.= str_replace('迪士尼剧场','',$v1[0]).'×'.$v1[2].' '; // if(isset($v1['ifback'])) // $ifback=$v1['ifback']; // } // $product_info =$order_info[$v]['prod_name'].'
'.$tic; // $ifdisn=0; // }else{ // foreach($array_order_desc[$v] as $v1){ // $tic.= str_replace('票','',$v1[0]).'×'.$v1[2].' '; // if(isset($v1['ifback'])) // $ifback=$v1['ifback']; // } // $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; // // $ifdisn=1; // } $array_order_list[] = array( 'order_id' => $v, 'create_time' => $order_info[$v]['create_time'], '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'], 'product_info' => $product_info, 'ifdisney' => $ifdisn, 'run_time' => $station[$v]['run_date'] . ' ' . $station[$v]['run_time'], 'customer_info' => $order_info[$v]['customer_name'] . '
' . $order_info[$v]['customer_mobile'] . '
' . $order_info[$v]['customer_id_no'], 'order_pay' => $order_info[$v]['order_price'], 'order_pay_type' => $pay_type_arr[$v], 'order_status' => $order_status[$v], 'go_pay' => $go_to ); } $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);