25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

110 lines
5.5 KiB

  1. <?php
  2. /*
  3. Author:fuhc
  4. Compeny:导出次日上车乘客信息 将备注转为一条数据添加进去
  5. */
  6. require_once '../Common/Mysql.php';
  7. if (ALLOW_ORIGIN)
  8. header("Access-Control-Allow-Origin:*");
  9. set_time_limit(1200);
  10. $method = isset($_GET['method']) ? $_GET['method'] : "";
  11. $timelimit = isset($_GET['timelimit']) ? $_GET['timelimit'] : '出发时间';
  12. $starttime = isset($_GET['starttime']) ? $_GET['starttime'] : date("Y-m-d");
  13. $endtime = isset($_GET['endtime']) ? $_GET['endtime'] : date("Y-m-d");
  14. //$starttime = "2016-08-04";
  15. //$endtime = "2016-08-04";
  16. $ordersource = isset($_GET['ordersource']) ? (empty($_GET['ordersource']) ? -1 : $_GET['ordersource']) : -1;
  17. $orderstatus = isset($_GET['orderstatus']) ? (empty($_GET['orderstatus']) ? 0 : $_GET['orderstatus']) : 0;
  18. $moresearch = isset($_GET['moresearch']) ? $_GET['moresearch'] : '';
  19. //2016-07-15新增
  20. $start_area = isset($_GET['start_area']) ? $_GET['start_area'] : '';
  21. $end_area = isset($_GET['end_area']) ? $_GET['end_area'] : '';
  22. $line = isset($_GET['line']) ? $_GET['line'] : '';
  23. //2016-10-19新增
  24. $bus_type_param = isset($_GET['bus_type'])?$_GET['bus_type']:"0";
  25. $pdo = conn();
  26. //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)
  27. //$sql = "CALL SP_EXPORT_CUSTOMERINFO(1,'" . $timelimit . "','" . $starttime . "','" . $endtime . "'," . $ordersource . "," . $orderstatus . "," . $paystatus . ",'" . $billingstatus . "','" . $mealbounce . "','" . $refund . "','" . $moresearch . "','" . $export . "'," . $currentpage . "," . $pagesize . ",'" . $line . "','" . $start_area . "','" . $end_area . "')";
  28. $sql = "CALL SP_EXPORT_CUSTOMER('".$timelimit."','".$starttime."','".$endtime."','".$ordersource."','".$orderstatus."','".$moresearch."','".$line."','".$start_area."','".$end_area."');";
  29. writeLog('order_list2.php export-- sql== '.$sql);
  30. if($pdo){
  31. $result = $pdo -> query($sql);
  32. if($result){
  33. $data = array();
  34. $data = $result -> fetchAll(PDO::FETCH_ASSOC);
  35. }else{
  36. $data['code']="400";
  37. $data['info']="数据库错误";
  38. echo json_encode($data);exit();
  39. }
  40. }else{
  41. $data['code']="500";
  42. $data['info']="连接数据库错误";
  43. echo json_encode($data);exit();
  44. }
  45. $str = "线路名称,线路类型,车号,车牌号码,司机姓名,司机手机,上车站点,下车站点,预订日期,发班日期,发班时间,乘客预定时间,产品名称,座位等级,出行人数,分销价,GMV,游客姓名,联系方式,身份证号,渠道,渠道订单号,订单号,状态" . "\n";
  46. for ($i = 0; $i < count($data); $i++) {
  47. $dict = $data[$i];
  48. $send_bus_no = $dict["send_bus_no"] . "\t";
  49. // $bus_type = $dict["bus_type"] . "\t";
  50. $send_driver_name = $dict["send_driver_name"] . "\t";
  51. $disp_bus_type = array("255" => "直通巴士", "256" => "穿梭巴士","284" => "城际商务车");
  52. // $bus_type = isset($disp_bus_type[$dict["bus_type"]])?$disp_bus_type[$dict["bus_type"]]. "\t": "-";
  53. if($bus_type_param=="0"){
  54. $bus_type = isset($disp_bus_type[$dict["bus_type"]])?$disp_bus_type[$dict["bus_type"]]. "\t": "-";
  55. }else{
  56. if($bus_type_param!=$dict['bus_type']){
  57. continue;
  58. }
  59. $bus_type = isset($disp_bus_type[$bus_type_param])?$disp_bus_type[$bus_type_param]. "\t": "-";
  60. }
  61. $send_driver_mobile = $dict["send_driver_mobile"] . "\t";
  62. $line = $dict['line'] . "\t";
  63. $start_station = $dict['start_station'] . "\t";
  64. $end_station = $dict['end_station'] . "\t";
  65. $run_date = substr($dict['run_date'], 0, 10) . "\t";
  66. $bus_run_time = substr($dict['run_time'], 0, 10) . "\t";
  67. $run_time = substr($dict['run_time'], 0, 10) . "\t";
  68. $prod_name=$dict['prod_name']."\t";
  69. $create_time=$dict['create_time']."\t";
  70. $seat=$dict['seat']."\t";
  71. $order_count = $dict['order_count']."\t";
  72. $order_price=$dict['order_price']."\t";
  73. $GMV = isset($dict['gmv']) ? $dict['gmv'] . "\t" : "-";
  74. $customer_name = isset($dict['customer_name'])?$dict['customer_name']. "\t":"-" ;
  75. $customer_mobile = isset($dict['customer_mobile'])?$dict['customer_mobile']. "\t":"-" ;
  76. $customer_id_no = isset($dict['customer_id_no'])?$dict['customer_id_no']. "\t":"-";
  77. $org_name = $dict['org_name'] . "\t";
  78. $outside_order_no = $dict['outside_order_no']==""?"-":$dict['outside_order_no']."\t";
  79. $parent_order_id = $dict['parent_order_id'] . "\t";
  80. $bus_order_id = isset($dict['bus_order_id']) ? $dict['bus_order_id'] . "\t" : "-";
  81. $order_status=$dict['order_status'];
  82. $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;
  83. $strline=str_replace(array("\n","\r"),array("",""),$strline);
  84. $str.= $strline."\n";
  85. }
  86. $filename = date('Ymd') . '.csv';
  87. //设置文件名
  88. //echo $str;
  89. export_csv($filename, $str);
  90. //导出
  91. function export_csv($filename, $data) {
  92. header("Content-type:text/csv");
  93. header("Content-Disposition:attachment;filename=客人" . $filename);
  94. header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
  95. header('Expires:0');
  96. header('Pragma:public');
  97. $data = chr(0xEF) . chr(0xBB) . chr(0xBF) . $data;
  98. // $data = iconv("utf-8","gb2312",$data);
  99. writeLog('export success');
  100. echo $data;
  101. }
  102. exit();