From ffd29e26626a871598e1d40d742e94de238ec3fd Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Wed, 12 Feb 2020 16:21:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=87=E6=A0=87=E5=AF=BC=E5=87=BA=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/QueryController.class.php | 2 +- .../Controller/DownloadController.class.php | 90 ++++++++++++------- 2 files changed, 58 insertions(+), 34 deletions(-) diff --git a/Application/Admin/Controller/QueryController.class.php b/Application/Admin/Controller/QueryController.class.php index f8c5ee29a..c95e645ab 100644 --- a/Application/Admin/Controller/QueryController.class.php +++ b/Application/Admin/Controller/QueryController.class.php @@ -1649,7 +1649,7 @@ class QueryController extends ThinkController } } - $data[$key]['highquality'] = number_format(($value['pay_amount']-$data[$key]['upstream']-$data[$key]['downstream']) * (1-0.0672),2,'.',''); + $data[$key]['highquality'] = number_format(($value['pay_amount'] - $initNum - $data[$key]['upstream']-$data[$key]['downstream']) * (1-0.0672),2,'.',''); $data[$key]['company_belong'] = $data[$key]['company_belong']?'外团':'内团'; $data[$key]['company_relation'] = $data[$key]['company_relation']?'只维护':'自主开发及维护'; diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index 4ad6dfd11..16adda12f 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -2058,42 +2058,66 @@ class DownloadController extends BaseController { public function promotequotaDtlExcelInfo($id,$map) { $xlsName = "推广员详情"; $xlsCell = array( - array('user_account','玩家账号'), - array('promote_account','推广账号'), - array('game_name','游戏名称'), - array('sdk_version','平台'), - array('server_name','游戏区服'), - array('role_name','角色名'), - array('role_level','等级'), - array('create_time','创建时间'), - ); + '玩家账号', + '推广账号', + '游戏名称', + '平台', + '游戏区服', + '角色名', + '等级', + '创建时间', + ); $records = M('user_play_info', 'tab_')->where($map)->order('create_time desc')->select(); - foreach ($records as $key => $value) { - //订单隐藏算法 - $orderLen = strlen($value['user_account']); - $strLen = 3; - $hideChar = ''; - - if ($orderLen <= 8) { $strLen = 2;} - for ($i = 0; $i < $orderLen - $strLen * 2; $i++) { - $hideChar .= '*'; - } + $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 = '100000';//从数据库获取总量,假设是十万 + $accessNum = count($records)?:0 ; + + $perSize = 5000;//每次查询的条数 + $pages = ceil($accessNum / $perSize); + for($i = 1; $i <= $pages; $i++) { + $data = M('user_play_info','tab_')->where($map)->order('create_time desc') + ->limit(($i-1)*$perSize ,$perSize)->select(); + foreach($data as $dataKey => $dataValue) { + $orderLen = strlen($dataValue['user_account']); + $strLen = 3; + $hideChar = ''; - $records[$key]['user_account'] = substr($value['user_account'], 0, $strLen) . $hideChar . substr($value['user_account'], $orderLen - $strLen); - } - $xlsData = []; - foreach ($records as $key1 => $value1) { - if($value1['sdk_version'] == 1) { - $value1['sdk_version'] = "安卓版"; - } - if($value1['sdk_version'] == 2) { - $value1['sdk_version'] = "苹果版"; - } - $xlsData[] = $value1; + if ($orderLen <= 8) { $strLen = 2;} + for ($i = 0; $i < $orderLen - $strLen * 2; $i++) { + $hideChar .= '*'; + } + $csvData['user_account'] = substr($dataValue['user_account'], 0, $strLen) . $hideChar . substr($dataValue['user_account'], $orderLen - $strLen); + $csvData['promote_account'] = $dataValue['promote_account']; + $csvData['game_name'] = $dataValue['game_name']; + if($dataValue['sdk_version'] == 1) { + $csvData['sdk_version'] = "安卓版"; + } + if($dataValue['sdk_version'] == 2) { + $csvData['sdk_version'] = "苹果版"; + } + $csvData['server_name'] = $dataValue['server_name']; + $csvData['role_name'] = $dataValue['role_name']; + $csvData['role_level'] = $dataValue['role_level']; + $csvData['create_time'] = date("Y-m-d H:i:s",$dataValue['create_time']); + mb_convert_variables('GBK', 'UTF-8', $csvData); + fputcsv($fp, $csvData); + } + unset($csvData); + ob_flush(); + flush(); } - $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); - - + fclose($fp); + $this->backSuccessExport($id); } public function promotequotaExcelInfo($tid,$map) {