From 1e9409ef1ab3f61f263fcb034de2c048396bd06c Mon Sep 17 00:00:00 2001 From: liuweiwen <“529520975@qq.com> Date: Thu, 26 Dec 2019 15:53:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96-=E3=80=90=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E3=80=91-=E3=80=90=E5=B9=B3=E5=8F=B0=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E3=80=91-=E3=80=90=E6=B8=B8=E6=88=8F=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E3=80=91=E3=80=81=E3=80=90=E6=B8=B8=E6=88=8F=E5=85=85=E5=80=BC?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E3=80=91=E3=80=81=E3=80=90=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E7=BB=9F=E8=AE=A1=E3=80=91=E5=92=8C=E3=80=90?= =?UTF-8?q?=E5=85=85=E5=80=BC=E6=96=B9=E5=BC=8F=E7=BB=9F=E8=AE=A1=E3=80=91?= =?UTF-8?q?=E7=9A=84=E4=BB=8A=E6=97=A5=E5=85=85=E5=80=BC=E3=80=81=E6=9C=AC?= =?UTF-8?q?=E5=91=A8=E5=85=85=E5=80=BC=E3=80=81=E6=9C=AC=E6=9C=88=E5=85=85?= =?UTF-8?q?=E5=80=BC=E4=B8=8D=E6=A0=B9=E6=8D=AE=E6=97=B6=E9=97=B4=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E6=94=B9=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/ExportController.class.php | 167 ++++++++++++------ .../Controller/PlatformController.class.php | 95 ++++++++-- .../RechargeSumController.class.php | 3 +- 3 files changed, 190 insertions(+), 75 deletions(-) diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 8205764a9..c6d331b20 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -2438,30 +2438,43 @@ class ExportController extends Controller $map['fgame_name'] =$_REQUEST['game_name']; unset($_REQUEST['fgame_name']); } - $today=total(1); - $week=total(2); - $mounth=total(3); + $today = total(1); + $week = total(2); + $mounth = total(3); //为数据权限添加 setPowerPromoteIds($map); - $data=$user - ->field('fgame_name,fgame_id,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') + $data = $user + ->field('fgame_name,fgame_id,date_format(FROM_UNIXTIME( register_time),"%Y-%m-%d") AS time, count(id) as count') ->where($map) ->group('fgame_id') ->order('count desc,register_time') ->select(); - - $count=count($data); +// dd($data); + $map2 = array(); + $map['fgame_id'] = array('egt', 0); + $map['puid'] = 0; + setPowerPromoteIds($map2); + + $data2 = $user->field('fgame_id,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($map2) + ->group('fgame_id') + ->select(); + $data2 = array_column($data2, null, 'fgame_id'); +// dd($data2); + $count = count($data); foreach ($data as $key => $value) { - static $i=0; + static $i = 0; $i++; - $data[$key]['rand']=$i; + $data[$key]['rand'] = $i; if ($data[$key]['fgame_id'] == 0) { $data[$key]['fgame_name'] = '其他注册'; } + $data[$key]['today'] = $data2[$value['fgame_id']]['today']; + $data[$key]['week'] = $data2[$value['fgame_id']]['week']; + $data[$key]['mounth'] = $data2[$value['fgame_id']]['mounth']; } $total=A('Platform')->data_total($data); if($_REQUEST['data_order']!=''){ @@ -2517,26 +2530,39 @@ class ExportController extends Controller $map['game_id'] =$_REQUEST['game_name']; unset($_REQUEST['game_name']); } - $map['pay_status']=1; - $today=total(1); - $week=total(2); - $mounth=total(3); - //为数据权限添加 - setPowerPromoteIds($map); - $data=$spend - ->field('game_name,game_id,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count, - sum(IF(pay_time '.$today.',pay_amount,0)) as today, - sum(IF(pay_time '.$week.',pay_amount,0)) as week, - sum(IF(pay_time '.$mounth.',pay_amount,0)) as mounth') + $map['pay_status'] = 1; + $today = total(1); + $week = total(2); + $mounth = total(3); + + + $data = $spend + ->field('game_name,game_id,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count') ->where($map) ->where($map) ->group('game_id') - ->order('count desc') + ->order('count desc,pay_time') ->select(); - $count=count($data); + //今日、本周、本月不随搜索条件而变动 + $map2['pay_status'] = 1; + $map2['game_id'] = array('gt', 0); + setPowerPromoteIds($map2); + $data2 = $spend + ->field('game_id,sum(IF(pay_time ' . $today . ',pay_amount,0)) as today, + sum(IF(pay_time ' . $week . ',pay_amount,0)) as week, + sum(IF(pay_time ' . $mounth . ',pay_amount,0)) as mounth') + ->where($map2) + ->group('game_id') + ->select(); + $data2 = array_column($data2, null, 'game_id'); + $count = count($data); foreach ($data as $key => $value) { - static $i=0; + static $i = 0; $i++; - $data[$key]['rand']=$i; + $data[$key]['rand'] = $i; + //加入今日、本周、本月数据 + $data[$key]['today'] = $data2[$value['game_id']]['today']; + $data[$key]['week'] = $data2[$value['game_id']]['week']; + $data[$key]['mounth'] = $data2[$value['game_id']]['mounth']; } $total=A('Platform')->data_total($data); $this->assign('total',$total); @@ -2583,7 +2609,8 @@ class ExportController extends Controller $page = $page ? $page : 1; //默认显示第一页数据 $arraypage=$page; $row = 10; - $user=M('User','tab_');$map['puid'] = 0; + $user=M('User','tab_'); + $map['puid'] = 0; if(isset($_REQUEST['timestart'])&&isset($_REQUEST['timeend'])){ $map['register_time'] =array('BETWEEN',array(strtotime($_REQUEST['timestart']),strtotime($_REQUEST['timeend'])+24*60*60-1)); unset($_REQUEST['timestart']);unset($_REQUEST['timeend']); @@ -2596,26 +2623,41 @@ class ExportController extends Controller $map['register_way'] =$_REQUEST['register_way']; unset($_REQUEST['register_way']); } - $today=total(1); - $week=total(2); - $mounth=total(3); - //为数据权限添加 + setPowerPromoteIds($map); - $data=$user - ->field('register_way,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') + + $today = total(1); + $week = total(2); + $mounth = total(3); + $data = $user + ->field('register_way,date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(id) as count') ->where($map) ->group('register_way') - ->order('count desc') + ->order('count desc,register_time') + ->select(); + + $map2 = array(); + $map2['puid'] = 0; + setPowerPromoteIds($map2); + $data2 = $user + ->field('register_way, + 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($map2) + ->group('register_way') ->select(); - $count=count($data); + $data2 = array_column($data2, null, 'register_way'); + $count = count($data); foreach ($data as $key => $value) { - static $i=0; + static $i = 0; $i++; - $data[$key]['rand']=$i; + $data[$key]['rand'] = $i; + $data[$key]['today'] = $data2[$value['register_way']]['today']; + $data[$key]['week'] = $data2[$value['register_way']]['week']; + $data[$key]['mounth'] = $data2[$value['register_way']]['mounth']; } + $total=A('Platform')->data_total($data); if($_REQUEST['data_order']!=''){ $data_order=reset(explode(',',$_REQUEST['data_order'])); @@ -2669,27 +2711,42 @@ class ExportController extends Controller $map['pay_way'] = array('in',$_REQUEST['pay_way']) ; unset($_REQUEST['pay_way']); } - $map['pay_status']=1; - $today=total(1); - $week=total(2); - $mounth=total(3); - //为数据权限添加 setPowerPromoteIds($map); - $data=$spend - ->field('pay_way,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count, - sum(IF(pay_time '.$today.',pay_amount,0)) as today, - sum(IF(pay_time '.$week.',pay_amount,0)) as week, - sum(IF(pay_time '.$mounth.',pay_amount,0)) as mounth') + + $map['pay_status'] = 1; + $today = total(1); + $week = total(2); + $mounth = total(3); + $data = $spend + ->field('pay_way,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count') ->where($map) ->group('pay_way') - ->order('count desc') + ->order('count desc,pay_time') ->select(); - $count=count($data); + + $map2 = array(); + $map2['pay_status'] = 1; + setPowerPromoteIds($map2); + $data2 = $spend + ->field('pay_way, + sum(IF(pay_time ' . $today . ',pay_amount,0)) as today, + sum(IF(pay_time ' . $week . ',pay_amount,0)) as week, + sum(IF(pay_time ' . $mounth . ',pay_amount,0)) as mounth') + ->where($map2) + ->group('pay_way') + ->select(); + $data2 = array_column($data2, null, 'pay_way'); + + $count = count($data); foreach ($data as $key => $value) { - static $i=0; + static $i = 0; $i++; - $data[$key]['rand']=$i; + $data[$key]['rand'] = $i; + $data[$key]['today'] = $data2[$value['pay_way']]['today']; + $data[$key]['week'] = $data2[$value['pay_way']]['week']; + $data[$key]['mounth'] = $data2[$value['pay_way']]['mounth']; } + $total = A('Platform')->data_total($data); $this->assign('total',$total); if($_REQUEST['data_order']!=''){ diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index 0ccf54ea5..a7acbcf85 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -44,21 +44,32 @@ class PlatformController extends ThinkController $map['fgame_name'] = $_REQUEST['game_name']; unset($_REQUEST['fgame_name']); } - //为数据权限添加 - setPowerPromoteIds($map); $today = total(1); $week = total(2); $mounth = total(3); + //为数据权限添加 + setPowerPromoteIds($map); $data = $user - ->field('fgame_name,fgame_id,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('fgame_name,fgame_id,date_format(FROM_UNIXTIME( register_time),"%Y-%m-%d") AS time, count(id) as count') ->where($map) ->group('fgame_id') ->order('count desc,register_time') ->select(); +// dd($data); + $map2 = array(); + $map['fgame_id'] = array('egt', 0); + $map['puid'] = 0; + setPowerPromoteIds($map2); + + $data2 = $user->field('fgame_id,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($map2) + ->group('fgame_id') + ->select(); + $data2 = array_column($data2, null, 'fgame_id'); +// dd($data2); $count = count($data); foreach ($data as $key => $value) { static $i = 0; @@ -68,6 +79,9 @@ class PlatformController extends ThinkController if ($data[$key]['fgame_id'] == 0) { $data[$key]['fgame_name'] = '其他注册'; } + $data[$key]['today'] = $data2[$value['fgame_id']]['today']; + $data[$key]['week'] = $data2[$value['fgame_id']]['week']; + $data[$key]['mounth'] = $data2[$value['fgame_id']]['mounth']; } $total = $this->data_total($data); @@ -110,8 +124,6 @@ class PlatformController extends ThinkController $spend = M('Spend', 'tab_'); $deposit = M('Deposit', "tab_"); - $map['game_id'] = array('gt', 0); - if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { $map['pay_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)]; unset($_REQUEST['timestart']); @@ -132,24 +144,40 @@ class PlatformController extends ThinkController $map['game_id'] = $_REQUEST['game_name']; unset($_REQUEST['game_name']); } + $map['game_id'] = array('gt', 0); $map['pay_status'] = 1; $today = total(1); $week = total(2); $mounth = total(3); + $data = $spend - ->field('game_name,game_id,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count, - sum(IF(pay_time ' . $today . ',pay_amount,0)) as today, - sum(IF(pay_time ' . $week . ',pay_amount,0)) as week, - sum(IF(pay_time ' . $mounth . ',pay_amount,0)) as mounth') + ->field('game_name,game_id,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count') ->where($map) ->where($map) ->group('game_id') ->order('count desc,pay_time') ->select(); + + //今日、本周、本月不随搜索条件而变动 + $map2['pay_status'] = 1; + $map2['game_id'] = array('gt', 0); + setPowerPromoteIds($map2); + $data2 = $spend + ->field('game_id,sum(IF(pay_time ' . $today . ',pay_amount,0)) as today, + sum(IF(pay_time ' . $week . ',pay_amount,0)) as week, + sum(IF(pay_time ' . $mounth . ',pay_amount,0)) as mounth') + ->where($map2) + ->group('game_id') + ->select(); + $data2 = array_column($data2, null, 'game_id'); $count = count($data); foreach ($data as $key => $value) { static $i = 0; $i++; $data[$key]['rand'] = $i; + //加入今日、本周、本月数据 + $data[$key]['today'] = $data2[$value['game_id']]['today']; + $data[$key]['week'] = $data2[$value['game_id']]['week']; + $data[$key]['mounth'] = $data2[$value['game_id']]['mounth']; } $total = $this->data_total($data); $this->assign('total', $total); @@ -219,20 +247,34 @@ class PlatformController extends ThinkController $week = total(2); $mounth = total(3); $data = $user - ->field('register_way,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('register_way,date_format(FROM_UNIXTIME(register_time),"%Y-%m-%d") AS time, count(id) as count') ->where($map) ->group('register_way') ->order('count desc,register_time') ->select(); + + $map2 = array(); + $map2['puid'] = 0; + setPowerPromoteIds($map2); + $data2 = $user + ->field('register_way, + 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($map2) + ->group('register_way') + ->select(); + $data2 = array_column($data2, null, 'register_way'); $count = count($data); foreach ($data as $key => $value) { static $i = 0; $i++; $data[$key]['rand'] = $i; + $data[$key]['today'] = $data2[$value['register_way']]['today']; + $data[$key]['week'] = $data2[$value['register_way']]['week']; + $data[$key]['mounth'] = $data2[$value['register_way']]['mounth']; } + $total = $this->data_total($data); if ($_REQUEST['data_order'] != '') { $data_order = reset(explode(',', $_REQUEST['data_order'])); @@ -302,20 +344,35 @@ class PlatformController extends ThinkController $week = total(2); $mounth = total(3); $data = $spend - ->field('pay_way,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count, + ->field('pay_way,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count') + ->where($map) + ->group('pay_way') + ->order('count desc,pay_time') + ->select(); + + $map2 = array(); + $map2['pay_status'] = 1; + setPowerPromoteIds($map2); + $data2 = $spend + ->field('pay_way, sum(IF(pay_time ' . $today . ',pay_amount,0)) as today, sum(IF(pay_time ' . $week . ',pay_amount,0)) as week, sum(IF(pay_time ' . $mounth . ',pay_amount,0)) as mounth') - ->where($map) + ->where($map2) ->group('pay_way') - ->order('count desc,pay_time') ->select(); + $data2 = array_column($data2, null, 'pay_way'); + $count = count($data); foreach ($data as $key => $value) { static $i = 0; $i++; $data[$key]['rand'] = $i; + $data[$key]['today'] = $data2[$value['pay_way']]['today']; + $data[$key]['week'] = $data2[$value['pay_way']]['week']; + $data[$key]['mounth'] = $data2[$value['pay_way']]['mounth']; } + $total = $this->data_total($data); $this->assign('total', $total); if ($_REQUEST['data_order'] != '') { diff --git a/Application/Admin/Controller/RechargeSumController.class.php b/Application/Admin/Controller/RechargeSumController.class.php index 6c9946b7b..42571a658 100644 --- a/Application/Admin/Controller/RechargeSumController.class.php +++ b/Application/Admin/Controller/RechargeSumController.class.php @@ -64,7 +64,8 @@ class RechargeSumController extends ThinkController //当天注册人数 $registerNum = D('User')->where(array_merge($rmap, array('puid' => 0)))->join("tab_user_play on tab_user.id = tab_user_play.user_id and tab_user.fgame_id = tab_user_play.game_id", 'left')->field("tab_user.id")->select(); $registerNum = $registerNum ? array_column($registerNum, 'id') : []; - +// if ($key ==2) +// dd(D('User')->_sql()); //当天活跃人数 $livenNum = D('UserPlay')->where($map)->count("id");