|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
|
namespace Admin\Controller;
|
|
|
|
|
use User\Api\UserApi as UserApi;
|
|
|
|
|
use Admin\Model\PromoteModel;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 后台首页控制器
|
|
|
|
@ -1137,5 +1138,177 @@ 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_end')) {
|
|
|
|
|
$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');} // 跳转玩家资料页面
|
|
|
|
|
// 获取包括他自己的下级id
|
|
|
|
|
$promote_ids = M('promote', 'tab_')->where("chain like '{$info['chain']}{$pid}/%' or (id={$pid}) ")->field('id')->select();
|
|
|
|
|
$promote_ids ? $map['pdl.promote_id'] = ['in', array_column($promote_ids, 'id')] : null;
|
|
|
|
|
$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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($startTime = I('create_time_start')) {
|
|
|
|
|
$startTime = strtotime($startTime);
|
|
|
|
|
$map['_string'] .= " and pdl.create_time >={$startTime}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($endTime = I('create_time_end')) {
|
|
|
|
|
$endTime = strtotime($endTime) + 86400;
|
|
|
|
|
$map['_string'] .= " and pdl.create_time < {$endTime}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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')
|
|
|
|
|
->join('tab_user u on u.id = pdl.user_id', 'left')
|
|
|
|
|
->where($map)
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
$count = M('package_download_log', 'tab_')->alias('pdl')
|
|
|
|
|
->join('tab_promote p on p.id = pdl.promote_id')
|
|
|
|
|
->join('tab_user u on u.id = pdl.user_id', 'left')
|
|
|
|
|
->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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|