From ead4a8598ee734e60e87eaea9b0b6ef7b69a98e0 Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Fri, 13 Mar 2020 09:24:13 +0800 Subject: [PATCH 1/3] upt --- .../Admin/Controller/AjaxController.class.php | 7 + .../Controller/ExportController.class.php | 139 ++++++++ .../Controller/StatisticsController.class.php | 161 +++++++++ .../Admin/Model/PromoteModel.class.php | 12 +- .../Admin/View/Statistics/packdownload.html | 247 ++++++++++++++ .../View/Statistics/packuserdownload.html | 319 ++++++++++++++++++ 6 files changed, 884 insertions(+), 1 deletion(-) create mode 100644 Application/Admin/View/Statistics/packdownload.html create mode 100644 Application/Admin/View/Statistics/packuserdownload.html diff --git a/Application/Admin/Controller/AjaxController.class.php b/Application/Admin/Controller/AjaxController.class.php index 61fbd4292..c438a2f3f 100644 --- a/Application/Admin/Controller/AjaxController.class.php +++ b/Application/Admin/Controller/AjaxController.class.php @@ -580,4 +580,11 @@ class AjaxController extends ThinkController{ $this->ajaxReturn(['code'=>1]); } + public function getPromoteChildren($pid) + { + $info = M('promote', 'tab_')->where(['id'=>$pid])->find(); + if (empty($info)) return $this->ajaxReturn(['code'=>1, 'data'=>[]]); + $result = M('promote', 'tab_')->field("id,account,nickname")->where(['parent_id'=>$pid])->select(); + $this->ajaxReturn(['code'=>1, 'data'=>$result]); + } } \ No newline at end of file diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index b641c30cf..6822f0519 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -3,6 +3,7 @@ namespace Admin\Controller; use Think\Controller; use GuzzleHttp\Client; +use Admin\Model\PromoteModel; class ExportController extends Controller { @@ -8477,4 +8478,142 @@ class ExportController extends Controller addOperationLog(['op_type'=>3,'key'=>getNowDate(),'url'=>U($url,$GetData),'menu'=>$menu]); } + public function exportPackDownload($pid=0, $level=PromoteModel::LEVEL_PRESIDENT) + { + $xlsName = 'IOS下载统计报表'; + + $map = []; + $map['_string'] = " 1=1 "; + if ($pid) { + $info = M('promote', 'tab_')->where(['id'=>$pid])->find(); + if (empty($info)) return $this->error('未找到该用户'); + $level = $map['p.level'] = $info['level'] + 1; + $map['p.parent_id'] = $pid; + } else { + $map['p.level'] = $level; + } + + $typeArr = ['未知', '企业签下载', 'TF下载', '超级签下载']; + if (I('promote_id')) { + $map['p.id'] = I('promote_id'); + } + + $pdlMap = ""; + if ($startTime = I('create_time_start')) { + $startTime = strtotime($startTime); + $pdlMap .= " and pdl.create_time >={$startTime}"; + } + + if ($endTime = I('create_time_start')) { + $endTime += strtotime($endTime) + 86400; + $pdlMap .= " and pdl.create_time < {$endTime}"; + } + + if ($info['level'] == PromoteModel::LEVEL_GROUP_LEADER) { + $xlsData = M('promote', 'tab_')->alias('p') + ->field('p.id, p.level, p.account, count(pdl.id) as lowerCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') + ->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left') + ->where($map) + ->group('p.id') + ->select(); + } else { + $xlsData = M('promote', 'tab_')->alias('p') + ->field('p.id, p.level, p.account, count(p2.id) as lowerCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') + ->join("tab_promote p2 on p2.chain like CONCAT(p.chain, p.id, '/%')", 'left') + ->join("tab_package_download_log pdl on pdl.promote_id = p2.id $pdlMap", 'left') + ->where($map) + ->group('p.id') + ->select(); + } + $xlsCell = array( + array('account', PromoteModel::$levelArr[$level]."账号"), + array('lowercount', PromoteModel::$levelArr[$level+1]."数量"), + array('tfcount', 'TF下载数'), + array('supersigncount', "超级签下载数"), + array('signcount', "企业签下载数"), + ); + + $this->exportAddOperationLog('Statistics/packDownload','统计-IOS下载统计-导出'); + $this->exportExcel($xlsName, $xlsCell, $xlsData); + } + + public function exportUserPackDownload() + { + $xlsName = 'IOS下载统计详细报表'; + + $typeArr = ['未知', '企业签下载', 'TF下载', '超级签下载']; + $map = []; + $map['_string'] = " 1=1 "; + if ($pid) { + $info = M('promote', 'tab_')->where(['id'=>$pid])->find(); + if (empty($info)) return $this->error('未找到该用户'); + //if ($info['level'] != PromoteModel::LEVEL_GROUP_LEADER) {return $this->error('无效的pid');} // 跳转玩家资料页面 + $map['pdl.promote_id'] = $pid; + $info['chain'] = $info['level'] == PromoteModel::LEVEL_PRESIDENT ? [$info['id']] : array_merge(explode('/', trim($info['chain'], '/')), [$info['id']]); + } + + if (I('user_account')) { + $map['u.account'] = I('user_account'); + } + + $list = M('package_download_log', 'tab_')->alias('pdl') + ->field('pdl.promote_id, pdl.create_time, pdl.type, p.chain, u.account, p.level') + ->join('tab_promote p on p.id = pdl.promote_id') + ->join('tab_user u on u.id = pdl.user_id', 'left') + ->where($map) + ->page($p, $row) + ->select(); + + $parentIds = []; + foreach ($list as $index => $item) { + $list[$index]['type_name'] = $typeArr[$item['type']]; + $ids = explode('/', trim($item['chain'], '/')); + $parentIds = array_merge($parentIds, $ids, [$item['promote_id']]); + switch ($item['level']) { + case PromoteModel::LEVEL_PRESIDENT: + $list[$index]['president_id'] = $item['promote_id']; + break; + case PromoteModel::LEVEL_DEPARMENT: + $list[$index]['president_id'] = $ids[0]; + $list[$index]['department_id'] = $item['promote_id']; + break; + case PromoteModel::LEVEL_GROUP_LEADER://组长 + $list[$index]['president_id'] = $ids[0]; + $list[$index]['department_id'] = $ids[1]; + $list[$index]['group_leader_id'] = $item['promote_id']; + break; + case PromoteModel::LEVEL_TEAM_MEMBER: + $list[$index]['president_id'] = $ids[0]; + $list[$index]['department_id'] = $ids[1]; + $list[$index]['group_leader_id'] = $ids[2]; + $list[$index]['member_id'] = $item['promote_id']; + break; + } + } + + $parents = $parentIds ? array_column(M('promote', 'tab_')->field('id, account')->where(['id'=>['in', array_unique($parentIds)]])->select(), 'account', 'id') : []; + + foreach ($list as &$v) { + $v['create_time'] = date('Y-m-d H:i:s', $v['create_time']); + $v['type_name'] = $typeArr[$v['type']]; + $v['promote'] = isset($parents[$v['member_id']]) ? $parents[$v['member_id']] : '-'; + $v['group_leader'] = isset($parents[$v['group_leader_id']]) ? $parents[$v['group_leader_id']] : '-'; + $v['department'] = isset($parents[$v['department_id']]) ? $parents[$v['department_id']] : '-'; + $v['president'] = isset($parents[$v['president_id']]) ? $parents[$v['president_id']] : '-'; + } + + $xlsCell = array( + array('account', "玩家账号"), + array('type_name', "类型"), + array('create_time', '时间'), + array('promote', "所属推广员"), + array('group_leader', "所属组长"), + array('department', "所属部门长"), + array('president', '所属会长') + ); + + $this->exportAddOperationLog('Statistics/packUserDownload','统计-IOS下载详细统计-导出'); + $this->exportExcel($xlsName, $xlsCell, $list); + } + } diff --git a/Application/Admin/Controller/StatisticsController.class.php b/Application/Admin/Controller/StatisticsController.class.php index 467be7f9c..7aa097771 100644 --- a/Application/Admin/Controller/StatisticsController.class.php +++ b/Application/Admin/Controller/StatisticsController.class.php @@ -2,6 +2,7 @@ namespace Admin\Controller; use User\Api\UserApi as UserApi; +use Admin\Model\PromoteModel; /** * 后台首页控制器 @@ -1137,5 +1138,165 @@ class StatisticsController extends ThinkController { $this->display('ltv'); } + + public function packDownload($p=1, $row=10, $pid = 0, $level=PromoteModel::LEVEL_PRESIDENT) + { + $map = []; + $map['_string'] = " 1=1 "; + if ($pid) { + $info = M('promote', 'tab_')->where(['id'=>$pid])->find(); + if (empty($info)) return $this->error('未找到该用户'); + //if ($info['level'] == PromoteModel::LEVEL_GROUP_LEADER) {return $this->error('跳转玩家资料页面');} // 跳转玩家资料页面 + $level = $map['p.level'] = $info['level'] + 1; + $map['p.parent_id'] = $pid; + } else { + $map['p.level'] = $level; + //if ($level == PromoteModel::LEVEL_TEAM_MEMBER) {return $this->error('跳转玩家资料页面');} // 跳转玩家资料页面 + } + + $typeArr = ['未知', '企业签下载', 'TF下载', '超级签下载']; + if (I('promote_id')) { + $map['p.id'] = I('promote_id'); + } + $count = M('promote', 'tab_')->alias('p')->where($map)->count(); + + $pdlMap = ""; + if ($startTime = I('create_time_start')) { + $startTime = strtotime($startTime); + $pdlMap .= " and pdl.create_time >={$startTime}"; + } + + if ($endTime = I('create_time_start')) { + $endTime += strtotime($endTime) + 86400; + $pdlMap .= " and pdl.create_time < {$endTime}"; + } + + if ($info['level'] == PromoteModel::LEVEL_GROUP_LEADER) { + $list = M('promote', 'tab_')->alias('p') + ->field('p.id, p.level, p.account, count(pdl.id) as lowerCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') + ->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left') + ->where($map) + ->page($p, $row) + ->group('p.id') + ->select(); + + $total = M('promote', 'tab_')->alias('p') + ->field('count(pdl.id) as lowerCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') + ->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left') + ->where($map) + ->select(); + } else { + $list = M('promote', 'tab_')->alias('p') + ->field('p.id, p.level, p.account, count(p2.id) as lowerCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') + ->join("tab_promote p2 on p2.chain like CONCAT(p.chain, p.id, '/%')", 'left') + ->join("tab_package_download_log pdl on pdl.promote_id = p2.id $pdlMap", 'left') + ->where($map) + ->page($p, $row) + ->group('p.id') + ->select(); + + + $total = M('promote', 'tab_')->alias('p') + ->field('count(p2.id) as lowerCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') + ->join("tab_promote p2 on p2.chain like CONCAT(p.chain, p.id, '/%')", 'left') + ->join("tab_package_download_log pdl on pdl.promote_id = p2.id $pdlMap", 'left') + ->where($map) + ->select(); + //echo M()->getLastSql();exit; + } + + + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + + $promoters = M('promote', 'tab_')->field('id, account')->where(array_merge(['level'=>$level], $pid ? ['parent_id'=>$pid] : []))->select(); + $this->assign('promoters', $promoters); + $this->assign('types', $typeArr); + $this->assign('level_desc', PromoteModel::$levelArr[$level]); + $this->assign('level_low_desc', PromoteModel::$levelArr[$level+1]); + $this->assign('level', $level); + $this->assign('list_data', $list); + $this->assign('total', $total); + $this->display('packdownload'); + } + + public function packUserDownload($p=1, $row=10, $pid = 0) + { + $typeArr = ['未知', '企业签下载', 'TF下载', '超级签下载']; + $map = []; + $map['_string'] = " 1=1 "; + if ($pid) { + $info = M('promote', 'tab_')->where(['id'=>$pid])->find(); + if (empty($info)) return $this->error('未找到该用户'); + //if ($info['level'] != PromoteModel::LEVEL_GROUP_LEADER) {return $this->error('无效的pid');} // 跳转玩家资料页面 + $map['pdl.promote_id'] = $pid; + $info['chain'] = $info['level'] == PromoteModel::LEVEL_PRESIDENT ? [$info['id']] : array_merge(explode('/', trim($info['chain'], '/')), [$info['id']]); + } + + if (I('user_account')) { + $map['u.account'] = I('user_account'); + } + + $list = M('package_download_log', 'tab_')->alias('pdl') + ->field('pdl.promote_id, pdl.create_time, pdl.type, p.chain, u.account, p.level') + ->join('tab_promote p on p.id = pdl.promote_id') + ->join('tab_user u on u.id = pdl.user_id', 'left') + ->where($map) + ->page($p, $row) + ->select(); + + $total = M('package_download_log', 'tab_')->alias('pdl') + ->field('count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') + ->join('tab_promote p on p.id = pdl.promote_id') + ->where($map) + ->select(); + + $count = M('package_download_log', 'tab_')->alias('pdl') + ->join('tab_promote p on p.id = pdl.promote_id') + ->where($map) + ->count(); + + $parentIds = []; + foreach ($list as $index => $item) { + $list[$index]['type_name'] = $typeArr[$item['type']]; + $ids = explode('/', trim($item['chain'], '/')); + $parentIds = array_merge($parentIds, $ids, [$item['promote_id']]); + switch ($item['level']) { + case PromoteModel::LEVEL_PRESIDENT: + $list[$index]['president_id'] = $item['promote_id']; + break; + case PromoteModel::LEVEL_DEPARMENT: + $list[$index]['president_id'] = $ids[0]; + $list[$index]['department_id'] = $item['promote_id']; + break; + case PromoteModel::LEVEL_GROUP_LEADER://组长 + $list[$index]['president_id'] = $ids[0]; + $list[$index]['department_id'] = $ids[1]; + $list[$index]['group_leader_id'] = $item['promote_id']; + break; + case PromoteModel::LEVEL_TEAM_MEMBER: + $list[$index]['president_id'] = $ids[0]; + $list[$index]['department_id'] = $ids[1]; + $list[$index]['group_leader_id'] = $ids[2]; + $list[$index]['member_id'] = $item['promote_id']; + break; + } + } + $parents = $parentIds ? array_column(M('promote', 'tab_')->field('id, account')->where(['id'=>['in', array_unique($parentIds)]])->select(), 'account', 'id') : []; + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + + $this->assign('parents', $parents); + $this->assign('presidents', M('promote', 'tab_')->where(['level'=>1])->select()); + $this->assign('types', $typeArr); + $this->assign('promoter', $info?:[]); + $this->assign('list_data', $list); + $this->assign('total', $total); + $this->display('packuserdownload'); + } } diff --git a/Application/Admin/Model/PromoteModel.class.php b/Application/Admin/Model/PromoteModel.class.php index 564b09a39..e23869964 100644 --- a/Application/Admin/Model/PromoteModel.class.php +++ b/Application/Admin/Model/PromoteModel.class.php @@ -15,7 +15,17 @@ use Think\Model; */ class PromoteModel extends Model{ - + const LEVEL_PRESIDENT = 1; + const LEVEL_DEPARMENT = 2; + const LEVEL_GROUP_LEADER = 3; + const LEVEL_TEAM_MEMBER = 4; + + public static $levelArr = [ + self::LEVEL_PRESIDENT => '会长', + self::LEVEL_DEPARMENT => '部门长', + self::LEVEL_GROUP_LEADER => '组长', + self::LEVEL_TEAM_MEMBER => '组员' + ]; /* 自动验证规则 */ protected $_validate = array( diff --git a/Application/Admin/View/Statistics/packdownload.html b/Application/Admin/View/Statistics/packdownload.html new file mode 100644 index 000000000..00441d238 --- /dev/null +++ b/Application/Admin/View/Statistics/packdownload.html @@ -0,0 +1,247 @@ + + + + + + + + + + + + +
+ + +
+
+ + +
+
+ +  -  + +
+
+ +
+ +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{$level_desc}账号{$level_low_desc}数量TF下载数超级签下载数企业签下载数操作
aOh! 暂时还没有内容!
{$data.account}{$data.lowercount}{$data.tfcount}{$data.supersigncount}{$data.signcount} + + 查看下级 + + 查看下级 + +
汇总{$total[0]['lowercount']}{$total[0]['tfcount']}{$total[0]['supersigncount']}{$total[0]['signcount']} + + 查看所有下级 + + 查看下级 + + +
+
+
+
+ {$_page|default=''} + + 导出 + +
+ +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ' + + '; + + + + + + + + diff --git a/Application/Admin/View/Statistics/packuserdownload.html b/Application/Admin/View/Statistics/packuserdownload.html new file mode 100644 index 000000000..25da8e7d0 --- /dev/null +++ b/Application/Admin/View/Statistics/packuserdownload.html @@ -0,0 +1,319 @@ + + + + + + + + + + + + +
+ + +
+
+ +
+
+ +  -  + +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
玩家账号类型时间所属推广员所属组长所属部门长所属会长
aOh! 暂时还没有内容!
{$data.account}{$data.type_name}{$data.create_time|date='Y-m-d H:i:s',###}
汇总TF下载:{$total[0]['tfcount']} 超级签下载:{$total[0]['supersigncount']} 企业签下载:{$total[0]['signcount']}
+
+
+
+ {$_page|default=''} + + 导出 + +
+ +
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ' + + '; + + + + + + + + From 18b0c3024d1c186f340936fb442681c4b251f787 Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Fri, 13 Mar 2020 09:32:48 +0800 Subject: [PATCH 2/3] upt --- Application/Admin/View/Statistics/packdownload.html | 6 +++--- Application/Admin/View/Statistics/packuserdownload.html | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Application/Admin/View/Statistics/packdownload.html b/Application/Admin/View/Statistics/packdownload.html index 00441d238..46f52a638 100644 --- a/Application/Admin/View/Statistics/packdownload.html +++ b/Application/Admin/View/Statistics/packdownload.html @@ -28,8 +28,8 @@ @@ -152,7 +152,7 @@