From 872a76356d885f3e22fe67c005da6845989be764 Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Tue, 14 Apr 2020 16:04:07 +0800 Subject: [PATCH] upt --- .../Controller/ExportController.class.php | 59 ++++++++++++++---- .../Controller/StatisticsController.class.php | 62 ++++++++++++++----- .../Controller/WorkOrderController.class.php | 2 +- 3 files changed, 95 insertions(+), 28 deletions(-) diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 412f7f792..08ce040a6 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -9026,27 +9026,60 @@ class ExportController extends Controller $map['p.id'] = I('promote_id'); } - $pdlMap = ""; + $pdlMap = ""; + $weekMap = ''; if ($startTime = I('create_time_start')) { $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')) { $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) { - $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")); - $xlsData = 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) - ->group('p.id') - ->select(); + $xlsData = M('promote', 'tab_')->alias('p') + ->field('p.id, p.level, p.account') + ->where($map) + ->select(); + + if ($xlsData) { + $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"; + } + 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 { $xlsData = M('promote', 'tab_')->alias('p') @@ -9224,7 +9257,7 @@ class ExportController extends Controller NULL AS total_complete_count FROM 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 u.uid in ({$userids}) GROUP BY u.uid diff --git a/Application/Admin/Controller/StatisticsController.class.php b/Application/Admin/Controller/StatisticsController.class.php index 583498def..d1aadef86 100644 --- a/Application/Admin/Controller/StatisticsController.class.php +++ b/Application/Admin/Controller/StatisticsController.class.php @@ -1162,34 +1162,68 @@ class StatisticsController extends ThinkController { $count = M('promote', 'tab_')->alias('p')->where($map)->count(); $pdlMap = ""; + $weekMap = ''; if ($startTime = I('create_time_start')) { $startTime = strtotime($startTime); $pdlMap .= " and pdl.create_time >={$startTime}"; + $weekMap .= " and register_time >={$startTime}"; } if ($endTime = I('create_time_end')) { $endTime = strtotime($endTime) + 86400; $pdlMap .= " and pdl.create_time < {$endTime}"; + $weekMap .= " and register_time < {$endTime}"; } if ($level == PromoteModel::LEVEL_TEAM_MEMBER) { $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"; + } $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(); + ->field('p.id, p.level, p.account') + ->where($map) + ->page($p, $row) + ->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(); + if ($list) { + foreach ($list 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; + } + // $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 { $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') @@ -1271,7 +1305,7 @@ 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")); $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_user u on u.id = pdl.user_id', 'left') ->where($map) diff --git a/Application/Admin/Controller/WorkOrderController.class.php b/Application/Admin/Controller/WorkOrderController.class.php index 96ebd2753..2c13724ab 100644 --- a/Application/Admin/Controller/WorkOrderController.class.php +++ b/Application/Admin/Controller/WorkOrderController.class.php @@ -403,7 +403,7 @@ class WorkOrderController extends ThinkController NULL AS total_complete_count FROM 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 u.uid in ({$userids}) GROUP BY u.uid