Merge remote-tracking branch 'origin/feature/promote_quota' into feature/promote_quota

master
chenxiaojun 5 years ago
commit ff489f8a17

@ -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) {

Loading…
Cancel
Save