|
|
|
@ -721,211 +721,214 @@ class UserEvent extends BaseEvent {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function arpu_analysis() {
|
|
|
|
|
if (IS_POST && $_POST['time_start'] && $_POST['time_end']) {
|
|
|
|
|
$request = $_REQUEST;
|
|
|
|
|
$game_id = $request['game_id'];
|
|
|
|
|
$promote_id = $request['promote_id'];
|
|
|
|
|
$this->assign('promote_arpu',$promote_id);
|
|
|
|
|
$start = strtotime($request['time_start']);
|
|
|
|
|
$end = strtotime($request['time_end'])+24*60*60-1;
|
|
|
|
|
if ($start>$end) {
|
|
|
|
|
$start = $end;
|
|
|
|
|
$_REQUEST['time_start'] = $request['time_end'];
|
|
|
|
|
$_REQUEST['time_end'] = $request['time_start'];
|
|
|
|
|
$end = strtotime($request['time_start']);
|
|
|
|
|
}
|
|
|
|
|
$promote = M('promote', 'tab_')->where(['id' => session('promote_auth.pid')])->find();
|
|
|
|
|
$map = [
|
|
|
|
|
'_logic' => 'or',
|
|
|
|
|
'id' => $promote['id'],
|
|
|
|
|
'parent_id' => $promote['id'],
|
|
|
|
|
'grand_id' => $promote['id'],
|
|
|
|
|
];
|
|
|
|
|
$ids = M('promote', 'tab_')->where($map)->getField('id', true);
|
|
|
|
|
|
|
|
|
|
if (IS_POST && $_POST['time_start'] && $_POST['time_end']) {
|
|
|
|
|
$request = $_REQUEST;
|
|
|
|
|
$game_id = $request['game_id'];
|
|
|
|
|
$promote_id = $request['promote_id'];
|
|
|
|
|
$this->assign('promote_arpu', $promote_id);
|
|
|
|
|
$start = strtotime($request['time_start']);
|
|
|
|
|
$end = strtotime($request['time_end'])+24*60*60-1;
|
|
|
|
|
if ($start>$end) {
|
|
|
|
|
$start = $end;
|
|
|
|
|
$_REQUEST['time_start'] = $request['time_end'];
|
|
|
|
|
$_REQUEST['time_end'] = $request['time_start'];
|
|
|
|
|
$end = strtotime($request['time_start']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$game_id = empty($request['game_id'])?0:$request['game_id'];
|
|
|
|
|
$promote_id = empty($request['promote_id'])?0:$request['promote_id'];
|
|
|
|
|
$start = mktime(0,0,0,date('m'),date('d')-6,date('Y'));
|
|
|
|
|
$_REQUEST['time_start'] = date('Y-m-d',$start);
|
|
|
|
|
$end = time();
|
|
|
|
|
$_REQUEST['time_end'] = date('Y-m-d');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$game_id = empty($request['game_id'])?0:$request['game_id'];
|
|
|
|
|
$promote_id = empty($request['promote_id'])?0:$request['promote_id'];
|
|
|
|
|
$start = mktime(0,0,0,date('m'),date('d')-6,date('Y'));
|
|
|
|
|
$_REQUEST['time_start'] = date('Y-m-d',$start);
|
|
|
|
|
$end = time();
|
|
|
|
|
$_REQUEST['time_end'] = date('Y-m-d');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//包含绑币 和 排除绑币
|
|
|
|
|
if (I('bind_coin') == 1){
|
|
|
|
|
$bangbi = true;
|
|
|
|
|
}else{
|
|
|
|
|
$bangbi = false;
|
|
|
|
|
}
|
|
|
|
|
//包含绑币 和 排除绑币
|
|
|
|
|
if (I('bind_coin') == 1){
|
|
|
|
|
$bangbi = true;
|
|
|
|
|
}else{
|
|
|
|
|
$bangbi = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($end-$start<=7776000 ) {
|
|
|
|
|
if ($end - $start <= 7776000 ) {
|
|
|
|
|
if ($promote_id <1) {
|
|
|
|
|
$pid = D('Promote')->get_child_promote(PID,'id');
|
|
|
|
|
if (empty($pid[0])) {
|
|
|
|
|
$promote_id = PID;
|
|
|
|
|
} else {
|
|
|
|
|
$id = implode(',',array_column($pid,'id'));
|
|
|
|
|
$promote_id = PID.','.$id;
|
|
|
|
|
}
|
|
|
|
|
$pid = D('Promote')->get_child_promote(PID,'id');
|
|
|
|
|
if (empty($pid[0])) {
|
|
|
|
|
$promote_id = PID;
|
|
|
|
|
} else {
|
|
|
|
|
$id = implode(',',array_column($pid,'id'));
|
|
|
|
|
$promote_id = PID.','.$id;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if(PID == $promote_id) {
|
|
|
|
|
|
|
|
|
|
if(PID == $promote_id) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$pro_id1=get_prmoote_chlid_account($promote_id);
|
|
|
|
|
$pro_arr = array_column($pro_id1,'id');
|
|
|
|
|
$pro_arr[] = $promote_id;
|
|
|
|
|
$promote_id=implode(',',$pro_arr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$datelist = get_date_list($start,$end);
|
|
|
|
|
$user = D('User');
|
|
|
|
|
$spend = D('Spend');
|
|
|
|
|
/*付费游戏数*/
|
|
|
|
|
$paygame = $spend->pay_game_by_time($start,$end,$game_id,$promote_id,$bangbi);
|
|
|
|
|
|
|
|
|
|
$newslist = $user->register_list_by_time($start,$end,$game_id,$promote_id,'time','');
|
|
|
|
|
|
|
|
|
|
/* 活跃玩家 */
|
|
|
|
|
$activelist = $user->login_count_by_time($start,$end,$game_id,$promote_id);
|
|
|
|
|
|
|
|
|
|
/* 充值金额 */
|
|
|
|
|
$incomelist = $spend -> money_amount_by_time($start,$end,$game_id,$promote_id,$bangbi);
|
|
|
|
|
|
|
|
|
|
/* 付费玩家 */
|
|
|
|
|
$paylist = $spend->pay_count_by_time($start,$end,$game_id,$promote_id,$bangbi);
|
|
|
|
|
|
|
|
|
|
/* 新付费玩家 */
|
|
|
|
|
$newspay = $spend->pay_count_by_time_class_game($datelist,$game_id,$promote_id,1,$bangbi);
|
|
|
|
|
/*新付费金额*/
|
|
|
|
|
$newspaysum = $spend->pay_sum_by_time_class_game($datelist,$game_id,$promote_id,1,$bangbi);
|
|
|
|
|
/* 开始时间前的付费玩家 */
|
|
|
|
|
$totalPayPlayer = $spend->payUsersStatisticsAgo($start,$game_id,$promote_id,$bangbi);
|
|
|
|
|
|
|
|
|
|
/* 留存 */
|
|
|
|
|
$ratention1 = $user->ratention_rate($newslist,$game_id,$promote_id);
|
|
|
|
|
|
|
|
|
|
/* 数据整理 */
|
|
|
|
|
foreach($datelist as $dv) {
|
|
|
|
|
$newPayUsers[$dv]=$activeUsers[$dv]=$newUsers[$dv]=$payUsers[$dv]=$usersIncome[$dv]=$ratentionRate1[$dv]=0;
|
|
|
|
|
|
|
|
|
|
$data[$dv]['newPayUsers']=$data[$dv]['activeUsers']=$data[$dv]['newUsers']=$data[$dv]['payUsers']=$data[$dv]['usersIncome']=0;
|
|
|
|
|
$data[$dv]['totalPayUsers']=intval($totalPayPlayer);
|
|
|
|
|
$data[$dv]['ratentionRate1']='--';
|
|
|
|
|
$data[$dv]['usersPayRate'] = '--';
|
|
|
|
|
$data[$dv]['usersArpu']=0;
|
|
|
|
|
$data[$dv]['usersArppu']=0;
|
|
|
|
|
$data[$dv]['payGame'] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
$pro_id1 = get_prmoote_chlid_account($promote_id);
|
|
|
|
|
$pro_arr = array_column($pro_id1,'id');
|
|
|
|
|
$pro_arr[] = $promote_id;
|
|
|
|
|
$promote_id=implode(',',$pro_arr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$datelist = get_date_list($start,$end);
|
|
|
|
|
$user = D('User');
|
|
|
|
|
$spend = D('Spend');
|
|
|
|
|
/*付费游戏数*/
|
|
|
|
|
$paygame = $spend->pay_game_by_time($start,$end,$game_id,$promote_id,$bangbi);
|
|
|
|
|
|
|
|
|
|
$newslist = $user->register_list_by_time($start,$end,$game_id,$promote_id,'time','');
|
|
|
|
|
|
|
|
|
|
/* 活跃玩家 */
|
|
|
|
|
$activelist = $user->login_count_by_time($start,$end,$game_id,$promote_id);
|
|
|
|
|
|
|
|
|
|
/* 充值金额 */
|
|
|
|
|
$incomelist = $spend -> money_amount_by_time($start,$end,$game_id,$promote_id,$bangbi);
|
|
|
|
|
|
|
|
|
|
/* 付费玩家 */
|
|
|
|
|
$paylist = $spend->pay_count_by_time($start,$end,$game_id,$promote_id,$bangbi);
|
|
|
|
|
|
|
|
|
|
/* 新付费玩家 */
|
|
|
|
|
$newspay = $spend->pay_count_by_time_class_game($datelist,$game_id,$promote_id,1,$bangbi);
|
|
|
|
|
/*新付费金额*/
|
|
|
|
|
$newspaysum = $spend->pay_sum_by_time_class_game($datelist,$game_id,$promote_id,1,$bangbi);
|
|
|
|
|
/* 开始时间前的付费玩家 */
|
|
|
|
|
$totalPayPlayer = $spend->payUsersStatisticsAgo($start,$game_id,$promote_id,$bangbi);
|
|
|
|
|
|
|
|
|
|
/* 留存 */
|
|
|
|
|
$ratention1 = $user->ratention_rate($newslist,$game_id,$promote_id);
|
|
|
|
|
|
|
|
|
|
/* 数据整理 */
|
|
|
|
|
foreach($datelist as $dv) {
|
|
|
|
|
$newPayUsers[$dv]=$activeUsers[$dv]=$newUsers[$dv]=$payUsers[$dv]=$usersIncome[$dv]=$ratentionRate1[$dv]=0;
|
|
|
|
|
|
|
|
|
|
$data[$dv]['newPayUsers']=$data[$dv]['activeUsers']=$data[$dv]['newUsers']=$data[$dv]['payUsers']=$data[$dv]['usersIncome']=0;
|
|
|
|
|
$data[$dv]['totalPayUsers']=intval($totalPayPlayer);
|
|
|
|
|
$data[$dv]['ratentionRate1']='--';
|
|
|
|
|
$data[$dv]['usersPayRate'] = '--';
|
|
|
|
|
$data[$dv]['usersArpu']=0;
|
|
|
|
|
$data[$dv]['usersArppu']=0;
|
|
|
|
|
$data[$dv]['payGame'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach($datelist as $dv) {
|
|
|
|
|
/**
|
|
|
|
|
* 付费游戏数
|
|
|
|
|
*/
|
|
|
|
|
foreach ($paygame as $pgal) {
|
|
|
|
|
if($dv == $pgal['pay_time']) {
|
|
|
|
|
$paygame[$dv]=intval($pgal['pay_num']);
|
|
|
|
|
$data[$dv]['payGame']=intval($pgal['pay_num']);break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach($datelist as $dv) {
|
|
|
|
|
/**
|
|
|
|
|
* 付费游戏数
|
|
|
|
|
*/
|
|
|
|
|
foreach ($paygame as $pgal) {
|
|
|
|
|
if($dv == $pgal['pay_time']) {
|
|
|
|
|
$paygame[$dv]=intval($pgal['pay_num']);
|
|
|
|
|
$data[$dv]['payGame']=intval($pgal['pay_num']);break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 新增玩家 */
|
|
|
|
|
foreach ($newslist as $nlv) {
|
|
|
|
|
if ($dv == $nlv['time']) {
|
|
|
|
|
/* 新增玩家 */
|
|
|
|
|
foreach ($newslist as $nlv) {
|
|
|
|
|
if ($dv == $nlv['time']) {
|
|
|
|
|
|
|
|
|
|
$data[$dv]['newUsers']=count(explode(',',$nlv['id']));break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* 活跃玩家 */
|
|
|
|
|
foreach ($activelist as $alv) {
|
|
|
|
|
if ($dv == $alv['time']) {
|
|
|
|
|
$activeUsers[$dv]=intval($alv['login_num']);
|
|
|
|
|
$data[$dv]['newUsers']=count(explode(',',$nlv['id']));break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* 活跃玩家 */
|
|
|
|
|
foreach ($activelist as $alv) {
|
|
|
|
|
if ($dv == $alv['time']) {
|
|
|
|
|
$activeUsers[$dv]=intval($alv['login_num']);
|
|
|
|
|
|
|
|
|
|
$data[$dv]['activeUsers']=intval($alv['login_num']);break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$data[$dv]['activeUsers']=intval($alv['login_num']);break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 充值金额 */
|
|
|
|
|
foreach ($incomelist as $ilv) {
|
|
|
|
|
if($ilv['pay_time']==$dv) {
|
|
|
|
|
$usersIncome[$dv] = round($ilv['money_amount'],2);
|
|
|
|
|
$data[$dv]['usersIncome'] = round($ilv['money_amount'],2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* 付费玩家 */
|
|
|
|
|
foreach ($paylist as $plv) {
|
|
|
|
|
if ($plv['pay_time']==$dv) {
|
|
|
|
|
$payUsers[$dv]=intval($plv['pay_num']);
|
|
|
|
|
/* 充值金额 */
|
|
|
|
|
foreach ($incomelist as $ilv) {
|
|
|
|
|
if($ilv['pay_time']==$dv) {
|
|
|
|
|
$usersIncome[$dv] = round($ilv['money_amount'],2);
|
|
|
|
|
$data[$dv]['usersIncome'] = round($ilv['money_amount'],2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* 付费玩家 */
|
|
|
|
|
foreach ($paylist as $plv) {
|
|
|
|
|
if ($plv['pay_time']==$dv) {
|
|
|
|
|
$payUsers[$dv]=intval($plv['pay_num']);
|
|
|
|
|
|
|
|
|
|
$data[$dv]['payUsers']=intval($plv['pay_num']);break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* 1日留存 */
|
|
|
|
|
foreach ($ratention1 as $r1) {
|
|
|
|
|
if ($r1['play_time'] == $dv) {
|
|
|
|
|
$rate = str_replace('.00','',$r1['retention_rate1']);
|
|
|
|
|
$data[$dv]['ratentionRate1']=$rate.'%';break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* 新付费玩家 */
|
|
|
|
|
foreach ($newspay as $npv) {
|
|
|
|
|
if ($npv['pay_time'] == $dv) {
|
|
|
|
|
$totalPayPlayer = $totalPayPlayer+intval($npv['pay_num']);
|
|
|
|
|
$data[$dv]['payUsers']=intval($plv['pay_num']);break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* 1日留存 */
|
|
|
|
|
foreach ($ratention1 as $r1) {
|
|
|
|
|
if ($r1['play_time'] == $dv) {
|
|
|
|
|
$rate = str_replace('.00','',$r1['retention_rate1']);
|
|
|
|
|
$data[$dv]['ratentionRate1']=$rate.'%';break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* 新付费玩家 */
|
|
|
|
|
foreach ($newspay as $npv) {
|
|
|
|
|
if ($npv['pay_time'] == $dv) {
|
|
|
|
|
$totalPayPlayer = $totalPayPlayer+intval($npv['pay_num']);
|
|
|
|
|
|
|
|
|
|
$data[$dv]['newPayUsers']=intval($npv['pay_num']);
|
|
|
|
|
$data[$dv]['totalPayUsers']=intval($totalPayPlayer);
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
$data[$dv]['newPayUsers']=intval($npv['pay_num']);
|
|
|
|
|
$data[$dv]['totalPayUsers']=intval($totalPayPlayer);
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
$data[$dv]['totalPayUsers']=intval($totalPayPlayer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*新付费金额*/
|
|
|
|
|
foreach ($newspaysum as $nspv) {
|
|
|
|
|
if ($nspv['pay_time'] == $dv) {
|
|
|
|
|
$data[$dv]['newPaySum']=round($nspv['pay_sum'],2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach ($activeUsers as $k1=>$ap) {
|
|
|
|
|
/* 付费率=付费玩家/活跃玩家 */
|
|
|
|
|
foreach ($payUsers as $k2 => $pp) {
|
|
|
|
|
if ($k1 === $k2 && $ap>0 && $pp>0) {
|
|
|
|
|
$payrate = sprintf("%.2f",$pp/$ap*100);
|
|
|
|
|
$data[$k1]['usersPayRate']=str_replace('.00','',$payrate).'%';
|
|
|
|
|
break;
|
|
|
|
|
} elseif ($k1 === $k2) {
|
|
|
|
|
}
|
|
|
|
|
$data[$dv]['totalPayUsers']=intval($totalPayPlayer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*新付费金额*/
|
|
|
|
|
foreach ($newspaysum as $nspv) {
|
|
|
|
|
if ($nspv['pay_time'] == $dv) {
|
|
|
|
|
$data[$dv]['newPaySum']=round($nspv['pay_sum'],2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* ARPU=当日总充值数/活跃玩家数 */
|
|
|
|
|
foreach ($usersIncome as $k2 => $ns) {
|
|
|
|
|
if ($k1 === $k2 && $ap>0 && $ns>0) {
|
|
|
|
|
$data[$k1]['usersArpu']=$ns/$ap;//str_replace('.00','',$ui);
|
|
|
|
|
break;
|
|
|
|
|
} elseif ($k1 === $k2) {
|
|
|
|
|
}
|
|
|
|
|
foreach ($activeUsers as $k1=>$ap) {
|
|
|
|
|
/* 付费率=付费玩家/活跃玩家 */
|
|
|
|
|
foreach ($payUsers as $k2 => $pp) {
|
|
|
|
|
if ($k1 === $k2 && $ap>0 && $pp>0) {
|
|
|
|
|
$payrate = sprintf("%.2f",$pp/$ap*100);
|
|
|
|
|
$data[$k1]['usersPayRate']=str_replace('.00','',$payrate).'%';
|
|
|
|
|
break;
|
|
|
|
|
} elseif ($k1 === $k2) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* ARPU=当日总充值数/活跃玩家数 */
|
|
|
|
|
foreach ($usersIncome as $k2 => $ns) {
|
|
|
|
|
if ($k1 === $k2 && $ap>0 && $ns>0) {
|
|
|
|
|
$data[$k1]['usersArpu']=$ns/$ap;//str_replace('.00','',$ui);
|
|
|
|
|
break;
|
|
|
|
|
} elseif ($k1 === $k2) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($usersIncome as $k1 => $ns) {
|
|
|
|
|
/* ARPPU=当日总充值/付费玩家数 */
|
|
|
|
|
foreach ($payUsers as $k2 => $pp) {
|
|
|
|
|
if ($k1 === $k2 && $pp>0 && $ns>0) {
|
|
|
|
|
$data[$k1]['usersArppu']=$ns/$pp;//sprintf("%d",$ns/$pp);
|
|
|
|
|
break;
|
|
|
|
|
} elseif ($k1 === $k2) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$this->assign('timeout',1);
|
|
|
|
|
}
|
|
|
|
|
foreach ($usersIncome as $k1 => $ns) {
|
|
|
|
|
/* ARPPU=当日总充值/付费玩家数 */
|
|
|
|
|
foreach ($payUsers as $k2 => $pp) {
|
|
|
|
|
if ($k1 === $k2 && $pp>0 && $ns>0) {
|
|
|
|
|
$data[$k1]['usersArppu']=$ns/$pp;//sprintf("%d",$ns/$pp);
|
|
|
|
|
break;
|
|
|
|
|
} elseif ($k1 === $k2) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//file_put_contents(dirname(__FILE__) . '/../Controller/arpu'.PID.'.txt',json_encode($data));
|
|
|
|
|
} else {
|
|
|
|
|
$this->assign('timeout',1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->assign('list_data',$data);
|
|
|
|
|
//file_put_contents(dirname(__FILE__) . '/../Controller/arpu'.PID.'.txt',json_encode($data));
|
|
|
|
|
|
|
|
|
|
$this->display();
|
|
|
|
|
$this->assign('list_data',$data);
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|