后台-》统计-》流失分析优化

master
“用lww 5 years ago
parent 75e2eda083
commit 2eadac6b53

@ -266,8 +266,8 @@ class StatController extends ThinkController
}
$players = $usermodel->getUserList($map, "GROUP_CONCAT(DISTINCT id) as user_ids,
FROM_UNIXTIME(register_time+{$continueDay}*86400, '%Y-%m-%d') as register_date", "register_date");
$players = array_column($players, 'user_ids', 'register_date');
$players = array_column($players, 'user_ids', 'register_date');
//获取这段时间内有登录(未流失)的玩家
$map1['r.login_time'] = array('exp', 'BETWEEN UNIX_TIMESTAMP(
FROM_UNIXTIME(
@ -286,7 +286,7 @@ AND UNIX_TIMESTAMP(
$map1['u.promote_id']=$para['promote_id'];
}
$map1['u.register_time'] = array('between',array($start, $end));
$keepPlayers = $usermodel->getKeepPlayers($map1, $continueDay);// 3或7天内有登录的玩家
$keepPlayers = $usermodel->getKeepPlayers($map1, $continueDay, count($days) > 5);// 3或7天内有登录的玩家
$keepPlayers = array_column($keepPlayers, 'user_ids', 'register_date');
$loss_count = array();//流失玩家数量

@ -2089,13 +2089,17 @@ class UserModel extends Model{
* 获取未流失的玩家
* @param $day int 几天算玩家流失
*/
public function getKeepPlayers($map = '', $day)
public function getKeepPlayers($map = '', $day, $falseIndex = false)
{
$map['lpuid']=0;
$data = M('user_login_record','tab_')
$join = "right join tab_user as u on r.user_id = u.id";
if ($falseIndex) {//日期范围大于5天使用强制索引
$join = "FORCE INDEX (PRIMARY) " . $join;
}
$data = $this->table("tab_user_login_record")
->alias("r")
->field("GROUP_CONCAT(DISTINCT u.id) as user_ids,FROM_UNIXTIME(u.register_time+{$day}*86400, '%Y-%m-%d') as register_date")
->join("right join tab_user as u on r.user_id = u.id")
->join($join)
->group("register_date")
->where($map)
->select();

Loading…
Cancel
Save