0) { $tmap['fgame_id'] = $map['up.game_id'] = $gameId; } if ($serverId > 0) { $tmap['fgame_id'] = $map['up.game_id'] = $serverId; } $tmap['promote_id'] = $map['tab_user.promote_id'] = ['in', $ids]; $union = M('user', 'tab_')->field('FROM_UNIXTIME(register_time,"%Y-%m-%d") as time,GROUP_CONCAT(DISTINCT id) as user_id') ->where($tmap)->group('time')->select(false); $sql = M('user', 'tab_')->field('FROM_UNIXTIME(up.login_time,"%Y-%m-%d") as time,GROUP_CONCAT(DISTINCT up.user_id) as user_id') ->join('tab_user_login_record up on up.user_id=tab_user.id','inner') ->union($union) ->where($map)->group('time')->select(false); $lists = M()->table('('.$sql.') as a')->field('a.time,GROUP_CONCAT(a.user_id) as user_id')->group('a.time')->select(); $data = []; foreach($lists as $k => $v) { $login = array_unique(explode(',', $v['user_id'])); $data[$k] = [ 'time' => $v['time'], 'login_num' => count($login), ]; } return $data; } }