_getMysql($targetId), 't_user', array( 'account_id' => $targetId ) ); return $row ? $row : null; } public static function findByAddress($address) { $row = SqlHelper::ormSelectOne (myself()->_getMysql(''), 't_user', array( 'address' => $address ) ); return $row ? $row : null; } public static function findUserAddress($accountId) { $row = SqlHelper::ormSelectOne (myself()->_getMysql($accountId), 't_user', array( 'account_id' => $accountId ) ); return $row ? $row['address'] : null; } public static function getListByGuildId($guildId) { $rows = SqlHelper::ormSelect (myself()->_getSelfMysql(), 't_user', array( 'guild_id' => $guildId ) ); return $rows ? $rows : null; } public static function show($row) { // mt\LevelUp::getExpByLv($row['level'],$row['exp']); { $current_star_num = $row['star_num']; $currSeasonMeta = \mt\StarLevel::getCurrentSeason(); $next_star_num = mt\StarLevel::getNextNeedStarNum($current_star_num,$currSeasonMeta['id']); } $heroDb = Hero::find($row['hero_id']); $heroId = $heroDb['hero_id']; // if ($heroDb){ // $heroId = $heroDb['hero_id']; // }else{ // $heroUniId = 0; // $heroId = 0; // Hero::randHero($heroUniId,$heroId); // $heroMeta = mt\Item::get($heroId); // $headList = emptyReplace(json_decode($row['head_list'], true), array()); // if ($heroMeta['hero_head'] && !in_array($heroMeta['hero_head'],$headList)){ // array_push($headList,$heroMeta['hero_head']); // } // self::update(array( // 'hero_id' => $heroUniId, // 'head_id' => $heroMeta['hero_head'], // 'head_frame' => 60000, // 'head_list' => json_encode($headList), // 'head_frame_list' => json_encode(array(60000)), // )); // $row = myself()->_getOrmUserInfo(); // } $honorInfo = array(); if ($row['address']){ $honorInfo = UserHonor::info($row['address']); } return array( 'activated' => $row['activated'], 'rename_count' => $row['rename_count'], 'account_id' => $row['account_id'], 'address' => $row['address'], 'name' => $row['name'], 'sex' => $row['sex'], 'head_id' => $row['head_id'], 'head_frame' => $row['head_frame'], 'level' => $row['level'], 'exp' => $row['exp'], 'rank' => $row['rank'], 'history_best_rank' => $row['history_best_rank'], 'score' => $row['score'], 'history_best_score' => $row['history_best_score'], 'bceg' => cegFormat($row['bceg']), 'gold' => cegFormat($row['gold']), 'diamond' => cecFormat($row['diamond']), 'hero_uniid' => $row['hero_id'], 'hero_id' => $heroId, 'first_fight' => $row['first_fight'], 'already_guide' => $row['already_guide'], 'pve_instance_id' => $row['pve_instance_id'], 'like_count' => $row['like_count'], 'head_list' => self::getHeadList($row), // 'head_list' => self::exportHeadList($row)['head_list'], // 'hero_list' => self::exportHeadList($row)['hero_list'], 'head_frame_list' => emptyReplace(json_decode($row['head_frame_list'], true), array()), 'is_gain_item' => $row['is_gain_item'], 'guild_id' => $row['guild_id'], 'guild_job' => $row['guild_job'], 'guild_name' => $row['guild_name'], 'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute, 'parachute_list' => Parachute::getMyParachute(), 'ring_id' => $row['ring_id'], 'ring_list' => UserSeasonRing::ringList($row['account_id']), 'current_star_num' => $current_star_num, 'next_star_num' => $next_star_num, // 'status_bar' => self::_getState(), 'honor_info' => $honorInfo ); } public static function info($row) { // mt\LevelUp::getExpByLv($row['level'],$row['exp']); { $current_star_num = $row['star_num']; $currSeasonMeta = \mt\StarLevel::getCurrentSeason(); $next_star_num = mt\StarLevel::getNextNeedStarNum($current_star_num,$currSeasonMeta['id']); } $heroDb = Hero::findByAccountId($row['account_id'],$row['hero_id']); $heroId = $heroDb['hero_id']; // if ($heroDb){ // $heroId = $heroDb['hero_id']; // }else{ // $heroUniId = 0; // $heroId = 0; // Hero::randHero($heroUniId,$heroId); // $heroMeta = mt\Item::get($heroId); // $headList = emptyReplace(json_decode($row['head_list'], true), array()); // if ($heroMeta['hero_head'] && !in_array($heroMeta['hero_head'],$headList)){ // array_push($headList,$heroMeta['hero_head']); // } // self::update(array( // 'hero_id' => $heroUniId, // 'head_id' => $heroMeta['hero_head'], // 'head_frame' => 60000, // 'head_list' => json_encode($headList), // 'head_frame_list' => json_encode(array(60000)), // )); // $row = myself()->_getOrmUserInfo(); // } $honorInfo = array(); if ($row['address']){ $honorInfo = UserHonor::info($row['address']); } return array( 'activated' => $row['activated'], 'rename_count' => $row['rename_count'], 'account_id' => $row['account_id'], 'address' => $row['address'], 'name' => $row['name'], 'sex' => $row['sex'], 'head_id' => $row['head_id'], 'head_frame' => $row['head_frame'], 'level' => $row['level'], 'exp' => $row['exp'], 'rank' => $row['rank'], 'history_best_rank' => $row['history_best_rank'], 'score' => $row['score'], 'history_best_score' => $row['history_best_score'], 'bceg' => cegFormat($row['bceg']), 'gold' => cegFormat($row['gold']), 'diamond' => cecFormat($row['diamond']), 'hero_uniid' => $row['hero_id'], 'hero_id' => $heroId, 'first_fight' => $row['first_fight'], 'already_guide' => $row['already_guide'], 'head_list' => self::getHeadList($row), // 'head_list' => self::exportHeadList($row)['head_list'], // 'hero_list' => self::exportHeadList($row)['hero_list'], 'pve_instance_id' => $row['pve_instance_id'], 'like_count' => $row['like_count'], 'head_frame_list' => emptyReplace(json_decode($row['head_frame_list'], true), array()), 'is_gain_item' => $row['is_gain_item'], 'is_leader' => 0, 'guild_id' => $row['guild_id'], 'guild_job' => $row['guild_job'], 'guild_name' => $row['guild_name'], 'ring_id' => $row['ring_id'], 'ring_list' => UserSeasonRing::ringList($row['account_id']), 'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute, 'parachute_list' => Parachute::getMyParachute(), 'current_star_num' => $current_star_num, 'next_star_num' => $next_star_num, // 'status_bar' => self::_getState(), 'honor_info' => $honorInfo, 'last_login_time' => $row['last_login_time'], ); } // private static function _getState(){ // $sign_state = 0; // $signDb = SignLog::find(); //// $paramMeta = \mt\Parameter::getByName('sign_daily_duration'); //// $end_time = myself()->_getDaySeconds($signDb['createtime'])+$paramMeta['param_value']*24*60*60; // if($signDb['days'] == 7 && $signDb['is_receive'] == 1){ //// if ( myself()->_getNowTime() - $end_time > 0){ // $sign_state = 1; // } // // return array( // "first_top_up" => myself()->_getV(TN_FIRST_TUPOP_STATUS,0), // "sign_day" => $sign_state // ); // } public static function toSimple($row) { // mt\LevelUp::getExpByLv($row['level'],$row['exp']); $heroDb = Hero::find($row['hero_id']); if ($heroDb){ $heroId = $heroDb['hero_id']; }else{ $heroUniId = 0; $heroId = 0; Hero::randHero($heroUniId,$heroId); self::update(array( 'hero_id' => $heroUniId )); } return array( 'account_id' => $row['account_id'], 'address' => $row['address'], 'name' => $row['name'], 'sex' => $row['sex'], 'head_id' => $row['head_id'], 'head_frame' => $row['head_frame'], 'level' => $row['level'], 'exp' => $row['exp'], 'rank' => $row['rank'], 'score' => $row['score'], 'gold' => cegFormat($row['gold']), 'diamond' => cecFormat($row['diamond']), 'hero_id' => $heroId, 'pve_instance_id' => $row['pve_instance_id'], 'like_count' => $row['like_count'], 'first_fight' => $row['first_fight'], ); } public static function toPreset($row){ // mt\LevelUp::getExpByLv($row['level'],$row['exp']); $heroDb = Hero::find($row['hero_id']); $heroId = 0; if ($heroDb){ $heroId = $heroDb['hero_id']; } $preset = HeroPreset::getHeroPreset($row['hero_id']); $skinDb = HeroSkin::findBx($heroId); $honorInfo = array(); if ($row['address']){ $honorInfo = UserHonor::info($row['address']); } return array( 'account_id' => $row['account_id'], 'address' => $row['address'], 'name' => $row['name'], 'sex' => $row['sex'], 'head_id' => $row['head_id'], 'head_frame' => $row['head_frame'], 'level' => $row['level'], 'exp' => $row['exp'], 'rank' => $row['rank'], 'score' => $row['score'], // 'gold' => cegFormat($row['gold']), // 'diamond' => cecFormat($row['diamond']), 'pve_instance_id' => $row['pve_instance_id'], // 'like_count' => $row['like_count'], 'first_fight' => $row['first_fight'], 'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute, 'hero_uniId' => $row['hero_id'], 'hero_id' => $heroId, 'hero_skin' =>$skinDb['skin_id'], 'hero_lv' =>$heroDb['hero_lv'], 'presetInfo' => $preset, 'is_leader' => 0, 'is_ready' => 0, 'permission' => 0, 'honor_info' => $honorInfo, ); } public static function isValidHeadId($userInfo, $headId) { // $headList = emptyReplace(json_decode($userInfo['head_list'], true), array()); $headList = self::getHeadList($userInfo); return in_array($headId, $headList); } public static function isValidHeroId($userInfo, $heroId) { $heroDb = Hero::findByAccountId($userInfo['account_id'],$heroId); return empty($heroDb) ? false : true ; } public static function isValidHeadFrame($userInfo, $headFrame) { $headFrameList = emptyReplace(json_decode($userInfo['head_frame_list'], true), array()); return in_array($headFrame, $headFrameList); } public static function isValidParachute($parachute){ $parachuteList = Parachute::getMyParachute(); return in_array($parachute, $parachuteList); } public static function isValidRing($parachute){ $ringList = UserSeasonRing::ringList(myself()->_getAccountId()); return in_array($parachute, $ringList); } private static function getHeadList($userInfo) { $headList = emptyReplace(json_decode($userInfo['head_list'], true), array()); $rows = array(); Hero::getHeroList(function ($row) use (&$rows){ array_push($rows,$row); }); foreach ($rows as $row) { $itemMeta = mt\Item::get($row['hero_id']); if ($itemMeta && $itemMeta['hero_head'] && !in_array($itemMeta['hero_head'],$headList)) { array_push($headList, $itemMeta['hero_head']); } } return $headList; } public static function update( $fieldsKv){ SqlHelper::update (myself()->_getSelfMysql(), 't_user', array( 'account_id' => myself()->_getAccountId(), ), $fieldsKv ); } public static function updateOther($accountId, $fieldsKv){ SqlHelper::update (myself()->_getMysql($accountId), 't_user', array( 'account_id' => $accountId, ), $fieldsKv ); } public static function updateLikeCount($targetId){ SqlHelper::update (myself()->_getSelfMysql(), 't_user', array( 'account_id' => $targetId, ), array( 'like_count' => function(){ return "like_count + 1"; } ) ); } public static function getUserByRankMess($row){ // $currSeasonMeta = mt\RankSeason::getCurrentSeason(); // $gameTimes = 0; // if ($currSeasonMeta){ // $season = Season::findByAccount($row['account_id'],$currSeasonMeta['id']); // if ($season){ // $battleData = json_decode($season['battle_data'], true); // $seasonBattleData = isset($battleData) ? getXVal($battleData, 'season_data', array()) : array(); // $gameTimes = getXVal($seasonBattleData, 'total_battle_times', 0); // } // } $toDto =array( 'idx' => $row['idx'], 'account_id' => $row['account_id'], 'channel' => $row['channel'], 'name' => $row['name'], 'head_id' => $row['head_id'], 'head_frame' => $row['head_frame'], 'rank' => $row['rank'], // 'history_best_rank' => $row['history_best_rank'], 'score' => $row['score'], // 'history_best_score' => $row['history_best_score'], //排位场数 // 'rank_num' => $gameTimes, ); return $toDto; } public static function getListByRank($rank){ $field = "idx,account_id,channel,name,head_id,head_frame,rank,score"; $sql = "select {$field} from t_user where rank=:rank order by score desc,score_modifytime asc limit 20 "; $whereKv = array( "rank" => $rank, ); $rows = myself()->_getSelfMysql()->execQuery($sql,$whereKv); if (!$rows){ $rows = array(); } return $rows; } public static function getKingCount($starshine){ $sql = "select count(*) as `count` from t_user where score>:score "; $whereKv = array( "score" => $starshine, ); $count = myself()->_getSelfMysql()->execQueryOne($sql,$whereKv); return $count?$count['count']:0; } }