diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index e4652913..9a61ae82 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -252,9 +252,66 @@ class BattleController extends BaseAuthedController { } } $this->switchAccount(getReqVal('account_id', 0)); + $this->updateRecentBattle($input['team_list']); $this->_rspOk(); } + private function updateRecentBattle($teamList) + { + $realPlayerHash = array(); + $realPlayerHashCopy = array(); + foreach ($teamList as $team) { + foreach ($team['members'] as $member) { + if (!myself()->_isAndroidAccountId($member['account_id'])) { + $realPlayerHash[$member['account_id']] = 1; + $realPlayerHashCopy[$member['account_id']] = 1; + } + } + } + error_log(json_encode($realPlayerHash)); + $accountIdPair = array(); + foreach ($realPlayerHash as $accountId => $val) { + foreach ($realPlayerHashCopy as $accountIdCopy => $valCopy) { + if ($accountId != $accountIdCopy) { + $accountId1 = $accountId; + $accountId2 = $accountIdCopy; + if ($accountId > $accountIdCopy) { + $accountId1 = $accountIdCopy; + $accountId2 = $accountId; + } + $key = $accountId . '|' . $accountId2; + if (!array_key_exists($key, $accountIdPair)) { + $accountIdPair[$key] = array($accountId1, $accountId2); + } + } + } + } + error_log(json_encode($accountIdPair)); + $nowTime = myself()->_getNowTime(); + foreach ($accountIdPair as $pair) { + $accountId1 = $pair[0]; + $accountId2 = $pair[1]; + SqlHelper::Upsert( + myself()->_getRelationDbMysql(), + 't_recent_battle', + array( + 'account_id1' => $accountId1, + 'account_id2' => $accountId2, + ), + array( + 'last_battle_time' => $nowTime, + ), + array( + 'account_id1' => $accountId1, + 'account_id2' => $accountId2, + 'last_battle_time' => $nowTime, + 'createtime' => $nowTime, + 'modifytime' => $nowTime, + ) + ); + } + } + /* http post php://input diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index f0ff03dc..9dd43bc0 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -457,8 +457,10 @@ class UserController extends BaseAuthedController { public function getMapConf() { + $modeId = getReqVal('mode_id', 0); $mapId = getReqVal('map_id', 0); $mapInfo = array( + 'mode_id' => $modeId, 'map_id' => 0, 'is_moba' => 0, 'is_open' => 0 @@ -474,8 +476,10 @@ class UserController extends BaseAuthedController { public function getBattleInfo() { + $modeId = getReqVal('mode_id', 0); $mapId = getReqVal('map_id', 0); $mapInfo = array( + 'mode_id' => $modeId, 'map_id' => 0, 'is_moba' => 0, 'is_open' => 0