master
yulingwei 5 years ago
parent 872a76356d
commit c3cb357e1c

@ -1172,7 +1172,7 @@ class StatisticsController extends ThinkController {
if ($endTime = I('create_time_end')) {
$endTime = strtotime($endTime) + 86400;
$pdlMap .= " and pdl.create_time < {$endTime}";
$weekMap .= " and register_time < {$endTime}";
$weekMap .= " and register_time <= {$endTime}";
}
if ($level == PromoteModel::LEVEL_TEAM_MEMBER) {
@ -1284,14 +1284,17 @@ class StatisticsController extends ThinkController {
$map['pdl.type'] = I('type');
}
$weekMap = '';
if ($startTime = I('create_time_start')) {
$startTime = strtotime($startTime);
$map['_string'] .= " and pdl.create_time >={$startTime}";
$weekMap .= " and register_time >={$startTime}";
}
if ($endTime = I('create_time_end')) {
$endTime = strtotime($endTime) + 86400;
$map['_string'] .= " and pdl.create_time < {$endTime}";
$weekMap .= " and register_time <= {$endTime}";
}
$list = M('package_download_log', 'tab_')->alias('pdl')
@ -1304,12 +1307,26 @@ class StatisticsController extends ThinkController {
$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"));
if (empty($weekMap)) {
$weekMap = " and register_time between $beginThisweek and $endThisweek";
}
$total = M('package_download_log', 'tab_')->alias('pdl')
->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')
->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();
$promoters = M('package_download_log', 'tab_')->alias('pdl')
->field('pdl.promote_id')
->join('tab_promote p on p.id = pdl.promote_id')
->join('tab_user u on u.id = pdl.user_id', 'left')
->where($map)
->select();
$pids = implode(',', array_unique(array_filter(array_column($promoters, 'promote_id'))));
$total[0]['ioscount'] = $promoters ? M('user', 'tab_')->where("device_type = 2 and promote_id in ($pids)")->count() : 0;
$total[0]['weekcount'] = $promoters ? M('user', 'tab_')->where("device_type = 2 and promote_id in ($pids)" . $weekMap)->count() : 0;
$count = M('package_download_log', 'tab_')->alias('pdl')
->join('tab_promote p on p.id = pdl.promote_id')

Loading…
Cancel
Save