|
|
@ -1162,34 +1162,68 @@ class StatisticsController extends ThinkController {
|
|
|
|
$count = M('promote', 'tab_')->alias('p')->where($map)->count();
|
|
|
|
$count = M('promote', 'tab_')->alias('p')->where($map)->count();
|
|
|
|
|
|
|
|
|
|
|
|
$pdlMap = "";
|
|
|
|
$pdlMap = "";
|
|
|
|
|
|
|
|
$weekMap = '';
|
|
|
|
if ($startTime = I('create_time_start')) {
|
|
|
|
if ($startTime = I('create_time_start')) {
|
|
|
|
$startTime = strtotime($startTime);
|
|
|
|
$startTime = strtotime($startTime);
|
|
|
|
$pdlMap .= " and pdl.create_time >={$startTime}";
|
|
|
|
$pdlMap .= " and pdl.create_time >={$startTime}";
|
|
|
|
|
|
|
|
$weekMap .= " and register_time >={$startTime}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($endTime = I('create_time_end')) {
|
|
|
|
if ($endTime = I('create_time_end')) {
|
|
|
|
$endTime = strtotime($endTime) + 86400;
|
|
|
|
$endTime = strtotime($endTime) + 86400;
|
|
|
|
$pdlMap .= " and pdl.create_time < {$endTime}";
|
|
|
|
$pdlMap .= " and pdl.create_time < {$endTime}";
|
|
|
|
|
|
|
|
$weekMap .= " and register_time < {$endTime}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($level == PromoteModel::LEVEL_TEAM_MEMBER) {
|
|
|
|
if ($level == PromoteModel::LEVEL_TEAM_MEMBER) {
|
|
|
|
$beginThisweek = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
|
|
|
|
$beginThisweek = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
|
|
|
|
$endThisweek = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
|
|
|
|
$endThisweek = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
|
|
|
|
|
|
|
|
if (empty($weekMap)) {
|
|
|
|
|
|
|
|
$weekMap = " and register_time between $beginThisweek and $endThisweek";
|
|
|
|
|
|
|
|
}
|
|
|
|
$list = M('promote', 'tab_')->alias('p')
|
|
|
|
$list = M('promote', 'tab_')->alias('p')
|
|
|
|
->field('p.id, p.level, p.account, count(u.id) as iosCount, count(if (u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null)) as weekCount, 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')
|
|
|
|
->field('p.id, p.level, p.account')
|
|
|
|
->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left')
|
|
|
|
|
|
|
|
->join("tab_user u on u.promote_id = p.id and u.device_type=2", 'left')
|
|
|
|
|
|
|
|
->where($map)
|
|
|
|
->where($map)
|
|
|
|
->page($p, $row)
|
|
|
|
->page($p, $row)
|
|
|
|
->group('p.id')
|
|
|
|
|
|
|
|
->select();
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
|
|
$total = M('promote', 'tab_')->alias('p')
|
|
|
|
if ($list) {
|
|
|
|
->field('count(distinct(u.id)) as iosCount, count(distinct(if (u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null))) as weekCount, 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')
|
|
|
|
foreach ($list as &$item) {
|
|
|
|
->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left')
|
|
|
|
$item['ioscount'] = M('user', 'tab_')->where('device_type = 2 and promote_id = ' . $item['id'])->count();
|
|
|
|
->join("tab_user u on u.promote_id = p.id and u.device_type=2")
|
|
|
|
$item['weekcount'] = M('user', 'tab_')->where("device_type = 2 and promote_id = {$item['id']}" . $weekMap)->count();
|
|
|
|
->where($map)
|
|
|
|
$itemCount = M('package_download_log', 'tab_')->alias('pdl')
|
|
|
|
->select();
|
|
|
|
->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')
|
|
|
|
|
|
|
|
->where("promote_id={$item['id']} $pdlMap")->select();
|
|
|
|
|
|
|
|
$item['signcount'] = $itemCount[0]['signcount'] ?? 0;
|
|
|
|
|
|
|
|
$item['tfcount'] = $itemCount[0]['tfcount'] ?? 0;
|
|
|
|
|
|
|
|
$item['supersigncount'] = $itemCount[0]['supersigncount'] ?? 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$promoters = M('promote', 'tab_')->alias('p')->field('p.id, p.level, p.account')->where($map)->select();
|
|
|
|
|
|
|
|
$pids = implode(',', array_column($promoters, 'id'));
|
|
|
|
|
|
|
|
$total[0]['ioscount'] = M('user', 'tab_')->where("device_type = 2 and promote_id in ($pids)")->count();
|
|
|
|
|
|
|
|
$total[0]['weekcount'] = M('user', 'tab_')->where("device_type = 2 and promote_id in ($pids)" . $weekMap)->count();
|
|
|
|
|
|
|
|
$totalCount = 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')
|
|
|
|
|
|
|
|
->where("promote_id in ($pids) $pdlMap")->select();
|
|
|
|
|
|
|
|
$total[0]['signcount'] = $totalCount[0]['signcount'] ?? 0;
|
|
|
|
|
|
|
|
$total[0]['tfcount'] = $totalCount[0]['tfcount'] ?? 0;
|
|
|
|
|
|
|
|
$total[0]['supersigncount'] = $totalCount[0]['supersigncount'] ?? 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// $list = M('promote', 'tab_')->alias('p')
|
|
|
|
|
|
|
|
// ->field('p.id, p.level, p.account, count(u.id) as iosCount, count(if (u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null)) as weekCount, 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')
|
|
|
|
|
|
|
|
// ->join("tab_user u on u.promote_id = p.id and u.device_type=2", 'left')
|
|
|
|
|
|
|
|
// ->where($map)
|
|
|
|
|
|
|
|
// ->page($p, $row)
|
|
|
|
|
|
|
|
// ->group('p.id')
|
|
|
|
|
|
|
|
// ->select();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $total = M('promote', 'tab_')->alias('p')
|
|
|
|
|
|
|
|
// ->field('count(distinct(u.id)) as iosCount, count(distinct(if (u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null))) as weekCount, 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')
|
|
|
|
|
|
|
|
// ->join("tab_user u on u.promote_id = p.id and u.device_type=2")
|
|
|
|
|
|
|
|
// ->where($map)
|
|
|
|
|
|
|
|
// ->select();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$list = M('promote', 'tab_')->alias('p')
|
|
|
|
$list = M('promote', 'tab_')->alias('p')
|
|
|
|
->field('p.id, p.level, p.account, count(if(p2.level = '.($level+1).', 1, null)) 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')
|
|
|
|
->field('p.id, p.level, p.account, count(if(p2.level = '.($level+1).', 1, null)) 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')
|
|
|
@ -1271,7 +1305,7 @@ class StatisticsController extends ThinkController {
|
|
|
|
$beginThisweek = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
|
|
|
|
$beginThisweek = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
|
|
|
|
$endThisweek = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
|
|
|
|
$endThisweek = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
|
|
|
|
$total = M('package_download_log', 'tab_')->alias('pdl')
|
|
|
|
$total = M('package_download_log', 'tab_')->alias('pdl')
|
|
|
|
->field('count(distinct(if(u.device_type=2, 1, null))) as iosCount, count(distinct(if (u.device_type=2 and u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null))) as weekCount, 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')
|
|
|
|
->field('count(if(u.device_type=2, 1, null)) as iosCount, count(if (u.device_type=2 and u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null)) as weekCount, 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_promote p on p.id = pdl.promote_id')
|
|
|
|
->join('tab_user u on u.id = pdl.user_id', 'left')
|
|
|
|
->join('tab_user u on u.id = pdl.user_id', 'left')
|
|
|
|
->where($map)
|
|
|
|
->where($map)
|
|
|
|