From 7b9bb91e164899cdf4ea8a1878acfd5867bb758d Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Tue, 21 Jul 2020 14:12:42 +0800 Subject: [PATCH 1/3] upt --- .../Controller/ExportController.class.php | 37 +++++++------ .../Controller/PlatformController.class.php | 54 ++++++++++--------- .../Admin/View/Platform/game_statistics.html | 10 ++-- .../View/Platform/gamepay_statistics.html | 8 +-- 4 files changed, 59 insertions(+), 50 deletions(-) diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 2f9d589e1..ac5fcfb6e 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -3153,7 +3153,7 @@ class ExportController extends Controller private function game_statistics_export($p = 1){ $xlsName = $_REQUEST['xlsname']?$_REQUEST['xlsname']:"游戏注册统计"; $xlsCell = array( - array('fgame_name', "游戏名称"), + array('relation_game_name', "游戏名称"), array('count', "累计注册"), array('rand', "排行榜"), array('today', "今日注册"), @@ -3181,9 +3181,9 @@ class ExportController extends Controller $map['register_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1)); unset($_REQUEST['start']);unset($_REQUEST['end']); } - if(isset($_REQUEST['game_name'])&&$_REQUEST['game_name']!=''){ - $map['fgame_name'] =$_REQUEST['game_name']; - unset($_REQUEST['fgame_name']); + if(isset($_REQUEST['game_id'])&&$_REQUEST['game_id']!=''){ + $map['tab_game.relation_game_id'] =$_REQUEST['game_id']; + unset($_REQUEST['game_id']); } $today = total(1); $week = total(2); @@ -3191,9 +3191,10 @@ class ExportController extends Controller //为数据权限添加 setPowerPromoteIds($map); $data = $user - ->field('fgame_name,fgame_id,date_format(FROM_UNIXTIME( register_time),"%Y-%m-%d") AS time, count(id) as count') + ->field('tab_game.relation_game_id,tab_game.relation_game_name,date_format(FROM_UNIXTIME( register_time),"%Y-%m-%d") AS time, count(tab_user.id) as count') + ->join('tab_game on tab_game.id = fgame_id', 'left') ->where($map) - ->group('fgame_id') + ->group('tab_game.relation_game_id') ->order('count desc,register_time') ->select(); // dd($data); @@ -3205,8 +3206,9 @@ class ExportController extends Controller $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') + ->join('tab_game on tab_game.id = fgame_id', 'left') ->where($map2) - ->group('fgame_id') + ->group('tab_game.relation_game_id') ->select(); $data2 = array_column($data2, null, 'fgame_id'); // dd($data2); @@ -3216,8 +3218,8 @@ class ExportController extends Controller $i++; $data[$key]['rand'] = $i; - if ($data[$key]['fgame_id'] == 0) { - $data[$key]['fgame_name'] = '其他注册'; + if ($data[$key]['relation_game_id'] == 0) { + $data[$key]['relation_game_name'] = '其他注册'; } $data[$key]['today'] = $data2[$value['fgame_id']]['today']; $data[$key]['week'] = $data2[$value['fgame_id']]['week']; @@ -3237,7 +3239,7 @@ class ExportController extends Controller // $data = array_slice($data, ($arraypage-1)*$size, $size); $length = count($data); $data[$length] = array( - 'fgame_name'=>'汇总', + 'relation_game_name'=>'汇总', 'count'=>$total['sum_count'], 'rand'=>'---', 'today'=>$total['sum_today'], @@ -3249,7 +3251,6 @@ class ExportController extends Controller unset($GetData['xlsname']); addOperationLog(['op_type'=>3,'key'=>getNowDate(),'op_name'=>'导出游戏注册统计','url'=>U('Platform/game_statistics',$GetData),'menu'=>'统计-统计-平台统计-游戏注册统计']); - $xlsData = $data; $this->exportExcel($xlsName, $xlsCell, $xlsData); } @@ -3283,28 +3284,30 @@ class ExportController extends Controller $map['game_id'] =$_REQUEST['game_name']; unset($_REQUEST['game_name']); } - $map['pay_status'] = 1; + $map['tab_spend.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) + ->field('tab_game.relation_game_name as game_name, tab_game.relation_game_id as game_id,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, sum(pay_amount) as count') ->where($map) + ->join('tab_game on tab_game.id = tab_spend.game_id', 'left') ->where($map) - ->group('game_id') + ->group('tab_game.relation_game_id') ->order('count desc,pay_time') ->select(); //今日、本周、本月不随搜索条件而变动 - $map2['pay_status'] = 1; + $map2['tab_spend.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, + ->field('tab_game.relation_game_id as 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') + ->join('tab_game on tab_game.id = tab_spend.game_id', 'left') ->where($map2) - ->group('game_id') + ->group('tab_game.relation_game_id') ->select(); $data2 = array_column($data2, null, 'game_id'); $count = count($data); diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index 1236ffafd..9b2b6d1f1 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -40,9 +40,9 @@ class PlatformController extends ThinkController } // var_dump($_REQUEST);exit; - if (isset($_REQUEST['game_name']) && $_REQUEST['game_name'] != '') { - $map['fgame_name'] = $_REQUEST['game_name']; - unset($_REQUEST['fgame_name']); + if (isset($_REQUEST['game_id']) && $_REQUEST['game_id'] != '') { + $map['tab_game.relation_game_id'] = $_REQUEST['game_id']; + unset($_REQUEST['game_id']); } $today = total(1); @@ -51,9 +51,10 @@ class PlatformController extends ThinkController //为数据权限添加 setPowerPromoteIds($map); $data = $user - ->field('fgame_name,fgame_id,date_format(FROM_UNIXTIME( register_time),"%Y-%m-%d") AS time, count(id) as count') + ->field('tab_game.relation_game_id,tab_game.relation_game_name,date_format(FROM_UNIXTIME( register_time),"%Y-%m-%d") AS time, count(tab_user.id) as count') ->where($map) - ->group('fgame_id') + ->join('tab_game on tab_game.id = fgame_id', 'left') + ->group('tab_game.relation_game_id') ->order('count desc,register_time') ->select(); $map2 = array(); @@ -61,25 +62,26 @@ class PlatformController extends ThinkController $map2['puid'] = 0; setPowerPromoteIds($map2); - $data2 = $user->field('fgame_id,count(IF(register_time ' . $today . ',1,null)) as today, + $data2 = $user->field('tab_game.relation_game_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') + ->join('tab_game on tab_game.id = fgame_id', 'left') + ->group('tab_game.relation_game_id') ->select(); - $data2 = array_column($data2, null, 'fgame_id'); + $data2 = array_column($data2, null, 'relation_game_id'); $count = count($data); foreach ($data as $key => $value) { static $i = 0; $i++; $data[$key]['rand'] = $i; - if ($data[$key]['fgame_id'] == 0) { - $data[$key]['fgame_name'] = '其他注册'; + if ($data[$key]['relation_game_id'] == 0) { + $data[$key]['relation_game_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']; + $data[$key]['today'] = $data2[$value['relation_game_id']]['today']; + $data[$key]['week'] = $data2[$value['relation_game_id']]['week']; + $data[$key]['mounth'] = $data2[$value['relation_game_id']]['mounth']; } $total = $this->data_total($data); @@ -103,9 +105,10 @@ class PlatformController extends ThinkController $data = array_slice($data, ($arraypage - 1) * $size, $size); $this->checkListOrCountAuthRestMap($map,[]); - + //dd($data); $this->meta_title = '游戏注册统计列表'; $this->assign('list_data', $data); + $this->assign('games', M('game', 'tab_')->field('relation_game_id, relation_game_name')->group('relation_game_id')->select()); $this->assign("is_admin",is_administrator()); $this->display(); } @@ -142,32 +145,34 @@ class PlatformController extends ThinkController $map['game_id'] = array('gt', 0); // var_dump($_REQUEST);exit; - if (isset($_REQUEST['game_name']) && $_REQUEST['game_name'] != '') { - $map['game_id'] = $_REQUEST['game_name']; - unset($_REQUEST['game_name']); + if (isset($_REQUEST['game_id']) && $_REQUEST['game_id'] != '') { + $map['tab_game.relation_game_id'] = $_REQUEST['game_id']; + unset($_REQUEST['game_id']); } - $map['pay_status'] = 1; + $map['tab_spend.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) + ->field('tab_game.relation_game_name as game_name, tab_game.relation_game_id as 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') + ->join('tab_game on tab_game.id = tab_spend.game_id', 'left') + ->group('tab_game.relation_game_id') ->order('count desc,pay_time') ->select(); //今日、本周、本月不随搜索条件而变动 - $map2['pay_status'] = 1; + $map2['tab_spend.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, + ->field('tab_game.relation_game_id as 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') + sum(IF(pay_time ' . $mounth . ',pay_amount,0)) as mounth') + ->join('tab_game on tab_game.id = tab_spend.game_id', 'left') ->where($map2) - ->group('game_id') + ->group('tab_game.relation_game_id') ->select(); $data2 = array_column($data2, null, 'game_id'); $count = count($data); @@ -205,6 +210,7 @@ class PlatformController extends ThinkController $this->meta_title = '游戏充值统计列表'; $this->assign('list_data', $data); $this->assign("is_admin",is_administrator()); + $this->assign('games', M('game', 'tab_')->field('relation_game_id, relation_game_name')->group('relation_game_id')->select()); $this->display(); } diff --git a/Application/Admin/View/Platform/game_statistics.html b/Application/Admin/View/Platform/game_statistics.html index c9c4ed67d..759059d82 100644 --- a/Application/Admin/View/Platform/game_statistics.html +++ b/Application/Admin/View/Platform/game_statistics.html @@ -58,10 +58,10 @@
- - - + +
@@ -139,7 +139,7 @@ - {$data.fgame_name}{$data.fgame_name}{$data.fgame_name}{$data.fgame_name} + {$data.relation_game_name}{$data.relation_game_name}{$data.relation_game_name}{$data.relation_game_name} {$data.count} {$data.rand}{$data.rand}{$data.rand}{$data.rand} {$data.today} @@ -166,7 +166,7 @@ array( 'timestart'=>$_GET['timestart'], 'timeend'=>$_GET['timeend'], - 'game_name'=>$_GET['game_name'], + 'game_id'=>$_GET['game_id'], 'p'=>$_GET['p'], 'xlsname'=>'统计_平台统计_游戏注册统计', ), diff --git a/Application/Admin/View/Platform/gamepay_statistics.html b/Application/Admin/View/Platform/gamepay_statistics.html index 7036cfb7b..f41310f13 100644 --- a/Application/Admin/View/Platform/gamepay_statistics.html +++ b/Application/Admin/View/Platform/gamepay_statistics.html @@ -56,10 +56,10 @@
- - - + +
@@ -136,7 +136,7 @@
导出 {$_page|default=''} From 9a380d7756626be02ddb521637b20a690038a40d Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Tue, 21 Jul 2020 17:11:04 +0800 Subject: [PATCH 2/3] upt --- .../Controller/ExportController.class.php | 107 ++++++++++------ .../Controller/PlatformController.class.php | 119 ++++++++++++------ .../View/Platform/promote_statistics.html | 55 ++++---- .../View/Platform/promotepay_statistics.html | 56 ++++----- 4 files changed, 199 insertions(+), 138 deletions(-) diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index ac5fcfb6e..fdddfc128 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -3585,6 +3585,9 @@ class ExportController extends Controller } private function promote_statistics_export($p=0){ + $user = M('User', 'tab_'); + // $map['promote_id'] = array('egt', 0); + // $map['puid'] = 0; if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { $map['register_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)]; unset($_REQUEST['timestart']); @@ -3599,7 +3602,7 @@ class ExportController extends Controller //TODO:应需求,取消玩家表,只要user表的fgame有就算注册无需在play表存在 $play_map = false; if (isset($_REQUEST['game_name'])) { - $map['fgame_name'] = $_REQUEST['game_name']; + $map['fgame_name'] = ['like', "{$_REQUEST['game_name']}%"]; // $play_map = " and up.game_name = '{$_REQUEST['game_name']}' "; } $play_info_map = false; @@ -3608,6 +3611,14 @@ class ExportController extends Controller $play_info_map = " and upi.server_id = '{$_REQUEST['server_id']}' and upi.game_name = '{$_REQUEST['game_name']}'"; } + if (!empty($_REQUEST['admin_id'])) { + $map['promote.admin_id'] = $_REQUEST['admin_id']; + } + + if (!empty($_REQUEST['game_type'])) { + $map['tab_game.sdk_version'] = $_REQUEST['game_type']; + } + $today = total(1); $week = total(2); $mounth = total(3); @@ -3619,27 +3630,30 @@ class ExportController extends Controller } } - if (!empty($_REQUEST['admin_id'])) { - $map['promote.admin_id'] = $_REQUEST['admin_id']; - } - - //为数据权限添加 - setPowerPromoteIds($map, 'u.promote_id'); - // 如果是市场专员那么只能看自己的 + // 如果是市场专员那么只能看自己的会长信息 $isMarketAdmin = isMarketAdmin(); if ($isMarketAdmin) { $map['promote.admin_id'] = is_login(); } - + + //为数据权限添加 + setPowerPromoteIds($map, 'u.promote_id'); + $data = M("User u","tab_") - ->field("count(u.id) as count,IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',u.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) id") + ->field(" + count(u.id) as count, + tab_game.relation_game_id, + tab_game.relation_game_name, + IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='', + u.promote_id, + substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) id") ->join("tab_promote promote ON u.promote_id = promote.id","left") ->join($play_map ? "tab_user_play as up on up.user_id = u.id " . $play_map : false) - ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) + // ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) ->join('tab_game on u.fgame_id = tab_game.id') ->where($map) - ->group('id') + ->group('tab_game.relation_game_id, id') ->order('count desc, register_time') ->select(); //今日/本周/本月不变 @@ -3662,44 +3676,56 @@ class ExportController extends Controller ->field("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, + tab_game.relation_game_id, IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',u.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) id") ->join("tab_promote promote ON u.promote_id = promote.id","left") ->join($play_map ? "tab_user_play as up on up.user_id = u.id " . $play_map : false) ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) + ->join('tab_game on u.fgame_id = tab_game.id') ->where($tmap) - ->group('id') + ->group('tab_game.relation_game_id, id') ->order('register_time') ->select(); + $tmdata = []; foreach($data as $k=>$v){ $v['today'] = 0; $v['week'] = 0; $v['mounth'] = 0; - $tmdata[$v['id']] = $v; + $tag = "{$v['id']}-{$v['relation_game_id']}"; + $tmdata[$tag] = $v; } + + // 填入日/周/月统计 if(!empty($tdata)){ foreach ($tdata as $k => $v) { - $tmdata[$v['id']]['today'] = $v['today']; - $tmdata[$v['id']]['week'] = $v['week']; - $tmdata[$v['id']]['mounth'] = $v['mounth']; - $tmdata[$v['id']]['id'] = $v['id']; - } - } - if(count($tmdata) >0){ - //获取推广员 - $idstr = implode(",",array_keys($tmdata)); - $promoteRes = M("Promote","tab_")->field("id,account promote_account")->where("id in ({$idstr})")->select(); - foreach($promoteRes as $k=>$v){ - $tmdata[$v['id']]['promote_account'] = $v['promote_account']; - } - } - $data = []; - foreach($tmdata as $k => $v){ - if($v['id'] == 0){ - $v['promote_account'] = C('OFFICIEL_CHANNEL'); + $tag = "{$v['id']}-{$v['relation_game_id']}"; + $tmdata[$tag]['today'] = $v['today']; + $tmdata[$tag]['week'] = $v['week']; + $tmdata[$tag]['mounth'] = $v['mounth']; + $tmdata[$tag]['id'] = $v['id']; + if (empty($tmdata[$tag]['relation_game_name']) && !empty($v['relation_game_name'])) { + $tmdata[$tag]['relation_game_name'] = $v['relation_game_name']; + } } - $data[] = $v; } + // if(count($tmdata) >0){ + // //获取推广员 + // $idstr = implode(",",array_keys($tmdata)); + // $promoteRes = M("Promote","tab_")->field("id,account promote_account")->where("id in ({$idstr})")->select(); + // foreach($promoteRes as $k=>$v){ + // $tmdata[$v['id']]['promote_account'] = $v['promote_account']; + // } + // } + // $data = []; + // foreach($tmdata as $k => $v){ + // if($v['id'] == 0){ + // $v['promote_account'] = C('OFFICIEL_CHANNEL'); + // } + // $data[] = $v; + // } + $data = array_values($tmdata); + unset($map['tp1.id']); unset($map['tp1.chain']); unset($tmap['tp1.id']); @@ -3711,7 +3737,6 @@ class ExportController extends Controller $last_names = array_column($data,'count'); array_multisort($last_names,SORT_DESC,$data); - $count = count($data); foreach ($data as $key => $value) { static $i = 0; $i++; @@ -3722,23 +3747,27 @@ class ExportController extends Controller if ($_REQUEST['data_order'] != '') { $data_order = reset(explode(',', $_REQUEST['data_order'])); $data_order_type = end(explode(',', $_REQUEST['data_order'])); - $this->assign('userarpu_order', $data_order); - $this->assign('userarpu_order_type', $data_order_type); } + //$this->checkListOrCountAuthRestMap($map,[]); $data = my_sort($data, $data_order_type, (int)$data_order); - //用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度) $companys = !empty($data) ? M('promote', 'tab_') - ->field('tab_promote.id, company_name, sys_member.nickname as admin_username') + ->field('tab_promote.id, tab_promote.account as promote_account, company_name, sys_member.nickname as admin_username') ->join("tab_promote_company on tab_promote.company_id = tab_promote_company.id", 'left') ->join('sys_member on tab_promote.admin_id = sys_member.uid', 'left') ->where("tab_promote.id in (".implode(',', array_column($data, 'id')).")")->select() : []; + $companys = $companys ? array_column($companys, null, 'id') : []; foreach ($data as &$item) { $item['company_name'] = $companys[$item['id']]['company_name'] ?? '无'; $item['admin_username'] = $companys[$item['id']]['admin_username'] ?? '无'; + if($item['id'] == 0){ + $item['promote_account'] = C('OFFICIEL_CHANNEL'); + } else { + $item['promote_account'] = $companys[$item['id']]['promote_account']; + } } $xlsName = $_REQUEST['xlsname']?$_REQUEST['xlsname']:'推广员注册统计'; @@ -3746,7 +3775,7 @@ class ExportController extends Controller array('company_name' , "公司"), array('promote_account', "会长账号"), array('admin_username' , "市场专员"), - //array('relation_game_name' , "游戏"), + array('relation_game_name' , "游戏"), array('count' , "累计注册"), array('rand' , "排行榜"), array('today' , "今日注册"), diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index 9b2b6d1f1..fc01eda57 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -443,7 +443,7 @@ class PlatformController extends ThinkController //TODO:应需求,取消玩家表,只要user表的fgame有就算注册无需在play表存在 $play_map = false; if (isset($_REQUEST['game_name'])) { - $map['fgame_name'] = $_REQUEST['game_name']; + $map['fgame_name'] = ['like', "{$_REQUEST['game_name']}%"]; // $play_map = " and up.game_name = '{$_REQUEST['game_name']}' "; } $play_info_map = false; @@ -456,6 +456,10 @@ class PlatformController extends ThinkController $map['promote.admin_id'] = $_REQUEST['admin_id']; } + if (!empty($_REQUEST['game_type'])) { + $map['tab_game.sdk_version'] = $_REQUEST['game_type']; + } + $today = total(1); $week = total(2); $mounth = total(3); @@ -478,13 +482,19 @@ class PlatformController extends ThinkController setPowerPromoteIds($map, 'u.promote_id'); $data = M("User u","tab_") - ->field("count(u.id) as count,IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',u.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) id") + ->field(" + count(u.id) as count, + tab_game.relation_game_id, + tab_game.relation_game_name, + IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='', + u.promote_id, + substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) id") ->join("tab_promote promote ON u.promote_id = promote.id","left") ->join($play_map ? "tab_user_play as up on up.user_id = u.id " . $play_map : false) - ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) + // ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) ->join('tab_game on u.fgame_id = tab_game.id') ->where($map) - ->group('id') + ->group('tab_game.relation_game_id, id') ->order('count desc, register_time') ->select(); //今日/本周/本月不变 @@ -507,45 +517,56 @@ class PlatformController extends ThinkController ->field("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, + tab_game.relation_game_id,tab_game.relation_game_name, IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',u.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) id") ->join("tab_promote promote ON u.promote_id = promote.id","left") ->join($play_map ? "tab_user_play as up on up.user_id = u.id " . $play_map : false) ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) ->join('tab_game on u.fgame_id = tab_game.id') ->where($tmap) - ->group('id') + ->group('tab_game.relation_game_id, id') ->order('register_time') ->select(); + $tmdata = []; foreach($data as $k=>$v){ $v['today'] = 0; $v['week'] = 0; $v['mounth'] = 0; - $tmdata[$v['id']] = $v; + $tag = "{$v['id']}-{$v['relation_game_id']}"; + $tmdata[$tag] = $v; } + + // 填入日/周/月统计 if(!empty($tdata)){ foreach ($tdata as $k => $v) { - $tmdata[$v['id']]['today'] = $v['today']; - $tmdata[$v['id']]['week'] = $v['week']; - $tmdata[$v['id']]['mounth'] = $v['mounth']; - $tmdata[$v['id']]['id'] = $v['id']; - } - } - if(count($tmdata) >0){ - //获取推广员 - $idstr = implode(",",array_keys($tmdata)); - $promoteRes = M("Promote","tab_")->field("id,account promote_account")->where("id in ({$idstr})")->select(); - foreach($promoteRes as $k=>$v){ - $tmdata[$v['id']]['promote_account'] = $v['promote_account']; - } - } - $data = []; - foreach($tmdata as $k => $v){ - if($v['id'] == 0){ - $v['promote_account'] = C('OFFICIEL_CHANNEL'); + $tag = "{$v['id']}-{$v['relation_game_id']}"; + $tmdata[$tag]['today'] = $v['today']; + $tmdata[$tag]['week'] = $v['week']; + $tmdata[$tag]['mounth'] = $v['mounth']; + if (empty($tmdata[$tag]['relation_game_name']) && !empty($v['relation_game_name'])) { + $tmdata[$tag]['relation_game_name'] = $v['relation_game_name']; + } + $tmdata[$tag]['id'] = $v['id']; } - $data[] = $v; } + // if(count($tmdata) >0){ + // //获取推广员 + // $idstr = implode(",",array_keys($tmdata)); + // $promoteRes = M("Promote","tab_")->field("id,account promote_account")->where("id in ({$idstr})")->select(); + // foreach($promoteRes as $k=>$v){ + // $tmdata[$v['id']]['promote_account'] = $v['promote_account']; + // } + // } + // $data = []; + // foreach($tmdata as $k => $v){ + // if($v['id'] == 0){ + // $v['promote_account'] = C('OFFICIEL_CHANNEL'); + // } + // $data[] = $v; + // } + $data = array_values($tmdata); + unset($map['tp1.id']); unset($map['tp1.chain']); unset($tmap['tp1.id']); @@ -584,16 +605,21 @@ class PlatformController extends ThinkController $pnum = ceil(count($data) / $size); //总页数,ceil()函数用于求大于数字的最小整数 //用array_slice(array,offset,length) 函数在数组中根据条件取出一段值;array(数组),offset(元素的开始位置),length(组的长度) $data = array_slice($data, ($arraypage - 1) * $size, $size); - $companys = !empty($data) ? M('promote', 'tab_') - ->field('tab_promote.id, company_name, sys_member.nickname as admin_username') + ->field('tab_promote.id, tab_promote.account as promote_account, company_name, sys_member.nickname as admin_username') ->join("tab_promote_company on tab_promote.company_id = tab_promote_company.id", 'left') ->join('sys_member on tab_promote.admin_id = sys_member.uid', 'left') ->where("tab_promote.id in (".implode(',', array_column($data, 'id')).")")->select() : []; + $companys = $companys ? array_column($companys, null, 'id') : []; foreach ($data as &$item) { $item['company_name'] = $companys[$item['id']]['company_name'] ?? '无'; $item['admin_username'] = $companys[$item['id']]['admin_username'] ?? '无'; + if($item['id'] == 0){ + $item['promote_account'] = C('OFFICIEL_CHANNEL'); + } else { + $item['promote_account'] = $companys[$item['id']]['promote_account']; + } } $this->meta_title = '渠道注册统计列表'; $this->assign("is_admin",is_administrator()); @@ -662,13 +688,17 @@ class PlatformController extends ThinkController } if (isset($_REQUEST['game_name'])) { - $map['s.game_name'] = $_REQUEST['game_name']; + $map['s.game_name'] = ['like', "{$_REQUEST['game_name']}%"]; if (isset($_REQUEST['server_id'])) { $map['s.server_id'] = $_REQUEST['server_id']; unset($_REQUEST['server_id']); } } + if (!empty($_REQUEST['game_type'])) { + $map['s.sdk_version'] = $_REQUEST['game_type']; + } + if (isMarketAdmin()) { $map['s.market_admin_id'] = is_login(); } else if (!empty($_REQUEST['admin_id'])) { @@ -679,13 +709,13 @@ class PlatformController extends ThinkController } $data = M('promote', 'tab_')->alias('tp1') - ->field('tp1.account as promote_account,tp1.id, + ->field('tp1.account as promote_account,tp1.id,g.relation_game_id,g.relation_game_name, floor(sum(pay_amount)*100) as count') ->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left') ->join("tab_spend as s use INDEX(search) on tp2.id = s.promote_id", 'left') ->join("tab_game as g on g.id = s.game_id", 'left') ->where($map) - ->group('tp1.id') + ->group('tp1.id, g.relation_game_id') ->order('count desc') ->select(); @@ -719,7 +749,7 @@ class PlatformController extends ThinkController $tmap['pay_time'] = ['between', array($tmin,$tmonth[1][1])]; } $tdata = M('promote', 'tab_')->alias('tp1') - ->field('tp1.account as promote_account,tp1.id, + ->field('tp1.account as promote_account,tp1.id,g.relation_game_id,g.relation_game_name, floor(sum(IF(s.pay_time ' . $today . ',pay_amount,0))*100) as today, floor(sum(IF(s.pay_time ' . $week . ',pay_amount,0))*100) as week, floor(sum(IF(s.pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') @@ -727,28 +757,37 @@ class PlatformController extends ThinkController ->join("tab_spend as s on tp2.id = s.promote_id", 'left') ->join("tab_game as g on g.id = s.game_id", 'left') ->where($tmap) - ->group('tp1.id') + ->group('tp1.id, g.relation_game_id') ->select(); + $tmdata = []; foreach($data as $k=>$v){ $v['today'] = 0; $v['week'] = 0; $v['mounth'] = 0; - $tmdata[$v['id']] = $v; + $tag = "{$v['id']}-{$v['relation_game_id']}"; + $tmdata[$tag] = $v; } //dd($data); foreach ($tdata as $k => $v) { - $tmdata[$v['id']]['today'] = $v['today']; - $tmdata[$v['id']]['week'] = $v['week']; - $tmdata[$v['id']]['mounth'] = $v['mounth']; - if (!$tmdata[$v['id']]['promote_account']) { - $tmdata[$v['id']]['promote_account'] = $v['promote_account']; - $tmdata[$v['id']]['count'] = 0; + $tag = "{$v['id']}-{$v['relation_game_id']}"; + + $tmdata[$tag]['today'] = $v['today']; + $tmdata[$tag]['week'] = $v['week']; + $tmdata[$tag]['mounth'] = $v['mounth']; + if (!$tmdata[$tag]['promote_account']) { + $tmdata[$tag]['promote_account'] = $v['promote_account']; + $tmdata[$tag]['count'] = 0; + } + + if (empty( $tmdata[$tag]['relation_game_name']) && !empty($v['relation_game_name'])) { + $tmdata[$tag]['relation_game_name'] = $v['relation_game_name']; } - $tmdata[$v['id']]['id'] = $v['id']; + $tmdata[$tag]['id'] = $v['id']; } + $data = []; foreach($tmdata as $k => $v){ $data[] = $v; diff --git a/Application/Admin/View/Platform/promote_statistics.html b/Application/Admin/View/Platform/promote_statistics.html index c8942ea10..e226976b6 100644 --- a/Application/Admin/View/Platform/promote_statistics.html +++ b/Application/Admin/View/Platform/promote_statistics.html @@ -71,18 +71,26 @@
- - - + +
+
+ +
+
搜索 @@ -104,6 +112,8 @@ 市场专员 + 游戏 + 累计注册▲ 累计注册▼ 累计注册 @@ -158,6 +168,7 @@ --> {$data['admin_username']} + {$data['relation_game_name']} {$data.count} {$data.rand}{$data.rand}{$data.rand}{$data.rand} {$data.today} @@ -168,7 +179,7 @@ - 汇总 + 汇总 {$total.sum_count} --- {$total.sum_today} @@ -299,32 +310,13 @@ // endDate:date }) - $("#game_id").change(function(){ - $.ajax({ - url:"{:U('getSpendServer')}", - type:"post", - data:{game_id:$("#game_id option:selected").attr('game-id')}, - dataType:'json', - success:function(data){ - console.log(data) - str = ""; - for (var i in data){ - str += "" - } - $("#server_id").empty(); - $("#server_id").append(str); - $("#server_id").select2(); - - } - }) - }); - var game_id = "{:I('game_name')}"; var game_server = "{:I('server_id')}"; - if(game_id){ + $("#game_type").change(function(){ + console.log({sdk_version:$("#game_type option:selected").val(), game_name:$("#game_name option:selected").val()}) $.ajax({ - url:"{:U('getSpendServer')}", + url:"{:U('Ajax/getGmeServer')}", type:"post", - data:{game_name:game_id}, + data:{sdk_version:$("#game_type option:selected").val(), game_name:$("#game_name option:selected").val()}, dataType:'json', success:function(data){ console.log(data) @@ -335,10 +327,15 @@ $("#server_id").empty(); $("#server_id").append(str); $("#server_id").select2(); - } }) - } + }); + + $("#game_name").change(function(){ + $("#game_type").change(); + }); + + $("#game_name").change(); }) \ No newline at end of file diff --git a/Application/Admin/View/Platform/promotepay_statistics.html b/Application/Admin/View/Platform/promotepay_statistics.html index 1ba329b87..8ca30230a 100644 --- a/Application/Admin/View/Platform/promotepay_statistics.html +++ b/Application/Admin/View/Platform/promotepay_statistics.html @@ -70,18 +70,26 @@
- - - + +
+
+ +
+
搜索 @@ -118,6 +126,8 @@ 当前市场专员 + 游戏 + 累计充值▲ 累计充值▼ 累计充值 @@ -165,6 +175,7 @@ {$data['company_name']} {$data['promote_account']} {$data['admin_username']} + {$data['relation_game_name']} {$data.count} {$data.rand}{$data.rand}{$data.rand}{$data.rand} {$data.today} @@ -174,7 +185,7 @@ - 汇总 + 汇总 {$total.sum_count} --- {$total.sum_today} @@ -367,34 +378,14 @@ pickerPosition:'bottom-left', // endDate:date }) - $("#game_id").change(function(){ - console.log($("#game_id option:selected").attr('game-id')); - $.ajax({ - url:"{:U('getSpendServer')}", - type:"post", - data:{game_id:$("#game_id option:selected").attr('game-id')}, - dataType:'json', - success:function(data){ - console.log(data) - str = ""; - for (var i in data){ - str += "" - } - $("#server_id").empty(); - $("#server_id").append(str); - $("#server_id").select2(); - } - }) - }); - var game_name = "{:I('game_name')}"; var game_server = "{:I('server_id')}"; - if(game_name){ - console.log({game_name:game_name}) + $("#game_type").change(function(){ + console.log({sdk_version:$("#game_type option:selected").val(), game_name:$("#game_name option:selected").val()}) $.ajax({ - url:"{:U('getSpendServer')}", + url:"{:U('Ajax/getGmeServer')}", type:"post", - data:{game_name:game_name}, + data:{sdk_version:$("#game_type option:selected").val(), game_name:$("#game_name option:selected").val()}, dataType:'json', success:function(data){ console.log(data) @@ -405,10 +396,15 @@ $("#server_id").empty(); $("#server_id").append(str); $("#server_id").select2(); - } }) - } + }); + + $("#game_name").change(function(){ + $("#game_type").change(); + }); + + $("#game_name").change(); }) \ No newline at end of file From 6c23a3ee5202c425915e013a511e65e23cb562af Mon Sep 17 00:00:00 2001 From: yulingwei <2436953959@qq.com> Date: Tue, 21 Jul 2020 18:16:06 +0800 Subject: [PATCH 3/3] upt --- Application/Admin/View/Platform/promotepay_statistics.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Admin/View/Platform/promotepay_statistics.html b/Application/Admin/View/Platform/promotepay_statistics.html index 8ca30230a..10e93dfb5 100644 --- a/Application/Admin/View/Platform/promotepay_statistics.html +++ b/Application/Admin/View/Platform/promotepay_statistics.html @@ -61,7 +61,7 @@
- +