diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index 33e73f876..c5e82e793 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -2376,7 +2376,6 @@ class DownloadController extends BaseController { '绑定币分成比例', '订单状态', ); - $xlsCell1 = $xlsCell; $spendModel = M('spend', 'tab_'); $withdrawId = $map['withdraw_id']; $withdraw = M('withdraw', 'tab_')->field('promote_id,status')->where(array('id' => $withdrawId))->find(); @@ -2451,6 +2450,7 @@ class DownloadController extends BaseController { } fclose($fp); $this->backSuccessExport($id); + } public function withdrawRecordExcelInfo($id,$map) { @@ -2932,28 +2932,52 @@ class DownloadController extends BaseController { public function rechargeExcelInfo($id,$map) { $xlsName = "订单查询"; $xlsCell = array( - array('user_account','玩家账号'), - array('order_number','游戏订单'), - array('pay_amount','订单金额'), - array('pay_way','支付方式'), - array('game_name','游戏名称'), - array('server_name','区服'), - array('game_player_name','角色名'), - array('p_p_proinfo','部门长'), - array('p_proinfo','组长'), - array('proinfo','推广员'), - array('pay_time','付款时间'), + '玩家账号', + '游戏订单', + '订单金额', + '支付方式', + '游戏名称', + '区服', + '角色名', + '部门长', + '组长', + '推广员', + '付款时间', ); $model = M('spend','tab_'); - $data = $model - ->field('tab_spend.*,tab_promote.account as pro_account,tab_promote.real_name as pro_real_name,tab_promote.chain as chain') + $data1 = $model + ->field('tab_spend.id') ->join('tab_game on tab_spend.game_id = tab_game.id') ->join('left join tab_promote on tab_spend.promote_id = tab_promote.id') ->where($map) ->order('tab_spend.id desc') ->select(); - $xlsData = []; - foreach ($data as $key1 => $value1) { + + $csvFileName = $xlsName.'.csv'; + //设置好告诉浏览器要下载excel文件的headers + header('Content-Description: File Transfer'); + header('Content-Type: application/vnd.ms-excel'); + header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + $fp = fopen('php://output', 'a');//打开output流 + mb_convert_variables('gb2312', 'UTF-8', $xlsCell); + fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 + $accessNum = count($data1)?:0 ; + $perSize = 5000;//每次查询的条数 + $pages = ceil($accessNum / $perSize); + for($i = 1; $i <= $pages; $i++) { + $model = M('spend','tab_'); + $data = $model + ->field('tab_spend.*,tab_promote.account as pro_account,tab_promote.real_name as pro_real_name,tab_promote.chain as chain') + ->join('tab_game on tab_spend.game_id = tab_game.id') + ->join('left join tab_promote on tab_spend.promote_id = tab_promote.id') + ->where($map) + ->limit(($i-1)*$perSize ,$perSize) + ->order('tab_spend.id desc') + ->select(); + foreach ($data as $key1 => $value1) { $value1['pay_way'] = $this->payWay[$value1['pay_way']]; $value1['pay_time'] = date('Y-m-d H:i:s',$value1['pay_time']); $value1['p_p_proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')'; @@ -2982,9 +3006,29 @@ class DownloadController extends BaseController { } - $xlsData[] = $value1; + $csvData["user_account"] = $value1["user_account"]; + $csvData["order_number"] = $value1["order_number"]; + $csvData["pay_amount"] = $value1["pay_amount"]; + $csvData["pay_way"] = $value1["pay_way"]; + $csvData["game_name"] = $value1["game_name"]; + $csvData["server_name"] = $value1["server_name"]; + $csvData["game_player_name"] = $value1["game_player_name"]; + $csvData["p_p_proinfo"] = $value1["p_p_proinfo"]; + $csvData["p_proinfo"] = $value1["p_proinfo"]; + $csvData["proinfo"] = $value1["proinfo"]; + $csvData["pay_time"] = $value1["pay_time"]; + $xlsData[] = $csvData; + } + foreach($xlsData as $value) { + mb_convert_variables('GBK', 'UTF-8', $value); + fputcsv($fp, $value); + } + unset($xlsData); + ob_flush(); + flush(); } - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + fclose($fp); + $this->backSuccessExport($id); } public function backSuccessExport($id) { //导出成功后