You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

128 lines
4.9 KiB

  1. <?php
  2. require_once './php_include/Config.php';
  3. require_once './php_include/class.db.inc';
  4. require_once './php_include/disney.inc';
  5. $disp_per_page = 10;
  6. //$return_flag = "\r";
  7. $return_flag = " ";
  8. if( !isset($_GET["curpage"]) || $_GET["curpage"] < 1 ) {
  9. $_GET["curpage"] = 1;
  10. }
  11. $url_param_array = array();
  12. $extra_sql_array = array();
  13. if( !isset($_GET["search_order_no"]) || mb_strlen($_GET["search_order_no"]) <= 0 ) {
  14. $_GET["search_order_no"] = "";
  15. } else {
  16. $extra_sql_array[] = ' order_serial_no like "%%'.$_GET["search_order_no"].'%%" ';
  17. $url_param_array[] = 'search_order_no='.$_GET["search_order_no"];
  18. }
  19. if( !isset($_GET["search_pay_no"]) || mb_strlen($_GET["search_pay_no"]) <= 0 ) {
  20. $_GET["search_pay_no"] = "";
  21. } else {
  22. $extra_sql_array[] = ' pay_no like "%%'.$_GET["search_pay_no"].'%%" ';
  23. $url_param_array[] = 'search_pay_no='.$_GET["search_pay_no"];
  24. }
  25. if( !isset($_GET["search_org_id"]) || mb_strlen($_GET["search_org_id"]) <= 0 || $_GET["search_org_id"] == "" || $_GET["search_org_id"] < 1) {
  26. $_GET["search_org_id"] = 0;
  27. } else {
  28. $extra_sql_array[] = ' org_id = '.$_GET["search_org_id"].' ';
  29. $url_param_array[] = 'search_org_id='.$_GET["search_org_id"];
  30. }
  31. if( !isset($_GET["search_create_date"]) || mb_strlen($_GET["search_create_date"]) <= 0 ) {
  32. $_GET["search_create_date"] = "";
  33. } else {
  34. $extra_sql_array[] = ' create_time like "%%'.$_GET["search_create_date"].'%%" ';
  35. $url_param_array[] = 'search_create_date='.$_GET["search_create_date"];
  36. }
  37. if( !isset($_GET["search_cus_name"]) || mb_strlen($_GET["search_cus_name"]) <= 0 ) {
  38. $_GET["search_cus_name"] = "";
  39. } else {
  40. $extra_sql_array[] = ' cus_name like "%%'.$_GET["search_cus_name"].'%%" ';
  41. $url_param_array[] = 'cus_name='.$_GET["cus_name"];
  42. }
  43. if( !isset($_GET["search_cus_mobile"]) || mb_strlen($_GET["search_cus_mobile"]) <= 0 ) {
  44. $_GET["search_cus_mobile"] = "";
  45. } else {
  46. $extra_sql_array[] = ' cus_mobile like "%%'.$_GET["search_cus_mobile"].'%%" ';
  47. $url_param_array[] = 'cus_mobile='.$_GET["cus_mobile"];
  48. }
  49. $url_param = count($url_param_array) > 0 ? implode("&",$url_param_array) : 'guid=ON';
  50. $limit = " ORDER BY create_time DESC ";
  51. //DB
  52. $objDbh = new Db;
  53. $objDbh->setAccount(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB);
  54. $objDisney = new DbDisney($objDbh);
  55. $extra_sql = count($extra_sql_array) > 0 ? implode( " AND ", $extra_sql_array ): false;
  56. $order_array = $objDisney->getActiceOrderCommonArray( $extra_sql, $limit );
  57. $all_count = $objDisney->getActiveOrderCommonCount( $extra_sql );
  58. $org_array = $objDisney->getBaseOrgArray();
  59. $org_temp_array = array();
  60. foreach( $org_array as $org_info ) {
  61. $org_temp_array[$org_info["org_id"]] = $org_info;
  62. }
  63. $org_array = $org_temp_array;
  64. $max_page = ceil($all_count/$disp_per_page);
  65. $url_base = $page_name."?".$url_param;
  66. $str = "订单编号,订单内容,订单金额,订单源,下单时间,支付信息,用户信息,备注" . "\n";
  67. foreach( $order_array as $order_info ) {
  68. $str .= $order_info["order_serial_no"]."\t,".$order_info["prod_name"].$return_flag;
  69. $order_date = $order_info["start_day"];
  70. if( mb_strlen($order_info["start_time"]) > 0 ) {
  71. $order_date .= " ".$order_info["start_time"];
  72. }
  73. if( $order_info["prod_id"] == 1 || $order_info["prod_id"] == 2 || $order_info["prod_id"] == 18 || $order_info["prod_id"] == 16 ) {
  74. $order_date .= "-".$order_info["end_day"]." ".$order_info["end_time"];
  75. if( mb_strlen($order_info["start_time2"]) > 0 ) {
  76. $order_date .= $return_flag.$order_info["start_day2"]." ".$order_info["start_time2"]."-".$order_info["end_day2"]." ".$order_info["end_time2"];
  77. }
  78. }
  79. $str .= $order_date.",";
  80. $str .= $order_info["order_price"].",";
  81. if( isset($org_array[$order_info["org_id"]]) ) {
  82. $str .= $org_array[$order_info["org_id"]]["org_name"].',';
  83. } else {
  84. $str .= '-,';
  85. }
  86. $str .= $order_info["create_time"].",";
  87. if( $order_info['is_payed'] == 1 ) {
  88. $str .= $_ary_pay_type[$order_info['pay_type']].$return_flag.'支付号:'.$order_info["pay_no"] . ',';
  89. } else if( $order_info['order_user_id'] > 0 ){
  90. $str .= '酒店代收现金,';
  91. } else {
  92. $str .= '未支付,';
  93. }
  94. $str .= $order_info["cus_name"].$return_flag.$order_info["cus_mobile"].$return_flag.$order_info["cus_iden"];
  95. $order_comment = str_replace(",",",",$order_info["comment"]);
  96. $str .= ",\"".$order_comment."\"";
  97. $str .= "\n";
  98. }
  99. $filename = date('Ymd') . '.csv';
  100. //设置文件名
  101. //echo $str;
  102. export_csv($filename, $str);
  103. //导出
  104. function export_csv($filename, $data) {
  105. header("Content-type:text/csv");
  106. header("Content-Disposition:attachment;filename=order_list" . $filename);
  107. header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
  108. header('Expires:0');
  109. header('Pragma:public');
  110. $data = chr(0xEF) . chr(0xBB) . chr(0xBF) . $data;
  111. // $data = iconv("utf-8","gb2312",$data);
  112. echo $data;
  113. }
  114. ?>