public function get_manor_players($union_id, $goal_num = 0, $is_cache = true) { if ($is_cache) { $data = $this->redis()->get($this->_cacheShortManorKeyPrefix . ':' . $union_id); if ($data) { $manor_info = json_decode($data, true); return $manor_info; } } if (!$goal_num) { $grab_domain_conf = Cache_UnionGrabDomain::getInstance()->get_base_conf(); $goal_num = $grab_domain_conf['goal_num']; } $union_info = $this->get_data('UnionPlayer')->get_union_player_info($union_id); $count = count($union_info); $manor_info = array(); if (0 == $count) { //pass } else { $players = array(); $s_fpower = $s_level = array(); foreach ($union_info as $player_id => $info) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('player_id', 'level', 'sum_fpower')); $players[] = $player_info; $s_fpower[] = $player_info['sum_fpower']; $s_level[] = $player_info['level']; } array_multisort($s_fpower, SORT_DESC, $s_level, SORT_DESC, $players); $i = 1; foreach ($players as $player) { $manor_info[] = $player['player_id']; if ($i >= $goal_num) { break; } $i++; } } $this->redis()->set($this->_cacheShortManorKeyPrefix . ':' . $union_id, json_encode($manor_info), 300); return $manor_info; }
public function get_union_num() { $grab_domain_conf = Cache_UnionGrabDomain::getInstance()->get_base_conf(); $week = $this->get_game('UnionGrabDomain')->get_week(); $week_end = $grab_domain_conf['week_end']; $time = time(); $time = $this->get_data('UnionGrabDomain')->get_revise_time($time); if ($week > $week_end) { $day = date('Ymd', $time - ($week - $week_end) * 86400); } else { $day = date('Ymd', $time); } $num = 0; $grab_domain_info = $this->get_data('UnionGrabDomain')->get_domain_info($day); if ($grab_domain_info) { $num = $grab_domain_info['num']; } /*else{ $total_num = $this->get_data('UnionInfo')->get_union_info_count(); if($total_num >= $grab_domain_conf['union_rank_top']){ $num = $grab_domain_conf['union_rank_top']; }else{ if($total_num<2){ $num = 0; }else{ if($total_num%2){ $num = $total_num-1; }else{ $num = $total_num; } } } }*/ return $num; }