master
yulingwei 5 years ago
parent ccc159d3b2
commit 872a76356d

@ -9026,27 +9026,60 @@ class ExportController extends Controller
$map['p.id'] = I('promote_id'); $map['p.id'] = I('promote_id');
} }
$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 ($startTime = I('create_time_start')) {
$startTime = strtotime($startTime);
$pdlMap .= " and pdl.create_time >={$startTime}";
$weekMap .= " and register_time >={$startTime}";
} }
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")); $xlsData = M('promote', 'tab_')->alias('p')
$endThisweek = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y")); ->field('p.id, p.level, p.account')
$xlsData = M('promote', 'tab_')->alias('p') ->where($map)
->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') ->select();
->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') if ($xlsData) {
->where($map) $beginThisweek = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
->group('p.id') $endThisweek = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
->select(); if (empty($weekMap)) {
$weekMap = " and register_time between $beginThisweek and $endThisweek";
}
foreach ($xlsData as &$item) {
$item['ioscount'] = M('user', 'tab_')->where('device_type = 2 and promote_id = ' . $item['id'])->count();
$item['weekcount'] = M('user', 'tab_')->where("device_type = 2 and promote_id = {$item['id']}" . $weekMap)->count();
$itemCount = 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={$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;
}
} else { } else {
$xlsData = M('promote', 'tab_')->alias('p') $xlsData = M('promote', 'tab_')->alias('p')
@ -9224,7 +9257,7 @@ class ExportController extends Controller
NULL AS total_complete_count NULL AS total_complete_count
FROM FROM
sys_member u sys_member u
LEFT JOIN tab_work_order_info i ON i.creator_id = u.uid JOIN tab_work_order_info i ON i.creator_id = u.uid
WHERE WHERE
u.uid in ({$userids}) u.uid in ({$userids})
GROUP BY u.uid GROUP BY u.uid

@ -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') ->where($map)
->join("tab_user u on u.promote_id = p.id and u.device_type=2", 'left') ->page($p, $row)
->where($map) ->select();
->page($p, $row)
->group('p.id') if ($list) {
->select(); foreach ($list as &$item) {
$item['ioscount'] = M('user', 'tab_')->where('device_type = 2 and promote_id = ' . $item['id'])->count();
$total = M('promote', 'tab_')->alias('p') $item['weekcount'] = M('user', 'tab_')->where("device_type = 2 and promote_id = {$item['id']}" . $weekMap)->count();
->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') $itemCount = M('package_download_log', 'tab_')->alias('pdl')
->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left') ->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_user u on u.promote_id = p.id and u.device_type=2") ->where("promote_id={$item['id']} $pdlMap")->select();
->where($map) $item['signcount'] = $itemCount[0]['signcount'] ?? 0;
->select(); $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)

@ -403,7 +403,7 @@ class WorkOrderController extends ThinkController
NULL AS total_complete_count NULL AS total_complete_count
FROM FROM
sys_member u sys_member u
LEFT JOIN tab_work_order_info i ON i.creator_id = u.uid JOIN tab_work_order_info i ON i.creator_id = u.uid
WHERE WHERE
u.uid in ({$userids}) u.uid in ({$userids})
GROUP BY u.uid GROUP BY u.uid

Loading…
Cancel
Save