|
- <?php
- /*
- Author:fuhc
- Compeny:导出次日上车乘客信息 将备注转为一条数据添加进去
- */
- require_once '../Common/Mysql.php';
- if (ALLOW_ORIGIN)
- header("Access-Control-Allow-Origin:*");
- set_time_limit(1200);
- $method = isset($_GET['method']) ? $_GET['method'] : "";
-
- $timelimit = isset($_GET['timelimit']) ? $_GET['timelimit'] : '出发时间';
- $starttime = isset($_GET['starttime']) ? $_GET['starttime'] : date("Y-m-d");
- $endtime = isset($_GET['endtime']) ? $_GET['endtime'] : date("Y-m-d");
- //$starttime = "2016-08-04";
- //$endtime = "2016-08-04";
- $ordersource = isset($_GET['ordersource']) ? (empty($_GET['ordersource']) ? -1 : $_GET['ordersource']) : -1;
- $orderstatus = isset($_GET['orderstatus']) ? (empty($_GET['orderstatus']) ? 0 : $_GET['orderstatus']) : 0;
- $moresearch = isset($_GET['moresearch']) ? $_GET['moresearch'] : '';
-
- //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'] : '';
-
- //2016-10-19新增
- $bus_type_param = isset($_GET['bus_type'])?$_GET['bus_type']:"0";
-
- $pdo = conn();
- //IN `TIMELIMIT` VARCHAR(20), IN `STARTTIME` VARCHAR(20), IN `ENDTIME` VARCHAR(20), IN `ORDERSOURCE` INT, IN `ORDERSTATUS` INT, IN `MORESEARCH` VARCHAR(50), IN `LINE` VARCHAR(20), IN `START_AREA` VARCHAR(20), IN `END_AREA` VARCHAR(20)
- //$sql = "CALL SP_EXPORT_CUSTOMERINFO(1,'" . $timelimit . "','" . $starttime . "','" . $endtime . "'," . $ordersource . "," . $orderstatus . "," . $paystatus . ",'" . $billingstatus . "','" . $mealbounce . "','" . $refund . "','" . $moresearch . "','" . $export . "'," . $currentpage . "," . $pagesize . ",'" . $line . "','" . $start_area . "','" . $end_area . "')";
- $sql = "CALL SP_EXPORT_CUSTOMER('".$timelimit."','".$starttime."','".$endtime."','".$ordersource."','".$orderstatus."','".$moresearch."','".$line."','".$start_area."','".$end_area."');";
- writeLog('order_list2.php export-- sql== '.$sql);
- if($pdo){
- $result = $pdo -> query($sql);
- if($result){
- $data = array();
- $data = $result -> fetchAll(PDO::FETCH_ASSOC);
- }else{
- $data['code']="400";
- $data['info']="数据库错误";
- echo json_encode($data);exit();
- }
- }else{
- $data['code']="500";
- $data['info']="连接数据库错误";
- echo json_encode($data);exit();
- }
- $str = "线路名称,线路类型,车号,车牌号码,司机姓名,司机手机,上车站点,下车站点,预订日期,发班日期,发班时间,乘客预定时间,产品名称,座位等级,出行人数,分销价,GMV,游客姓名,联系方式,身份证号,渠道,渠道订单号,订单号,状态" . "\n";
- for ($i = 0; $i < count($data); $i++) {
- $dict = $data[$i];
- $send_bus_no = $dict["send_bus_no"] . "\t";
- // $bus_type = $dict["bus_type"] . "\t";
- $send_driver_name = $dict["send_driver_name"] . "\t";
- $disp_bus_type = array("255" => "直通巴士", "256" => "穿梭巴士","284" => "城际商务车");
- // $bus_type = isset($disp_bus_type[$dict["bus_type"]])?$disp_bus_type[$dict["bus_type"]]. "\t": "-";
- if($bus_type_param=="0"){
- $bus_type = isset($disp_bus_type[$dict["bus_type"]])?$disp_bus_type[$dict["bus_type"]]. "\t": "-";
- }else{
- if($bus_type_param!=$dict['bus_type']){
- continue;
- }
- $bus_type = isset($disp_bus_type[$bus_type_param])?$disp_bus_type[$bus_type_param]. "\t": "-";
- }
- $send_driver_mobile = $dict["send_driver_mobile"] . "\t";
- $line = $dict['line'] . "\t";
- $start_station = $dict['start_station'] . "\t";
- $end_station = $dict['end_station'] . "\t";
- $run_date = substr($dict['run_date'], 0, 10) . "\t";
- $bus_run_time = substr($dict['run_time'], 0, 10) . "\t";
- $run_time = substr($dict['run_time'], 0, 10) . "\t";
- $prod_name=$dict['prod_name']."\t";
- $create_time=$dict['create_time']."\t";
- $seat=$dict['seat']."\t";
- $order_count = $dict['order_count']."\t";
- $order_price=$dict['order_price']."\t";
- $GMV = isset($dict['gmv']) ? $dict['gmv'] . "\t" : "-";
- $customer_name = isset($dict['customer_name'])?$dict['customer_name']. "\t":"-" ;
- $customer_mobile = isset($dict['customer_mobile'])?$dict['customer_mobile']. "\t":"-" ;
- $customer_id_no = isset($dict['customer_id_no'])?$dict['customer_id_no']. "\t":"-";
- $org_name = $dict['org_name'] . "\t";
- $outside_order_no = $dict['outside_order_no']==""?"-":$dict['outside_order_no']."\t";
- $parent_order_id = $dict['parent_order_id'] . "\t";
- $bus_order_id = isset($dict['bus_order_id']) ? $dict['bus_order_id'] . "\t" : "-";
- $order_status=$dict['order_status'];
- $strline = $line . ",".$bus_type."," . $bus_order_id . "," . $send_bus_no . "," . $send_driver_name . "," . $send_driver_mobile . "," . $start_station . "," . $end_station . "," . $create_time . "," . $run_date . ",". $bus_run_time . ",". $run_time . ",".$prod_name."," . $seat . "," . $order_count . "," . $order_price . "," . $GMV . "," . $customer_name . "," . $customer_mobile . "," . $customer_id_no . "," . $org_name . "," . $outside_order_no . "," . $parent_order_id . "," . $order_status;
- $strline=str_replace(array("\n","\r"),array("",""),$strline);
- $str.= $strline."\n";
- }
- $filename = date('Ymd') . '.csv';
- //设置文件名
- //echo $str;
- export_csv($filename, $str);
- //导出
-
- function export_csv($filename, $data) {
- header("Content-type:text/csv");
- header("Content-Disposition:attachment;filename=客人" . $filename);
- header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
- header('Expires:0');
- header('Pragma:public');
- $data = chr(0xEF) . chr(0xBB) . chr(0xBF) . $data;
- // $data = iconv("utf-8","gb2312",$data);
- writeLog('export success');
- echo $data;
- }
-
-
- exit();
|