From c3cb357e1c09bb0ae89b25528236f303d4a5c963 Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Tue, 14 Apr 2020 16:19:09 +0800 Subject: [PATCH] upt --- .../Controller/StatisticsController.class.php | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Controller/StatisticsController.class.php b/Application/Admin/Controller/StatisticsController.class.php index d1aadef86..c99dbed65 100644 --- a/Application/Admin/Controller/StatisticsController.class.php +++ b/Application/Admin/Controller/StatisticsController.class.php @@ -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')