_getOrmUserInfo(); if (!$userInfo) { $this->_rspErr(1, '没有这个玩家1'); return; } $this->updateUserBaseInfo($userInfo); $this->updateSeason($userInfo); $this->updateMission($userInfo); $this->_rspOk(); } private function updateUserBaseInfo($userInfo) { $fieldsKv = array( 'total_battle_times' => function () { return 'total_battle_times + 1'; }, ); if (getReqVal('rank', 0) == 1) { $fieldsKv['total_win_times'] = function () { return 'total_win_times + 1'; }; } $kills = getReqVal('kills', 0); if ($kills > 0) { $fieldsKv['total_kills_times'] = function () { return "total_kills_times + ${kills}"; }; $fieldsKv['max_kills_times'] = function () { return "GREATEST(max_kills_times, ${kills})"; }; } $damageOut = getReqVal('damage_out', 0); if ($damageOut > 0) { $fieldsKv['total_damage_out'] = function () { return "total_damage_out + ${damageOut}"; }; $fieldsKv['max_damage_out'] = function () { return "GREATEST(max_damage_out, ${damageOut})"; }; } $damageIn = getReqVal('damage_in', 0); if ($damageIn > 0) { $fieldsKv['total_damage_in'] = function () { return "total_damage_in + ${damageIn}"; }; } $recoverHp = getReqVal('recover_hp', 0); if ($recoverHp > 0) { $fieldsKv['total_recover_hp'] = function () { return "total_recover_hp + ${recoverHp}"; }; $fieldsKv['max_recover_hp'] = function () { return "GREATEST(max_recover_hp, ${recoverHp})"; }; } $aliveTime = getReqVal('alive_time', 0); if ($aliveTime > 0) { $fieldsKv['total_alive_time'] = function () { return "total_alive_time + ${aliveTime}"; }; $fieldsKv['max_alive_time'] = function () { return "GREATEST(max_alive_time, ${aliveTime})"; }; } if (count($fieldsKv) > 0) { $this->_updateUserInfo($fieldsKv); } } private function updateSeason($userInfo) { $fieldsKv = array( 'total_battle_times' => function () { return 'total_battle_times + 1'; }, ); if (getReqVal('rank', 0) == 1) { $fieldsKv['total_win_times'] = function () { return 'total_win_times + 1'; }; } $kills = getReqVal('kills', 0); if ($kills > 0) { $fieldsKv['total_kills_times'] = function () { return "total_kills_times + ${kills}"; }; $fieldsKv['max_kills_times'] = function () { return "GREATEST(max_kills_times, ${kills})"; }; } $damageOut = getReqVal('damage_out', 0); if ($damageOut > 0) { $fieldsKv['total_damage_out'] = function () { return "total_damage_out + ${damageOut}"; }; $fieldsKv['max_damage_out'] = function () { return "GREATEST(max_damage_out, ${damageOut})"; }; } $damageIn = getReqVal('damage_in', 0); if ($damageIn > 0) { $fieldsKv['total_damage_in'] = function () { return "total_damage_in + ${damageIn}"; }; } $recoverHp = getReqVal('recover_hp', 0); if ($recoverHp > 0) { $fieldsKv['total_recover_hp'] = function () { return "total_recover_hp + ${recoverHp}"; }; $fieldsKv['max_recover_hp'] = function () { return "GREATEST(max_recover_hp, ${recoverHp})"; }; } $aliveTime = getReqVal('alive_time', 0); if ($aliveTime > 0) { $fieldsKv['total_alive_time'] = function () { return "total_alive_time + ${aliveTime}"; }; $fieldsKv['max_alive_time'] = function () { return "GREATEST(max_alive_time, ${aliveTime})"; }; } $currSeasonMeta = mt\Season::getCurrentSeason(); if ($currSeasonMeta && count($fieldsKv) > 0) { $seasonService = new services\SeasonService(); if (!$seasonService->checkSeason($userInfo)) { $userInfo = $this->_safeGetOrmUserInfo(); } $seasonDb = Season::find($currSeasonMeta['id']); if (!$seasonDb) { Season::add($currSeasonMeta['id']); $seasonDb = Season::find($currSeasonMeta['id']); } Season::update($fieldsKv); } } private function updateMission($userInfo) { } private function old() { //更新击杀信息时间 $k = 0; if ($userInfo['game_times'] != 0) { $k = $userInfo['kill_his'] / $userInfo['game_times']; } if (($userInfo['kill_his'] + $kills) / ($userInfo['game_times'] + 1) != $k) { $this->_updateUserInfo(array( 'kill_modifytime' => $this->_getNowTime(), )); } //更新胜场信息时间 if ($rank == 1) { $this->_updateUserInfo(array( 'win_times' => $userInfo['win_times'] + 1, 'season_win' => $userInfo['season_win'] + 1, 'win_modifytime' => $this->_getNowTime(), )); } //更新排位积分信息时间 if ($integral > 0) { $update_maxscore = $integral + $userInfo['max_integral']; $update_score = $integral + $userInfo['integral']; $isProtect = false; $minScore = 0; mt\SeasonPoint::calcScore($intergral, $isProtect, $minScore); if ($isProtect && $minScore > $updateScore) { $update_score = $minScore; } $this->_updateUserInfo(array( 'integral' => $update_score, 'rank_modifytime' => $this->_getNowTime(), 'max_integral' => $update_maxscore, )); } //更新历史最高信息 $kill_his = max($kill_his, $userInfo['kill_his']); $harm_his = max($harm_his, $userInfo['harm_his']); $sea_max_hart = max($harm, $userInfo['sea_max_hart']); $sea_max_kill = max($kills, $userInfo['sea_max_kill']); $alive_time_his = max($alive_time_his, $userInfo['alive_time_his']); $add_HP_his = max($add_HP_his, $userInfo['add_HP_his']); //添加空投箱 $box_num = min($userInfo['box_num'] + 1, 20); $newhand = $userInfo['newhand']; $newhand2 = $userInfo['newhand2']; $game_times2 = $userInfo['game_times2']; { $fight_times = mt\Parameter::getByName('newhand_num1')['param_value']; $view_times = mt\Parameter::getByName('newhand_num2')['param_value']; $fight_times2 = mt\Parameter::getByName('cream_task_01')['param_value']; $view_times2 = mt\Parameter::getByName('cream_task_02')['param_value']; if ($userInfo['game_times'] + 1 == $fight_times && $userInfo['vip_score'] >= $view_times) { $newhand = 1; } if ($newhand == 2) { if ($userInfo['game_times2'] + 1 == $fight_times2 && $userInfo['view_times2'] >= $view_times2) { $newhand2 = 1; } $game_times2++; } } $this->_updateUserInfo(array( 'game_times' => function () { return 'game_times + 1'; }, 'kill_his' => $kill_his, 'kills' => function () use($kills) { return "kills + ${kills}"; }, 'harm_his' => $harm_his, 'harm' => function () use($harm) { return "harm + ${harm}"; }, 'add_HP' => function () use($add_HP) { return "add_HP + ${add_HP}"; }, 'alive_time' => function () use($alive_time) { return "alive_time + ${alive_time}"; }, 'alive_time_his' => $alive_time_his, 'add_HP_his' => $add_HP_his, 'coin_num' => function () use($coin_num) { return "coin_num + ${coin_num}"; }, 'modify_time' => $this->_getNowTime(), 'box_num' => $box_num, 'score' => function () { return 'score'; //?? }, 'daily_time' => function () use($nowDaySeconds) { return 'GREATEST(daily_time, ${nowDaySeconds})'; }, 'season_games' => function () { return 'season_games + 1'; }, 'sea_max_kill' => $sea_max_kill, 'sea_max_hart' => $sea_max_hart, 'sea_avg_kill' => function () use($kills) { return "sea_avg_kill + ${kills}"; //?? }, 'first_fight' => 1, )); echo json_encode(array( 'errcode' => 0, 'errmsg' => '', )); } }