From a61e0f36b524796349403dc078a8fc3b5cfd03f4 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 26 Dec 2019 17:28:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B3=A8=E5=86=8C=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E4=BB=8A=E6=97=A5=E6=9C=AC=E5=91=A8=E6=9C=AC=E6=9C=88?= =?UTF-8?q?=E4=B8=8D=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PlatformController.class.php | 70 ++++++++++++++++--- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index cdbf674c5..6e4a63871 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -454,19 +454,67 @@ class PlatformController extends ThinkController $data = M('promote', 'tab_')->alias('tp1') ->field('tp1.account as promote_account,tp1.id, date_format(FROM_UNIXTIME(register_time),"% ") AS time, - count(u.id) as count, + count(u.id) as count') + ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') + ->join("tab_user as u on tp2.id = u.promote_id", 'left') + ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) + ->where($map) + ->group('tp1.id') + ->order('count desc, register_time') + ->select(); + //今日/本周/本月不变 + $tmap = $map; + if(isset($tmap['register_time'])){ + //获取最大最小 + $tweek = total(2,false); + $tmonth = total(3,false); + //获取最小 + $tmin = 0; + if($tweek[1][0] < $tmonth[1][0]){ + $tmin = $tweek[1][0]; + }else{ + $tmin = $tmonth[1][0]; + } + $tmap['register_time'] = ['between', array($tmin,$tmonth[1][1])]; + } + + $tdata = M('promote', 'tab_')->alias('tp1') + ->field('tp1.account as promote_account,tp1.id, + date_format(FROM_UNIXTIME(register_time),"% ") AS time, count(IF(register_time ' . $today . ',1,null)) as today, count(IF(register_time ' . $week . ',1,null)) as week, count(IF(register_time ' . $mounth . ',1,null)) as mounth') ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') ->join("tab_user as u on tp2.id = u.promote_id", 'left') ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) - ->where($map) + ->where($tmap) ->group('tp1.id') - ->order('count desc, register_time') + ->order('register_time') ->select(); + + $tmdata = []; + foreach($data as $k=>$v){ + $v['today'] = 0; + $v['week'] = 0; + $v['mounth'] = 0; + $tmdata[$v['id']] = $v; + } + foreach ($tdata as $k => $v) { + + $tmdata[$v['id']]['today'] = $v['today']; + $tmdata[$v['id']]['week'] = $v['week']; + $tmdata[$v['id']]['mounth'] = $v['mounth']; + + } + $data = []; + foreach($tmdata as $k => $v){ + $data[] = $v; + } + unset($map['tp1.id']); unset($map['tp1.chain']); + unset($tmap['tp1.chain']); + unset($tmap['tp1.chain']); $map['promote_id'] = 0; $authorityData['count'] = 0; @@ -475,13 +523,19 @@ class PlatformController extends ThinkController if ($user_auth_promote_ids == 'all' || in_array('0', explode(",", $user_auth_promote_ids))) { //官方渠道数据添加 $authorityData = M('user', 'tab_')->alias('u') - ->field('date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, - count(id) as count, - count(IF(register_time ' . $today . ',1,null)) as today, - count(IF(register_time ' . $week . ',1,null)) as week, - count(IF(register_time ' . $mounth . ',1,null)) as mounth') + ->field('date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time,count(id) as count') ->where($map) ->find(); + $tauthorityData = M('user', 'tab_')->alias('u') + ->field('date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, + count(IF(register_time ' . $today . ',1,null)) as today, + count(IF(register_time ' . $week . ',1,null)) as week, + count(IF(register_time ' . $mounth . ',1,null)) as mounth') + ->where($tmap) + ->find(); + $authorityData['today'] = $tauthorityData['today']; + $authorityData['week'] = $tauthorityData['week']; + $authorityData['mounth'] = $tauthorityData['mounth']; } $authorityData['promote_account'] = "官方渠道"; $authorityData['id'] = "1";