@ -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;