From 712010b2414b1f6f9d15496df549a785b9586307 Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Wed, 12 Feb 2020 16:15:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=91=98=E6=8C=87?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/DownloadController.class.php | 92 ++++++++++++------- 1 file changed, 58 insertions(+), 34 deletions(-) diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index 89897cf5b..33dad00f7 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 .= '*'; - } - - $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; + $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 = ''; + + 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) { From 2defa249e839e19c77a3653d1f655604f9115ba5 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Wed, 12 Feb 2020 17:59:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=B9=B3=E5=8F=B0>?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=AE=A1=E7=90=86>=E6=8E=A8=E5=B9=BF?= =?UTF-8?q?=E5=91=98=E6=8C=87=E6=A0=87--=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PromoteController.class.php | 4 +-- .../Home/Controller/QueryController.class.php | 4 +-- .../Home/View/default/Query/promoteQuota.html | 36 +++++++++++++++---- .../Home/View/default/Query/quotaDtl.html | 2 +- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index fcb203a58..e08f08cdb 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -232,7 +232,7 @@ class PromoteController extends BaseController $this->assign("rules", $rules); $this->assign("rules_count", count($rules)); - /* $redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]); + $redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]); $cacheKey = "pop:rule:set"; if (!$redis->sIsMember($cacheKey, get_pid())) { $currentTime = strtotime(date('Y-m-d')); @@ -245,7 +245,7 @@ class PromoteController extends BaseController ->select(); } else { $match_rules = []; - } */ + } $this->assign("match_rules_id", $match_rules ? json_encode(array_column($match_rules, 'id')) : 'null'); diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 0a2c369dd..d39edcb99 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1957,7 +1957,7 @@ class QueryController extends BaseController $map['sdk_version'] = $sdkVersion; } $gameIds = M('game', 'tab_')->where($map)->getField('id', true); - $servers = M('server', 'tab_')->field(['id', 'server_id', 'server_name'])->where(['game_id' => ['in', $gameIds]])->order('server_id asc')->select(); + $servers = M('server', 'tab_')->field(['id', 'server_id', 'server_name'])->where(['game_id' => ['in', $gameIds]])->group('server_id')->order('server_id asc')->select(); } $this->ajaxReturn([ 'status' => 1, @@ -2223,7 +2223,7 @@ class QueryController extends BaseController $sdkVersion = I('sdk_version', 0); $relationGameId = I('relation_game_id', 0); $serverId = I('server_id', 0); - $parentId = I('parent_id', 0); + $parentId = I('get.parent_id', 0); $promoteId = I('promote_id', 0); $levelBegin = I('level_begin', ''); $levelEnd = I('level_end', ''); diff --git a/Application/Home/View/default/Query/promoteQuota.html b/Application/Home/View/default/Query/promoteQuota.html index f98ada7c1..f4472d115 100644 --- a/Application/Home/View/default/Query/promoteQuota.html +++ b/Application/Home/View/default/Query/promoteQuota.html @@ -26,10 +26,10 @@ {$meta_title}