|
|
|
@ -173,6 +173,118 @@ class DownloadController extends BaseController {
|
|
|
|
|
$this->assign('promoteNameArr',$promoteNameArr);
|
|
|
|
|
return $this->display();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* IOS详细下载数统计
|
|
|
|
|
* @author sunke
|
|
|
|
|
*/
|
|
|
|
|
public function iosdetail_data_export() {
|
|
|
|
|
$promote_id = $_REQUEST['promote_id'];
|
|
|
|
|
$belongs_president = $_REQUEST['belongs_president'];
|
|
|
|
|
$belongs_department = $_REQUEST['belongs_department'];
|
|
|
|
|
$belongs_group = $_REQUEST['belongs_group'];
|
|
|
|
|
$user_account = $_REQUEST['user_account'];
|
|
|
|
|
$type = $_REQUEST['type'];
|
|
|
|
|
$createTime = I('create_time', '');
|
|
|
|
|
if(!empty($_REQUEST['promote_id'])) {
|
|
|
|
|
$map['promote_id'] = $_REQUEST['promote_id'];
|
|
|
|
|
}
|
|
|
|
|
if(!empty($_REQUEST['belongs_president'])) {
|
|
|
|
|
$map['belongs_president'] = $_REQUEST['belongs_president'];
|
|
|
|
|
}
|
|
|
|
|
if(!empty($_REQUEST['belongs_department'])) {
|
|
|
|
|
$map['belongs_department'] = $_REQUEST['belongs_department'];
|
|
|
|
|
}
|
|
|
|
|
if(!empty($_REQUEST['belongs_group'])) {
|
|
|
|
|
$map['belongs_group'] = $_REQUEST['belongs_group'];
|
|
|
|
|
}
|
|
|
|
|
if($user_account) {
|
|
|
|
|
$user_id = M('user', 'tab_')->where(['account'=>$user_account])->getField('id');
|
|
|
|
|
$map['user_id'] = $user_id;
|
|
|
|
|
}
|
|
|
|
|
if($type) {
|
|
|
|
|
$map['type'] = $type;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if ($createTime != '') {
|
|
|
|
|
$createTimeRow = explode(' 至 ', $createTime);
|
|
|
|
|
$createTimeBegin = 0;
|
|
|
|
|
$createTimeEnd = 0;
|
|
|
|
|
if (count($createTimeRow) == 2) {
|
|
|
|
|
$createTimeBegin = strtotime($createTimeRow[0] . ' 00:00:00');
|
|
|
|
|
$createTimeEnd = strtotime($createTimeRow[1] . ' 23:59:59');
|
|
|
|
|
} else {
|
|
|
|
|
$createTimeBegin = strtotime($createTimeRow[0] . ' 00:00:00');
|
|
|
|
|
$createTimeEnd = strtotime($createTimeRow[0] . ' 23:59:59');
|
|
|
|
|
}
|
|
|
|
|
$map['create_time'] = ['between', [$createTimeBegin, $createTimeEnd]];
|
|
|
|
|
}
|
|
|
|
|
$conditions = json_encode($map,TRUE);
|
|
|
|
|
$addtime = time();
|
|
|
|
|
$data = [
|
|
|
|
|
'logid' => 'IOSdetail_'.time(),
|
|
|
|
|
'promote_id' => PID,
|
|
|
|
|
'type' => '/Home/Query/iosDownLoadDetail',
|
|
|
|
|
'dataname' => 'IOS玩家详情下载统计',
|
|
|
|
|
'status' => 0,
|
|
|
|
|
'addtime' => $addtime,
|
|
|
|
|
'begintime' => 0,
|
|
|
|
|
'content' => '',
|
|
|
|
|
'conditions' =>$conditions
|
|
|
|
|
];
|
|
|
|
|
$res = M('downloadlog','tab_')->add($data);
|
|
|
|
|
if (!$res) {
|
|
|
|
|
// $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res));
|
|
|
|
|
$this->error('添加下载失败');
|
|
|
|
|
}
|
|
|
|
|
$this->success('添加下载成功',U('listsIndex'));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* IOS下载数统计
|
|
|
|
|
* @author sunke
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function ios_data_export() {
|
|
|
|
|
$levelPromote = $this->getLevelPromote();
|
|
|
|
|
$queryPromote = $this->getQueryPromote($levelPromote);
|
|
|
|
|
$map = [];
|
|
|
|
|
$map['chain'] = ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%'];
|
|
|
|
|
$createTime = I('create_time', '');
|
|
|
|
|
if ($createTime != '') {
|
|
|
|
|
$createTimeRow = explode(' 至 ', $createTime);
|
|
|
|
|
$createTimeBegin = 0;
|
|
|
|
|
$createTimeEnd = 0;
|
|
|
|
|
if (count($createTimeRow) == 2) {
|
|
|
|
|
$createTimeBegin = strtotime($createTimeRow[0] . ' 00:00:00');
|
|
|
|
|
$createTimeEnd = strtotime($createTimeRow[1] . ' 23:59:59');
|
|
|
|
|
} else {
|
|
|
|
|
$createTimeBegin = strtotime($createTimeRow[0] . ' 00:00:00');
|
|
|
|
|
$createTimeEnd = strtotime($createTimeRow[0] . ' 23:59:59');
|
|
|
|
|
}
|
|
|
|
|
$map['create_time'] = ['between', [$createTimeBegin, $createTimeEnd]];
|
|
|
|
|
}
|
|
|
|
|
$map['pid'] = PID;
|
|
|
|
|
$conditions = json_encode($map,TRUE);
|
|
|
|
|
$addtime = time();
|
|
|
|
|
$data = [
|
|
|
|
|
'logid' => 'IOS_'.time(),
|
|
|
|
|
'promote_id' => PID,
|
|
|
|
|
'type' => '/Home/Query/iosDownLoadData',
|
|
|
|
|
'dataname' => 'IOS下载统计',
|
|
|
|
|
'status' => 0,
|
|
|
|
|
'addtime' => $addtime,
|
|
|
|
|
'begintime' => 0,
|
|
|
|
|
'content' => '',
|
|
|
|
|
'conditions' =>$conditions
|
|
|
|
|
];
|
|
|
|
|
$res = M('downloadlog','tab_')->add($data);
|
|
|
|
|
if (!$res) {
|
|
|
|
|
// $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res));
|
|
|
|
|
$this->error('添加下载失败');
|
|
|
|
|
}
|
|
|
|
|
$this->success('添加下载成功',U('listsIndex'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 每日概况
|
|
|
|
@ -2103,12 +2215,251 @@ class DownloadController extends BaseController {
|
|
|
|
|
case "推广员操作日志":
|
|
|
|
|
$this->promotelogsExcelInfo($id,$map);
|
|
|
|
|
break;
|
|
|
|
|
case "IOS下载统计":
|
|
|
|
|
$this->iosDataExcelInfo($id,$map);
|
|
|
|
|
break;
|
|
|
|
|
case "IOS玩家详情下载统计":
|
|
|
|
|
$this->iosDetailExcelInfo($id,$map);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function iosDetailExcelInfo($id,$map) {
|
|
|
|
|
$xlsName ="IOS详情下载数统计";
|
|
|
|
|
$xlsCell = array(
|
|
|
|
|
'玩家账号',
|
|
|
|
|
'类型',
|
|
|
|
|
'时间',
|
|
|
|
|
'所属推广员',
|
|
|
|
|
'所属会长',
|
|
|
|
|
'所属部门长',
|
|
|
|
|
'所属组长'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!empty($map['user_id'])) {
|
|
|
|
|
$map1['user_id'] = $map['user_id'];
|
|
|
|
|
}
|
|
|
|
|
if (!empty($map['type'])) {
|
|
|
|
|
$map1['type'] = $map['type'];
|
|
|
|
|
}
|
|
|
|
|
if (!empty($map['create_time'])) {
|
|
|
|
|
$map1['create_time'] = $map['create_time'];
|
|
|
|
|
$tfMap['create_time'] = $map['craete_time'];
|
|
|
|
|
$superMap['create_time'] = $map['craete_time'];
|
|
|
|
|
$companyMap['create_time'] = $map['craete_time'];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$belongs_president = '';
|
|
|
|
|
$belongs_department = '';
|
|
|
|
|
$belongs_group = '';
|
|
|
|
|
if (!empty($map['belongs_president'])) {
|
|
|
|
|
$belongs_president = $map['belongs_president'];
|
|
|
|
|
}
|
|
|
|
|
if (!empty($map['belongs_department'])) {
|
|
|
|
|
$belongs_department = $map['belongs_department'];
|
|
|
|
|
}
|
|
|
|
|
if (!empty($map['belongs_group'])) {
|
|
|
|
|
$belongs_group = $map['belongs_group'];
|
|
|
|
|
}
|
|
|
|
|
if (!empty($map['promote_id'])) {
|
|
|
|
|
$promote_id = $map['promote_id'];
|
|
|
|
|
}
|
|
|
|
|
$rs = M('package_download_log', 'tab_')->field('id,game_id,user_id,type,create_time')->where($map1)->select();
|
|
|
|
|
$tfMap['promote_id'] = $promote_id;
|
|
|
|
|
$tfMap['type'] = 2;
|
|
|
|
|
$TFCounts = M('package_download_log', 'tab_')->where($tfMap)->count();
|
|
|
|
|
|
|
|
|
|
$superMap['promote_id'] = $promote_id;
|
|
|
|
|
$superMap['type'] = 3;
|
|
|
|
|
$superCounts = M('package_download_log', 'tab_')->where($superMap)->count();
|
|
|
|
|
|
|
|
|
|
$companyMap['promote_id'] = $promote_id;
|
|
|
|
|
$companyMap['type'] = 1;
|
|
|
|
|
$companyCounts = M('package_download_log', 'tab_')->where($companyMap)->count();
|
|
|
|
|
$csvFileName = $xlsName.'.csv';
|
|
|
|
|
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($rs)?:0 ;
|
|
|
|
|
$perSize = 5000;//每次查询的条数
|
|
|
|
|
$pages = ceil($accessNum / $perSize);
|
|
|
|
|
for($i = 1; $i <= $pages; $i++) {
|
|
|
|
|
$data = M('package_download_log', 'tab_')->field('id,game_id,user_id,type,create_time')->where($map1)
|
|
|
|
|
->limit(($i-1)*$perSize ,$perSize)->select();
|
|
|
|
|
foreach($data as $key => $value) {
|
|
|
|
|
$user_id = $value['user_id'];
|
|
|
|
|
$usersAccount = M('user', 'tab_')->where(['id' => $user_id])->getField('account');
|
|
|
|
|
$csvData['account'] = $usersAccount;
|
|
|
|
|
if ($value['type'] == 1) {
|
|
|
|
|
$csvData['typename'] = "企业签下载";
|
|
|
|
|
}
|
|
|
|
|
if($value['type'] == 2) {
|
|
|
|
|
$csvData['typename'] = "TF下载";
|
|
|
|
|
}
|
|
|
|
|
if($value['type'] == 3) {
|
|
|
|
|
$csvData['typename'] = "超级签下载";
|
|
|
|
|
}
|
|
|
|
|
$csvData['create_time'] = date('Y-m-d H:i:s', $package['crate_time']);
|
|
|
|
|
$promoteInfo = M('promote', 'tab_')->field('account')->where(['id'=>$promote_id])->find();
|
|
|
|
|
$csvData['promote_account'] = $promoteInfo['account'];
|
|
|
|
|
$csvData['belongs_president'] = $belongs_president;
|
|
|
|
|
$csvData['belongs_department'] = $belongs_department;
|
|
|
|
|
$csvData['belongs_group'] = $belongs_group;
|
|
|
|
|
|
|
|
|
|
mb_convert_variables('GBK', 'UTF-8', $csvData);
|
|
|
|
|
fputcsv($fp, $csvData);
|
|
|
|
|
$xlsData[] = $csvData;
|
|
|
|
|
}
|
|
|
|
|
unset($xlsData);
|
|
|
|
|
ob_flush();
|
|
|
|
|
flush();
|
|
|
|
|
}
|
|
|
|
|
$allData['account'] = '汇总';
|
|
|
|
|
$allData['typename'] = "TF下载次数:".$TFCounts;
|
|
|
|
|
$allData['create_time'] = "超级签下载次数:".$superCounts;
|
|
|
|
|
$allData['promote_account'] = "企业签下载次数:".$companyCounts;
|
|
|
|
|
mb_convert_variables('GBK', 'UTF-8', $allData);
|
|
|
|
|
fputcsv($fp, $allData);
|
|
|
|
|
$xlsData[] = $allData;
|
|
|
|
|
fclose($fp);
|
|
|
|
|
$this->backSuccessExport($id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function iosDataExcelInfo($tid,$map) {
|
|
|
|
|
$xlsName ="IOS下载数统计";
|
|
|
|
|
$xlsCell = array(
|
|
|
|
|
'推广员账号',
|
|
|
|
|
'玩家人数',
|
|
|
|
|
'TF下载次数',
|
|
|
|
|
'超级签下载次数',
|
|
|
|
|
'企业签下载次数',
|
|
|
|
|
'所属会长',
|
|
|
|
|
'所属部门长',
|
|
|
|
|
'所属组长'
|
|
|
|
|
);
|
|
|
|
|
$pid = $map['pid'];
|
|
|
|
|
unset($map['pid']);
|
|
|
|
|
$map1['chain'] = $map['chain'];
|
|
|
|
|
if (!empty($map['create_time'])) {
|
|
|
|
|
$map2['create_time'] = $map['create_time'];
|
|
|
|
|
$tfMap['create_time'] = $map['create_time'];
|
|
|
|
|
$companyMap['create_time'] = $map['create_time'];
|
|
|
|
|
$superMap['create_time'] = $map['create_time'];
|
|
|
|
|
}
|
|
|
|
|
$rs = M('promote', 'tab_')->field(['id'])->where($map1)->select();
|
|
|
|
|
$allids = array_column($rs, 'id');
|
|
|
|
|
$allUserMap['promote_id'] = ['in', $allids];
|
|
|
|
|
$allTFMap['promote_id'] = ['in', $allids];
|
|
|
|
|
$allTFMap['type'] = 2;
|
|
|
|
|
$allSuperMap['promote_id'] = ['in', $allids];
|
|
|
|
|
$allSuperMap['type'] = 3;
|
|
|
|
|
$companyMap['promote_id'] = ['in', $allids];
|
|
|
|
|
$companyMap['type'] = 1;
|
|
|
|
|
$allUsersCounts = M('user', 'tab_')->where($allUserMap)->count();
|
|
|
|
|
$allTFCounts = M('package_download_log', 'tab_')->where($allTFMap)->count();
|
|
|
|
|
$allSuperCounts = M('package_download_log', 'tab_')->where($allSuperMap)->count();
|
|
|
|
|
$allCompanyCounts = M('package_download_log', 'tab_')->where($companyMap)->count();
|
|
|
|
|
$csvFileName = $xlsName.'.csv';
|
|
|
|
|
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($rs)?:0 ;
|
|
|
|
|
$perSize = 5000;//每次查询的条数
|
|
|
|
|
$pages = ceil($accessNum / $perSize);
|
|
|
|
|
for($i = 1; $i <= $pages; $i++) {
|
|
|
|
|
$data = M('promote', 'tab_')->field(['id'])->where($map1)
|
|
|
|
|
->limit(($i-1)*$perSize ,$perSize)->select();
|
|
|
|
|
$ids = array_column($data, 'id');
|
|
|
|
|
foreach($ids as $key => $id) {
|
|
|
|
|
$promote1 = M('promote', 'tab_')->field('account, level, parent_id, chain')->where(['id' => $id])->select();
|
|
|
|
|
$promote = $promote1[0];
|
|
|
|
|
$chain = $promote['chain'];
|
|
|
|
|
//$csvData['promote_id'] = $id;
|
|
|
|
|
$csvData['account'] = $promote['account'];
|
|
|
|
|
$tfMap['promote_id'] = $id;
|
|
|
|
|
$tfMap['type'] = 2;
|
|
|
|
|
$companyMap['promote_id'] = $id;
|
|
|
|
|
$companyMap['type'] = 1;
|
|
|
|
|
$superMap['promote_id'] = $id;
|
|
|
|
|
$superMap['type'] = 3;
|
|
|
|
|
$tfCounts = M('package_download_log', 'tab_')->where($tfMap)->count(); //TF下载量
|
|
|
|
|
$companyCounts = M('package_download_log', 'tab_')->where($companyMap)->count(); //企业签下载量
|
|
|
|
|
$superCounts = M('package_download_log', 'tab_')->where($superMap)->count(); //超级签下载量
|
|
|
|
|
$usersCounts = M('user', 'tab_')->where(['promote_id' => $id])->count();
|
|
|
|
|
$csvData['userscounts'] = intval($usersCounts);
|
|
|
|
|
$csvData['tfcounts'] = intval($tfCounts);
|
|
|
|
|
$csvData['supercounts'] = intval($superCounts);
|
|
|
|
|
$csvData['companycounts'] = intval($companyCounts);
|
|
|
|
|
|
|
|
|
|
if($promote['level'] == 1) {
|
|
|
|
|
$csvData['belongs_president'] = $promote['account'];
|
|
|
|
|
$csvData['belongs_department'] = "无所属部门长";
|
|
|
|
|
$csvData['belongs_group'] = "无所属组长";
|
|
|
|
|
}
|
|
|
|
|
if ($promote['level'] == 2) {
|
|
|
|
|
$parentPromote = M('promote', 'tab_')->field('account')->where(['id'=>$promote['parent_id']])->select();
|
|
|
|
|
$csvData['belongs_president'] = $parentPromote['account'];
|
|
|
|
|
$csvData['belongs_department'] = $promote['account'];
|
|
|
|
|
$csvData['belongs_group'] = "无所属组长";
|
|
|
|
|
}
|
|
|
|
|
if ($promote['level'] == 3) {
|
|
|
|
|
$chainArr = explode('/', $chain);
|
|
|
|
|
$presidentAccount = M('promote', 'tab_')->where(['id' => $chainArr[1]])->getField('account');
|
|
|
|
|
$departmentAccount = M('promote', 'tab_')->where(['id' => $chainArr[2]])->getField('account');
|
|
|
|
|
$csvData['belongs_president'] = $presidentAccount;
|
|
|
|
|
$csvData['belongs_department'] = $departmentAccount;
|
|
|
|
|
$csvData['belongs_group'] = $promote['account'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($promote['level'] == 4) {
|
|
|
|
|
$chainArr = explode('/', $chain);
|
|
|
|
|
$presidentAccount = M('promote', 'tab_')->where(['id' => $chainArr[1]])->getField('account');
|
|
|
|
|
$departmentAccount = M('promote', 'tab_')->where(['id' => $chainArr[2]])->getField('account');
|
|
|
|
|
$groupAccount = M('promote', 'tab_')->where(['id' => $chainArr[3]])->getField('account');
|
|
|
|
|
$csvData['belongs_president'] = $presidentAccount;
|
|
|
|
|
$csvData['belongs_department'] = $departmentAccount;
|
|
|
|
|
$csvData['belongs_group'] = $groupAccount;
|
|
|
|
|
}
|
|
|
|
|
mb_convert_variables('GBK', 'UTF-8', $csvData);
|
|
|
|
|
fputcsv($fp, $csvData);
|
|
|
|
|
$xlsData[] = $csvData;
|
|
|
|
|
}
|
|
|
|
|
unset($xlsData);
|
|
|
|
|
ob_flush();
|
|
|
|
|
flush();
|
|
|
|
|
}
|
|
|
|
|
$allData['account'] = '汇总';
|
|
|
|
|
$allData['userscounts'] = $allUsersCounts;
|
|
|
|
|
$allData['tfcounts'] = $allTFCounts;
|
|
|
|
|
$allData['supercounts'] = $allSuperCounts;
|
|
|
|
|
$allData['companycounts'] = $allCompanyCounts;
|
|
|
|
|
|
|
|
|
|
$allData['belongs_president'] = '--';
|
|
|
|
|
$allData['belongs_department'] = '--';
|
|
|
|
|
$allData['belongs_group'] = '--';
|
|
|
|
|
mb_convert_variables('GBK', 'UTF-8', $allData);
|
|
|
|
|
fputcsv($fp, $allData);
|
|
|
|
|
$xlsData[] = $allData;
|
|
|
|
|
fclose($fp);
|
|
|
|
|
$this->backSuccessExport($tid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function promotelogsExcelInfo($id,$map) {
|
|
|
|
|
$xlsName = "推广员操作日志";
|
|
|
|
|
$xlsCell = array(
|
|
|
|
|