指标导出处理

master
sunke 5 years ago
parent 739eff3d00
commit ffd29e2662

@ -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_belong'] = $data[$key]['company_belong']?'外团':'内团';
$data[$key]['company_relation'] = $data[$key]['company_relation']?'只维护':'自主开发及维护'; $data[$key]['company_relation'] = $data[$key]['company_relation']?'只维护':'自主开发及维护';

@ -2058,42 +2058,66 @@ class DownloadController extends BaseController {
public function promotequotaDtlExcelInfo($id,$map) { public function promotequotaDtlExcelInfo($id,$map) {
$xlsName = "推广员详情"; $xlsName = "推广员详情";
$xlsCell = array( $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(); $records = M('user_play_info', 'tab_')->where($map)->order('create_time desc')->select();
foreach ($records as $key => $value) { $csvFileName = $xlsName.'.csv';
//订单隐藏算法 //设置好告诉浏览器要下载excel文件的headers
$orderLen = strlen($value['user_account']); header('Content-Description: File Transfer');
$strLen = 3; header('Content-Type: application/vnd.ms-excel');
$hideChar = ''; header('Content-Disposition: attachment; filename="'. $csvFileName .'"');
header('Expires: 0');
if ($orderLen <= 8) { $strLen = 2;} header('Cache-Control: must-revalidate');
for ($i = 0; $i < $orderLen - $strLen * 2; $i++) { header('Pragma: public');
$hideChar .= '*'; $fp = fopen('php://output', 'a');//打开output流
} mb_convert_variables('gb2312', 'UTF-8', $xlsCell);
fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中
$accessNum = '100000';//从数据库获取总量,假设是十万
$accessNum = count($records)?:0 ;
$records[$key]['user_account'] = substr($value['user_account'], 0, $strLen) . $hideChar . substr($value['user_account'], $orderLen - $strLen); $perSize = 5000;//每次查询的条数
} $pages = ceil($accessNum / $perSize);
$xlsData = []; for($i = 1; $i <= $pages; $i++) {
foreach ($records as $key1 => $value1) { $data = M('user_play_info','tab_')->where($map)->order('create_time desc')
if($value1['sdk_version'] == 1) { ->limit(($i-1)*$perSize ,$perSize)->select();
$value1['sdk_version'] = "安卓版"; foreach($data as $dataKey => $dataValue) {
} $orderLen = strlen($dataValue['user_account']);
if($value1['sdk_version'] == 2) { $strLen = 3;
$value1['sdk_version'] = "苹果版"; $hideChar = '';
}
$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) { public function promotequotaExcelInfo($tid,$map) {

Loading…
Cancel
Save