From 4fef5971ca63d91d0e8f8d81cfb89129bd74b6d2 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Fri, 31 May 2024 11:40:19 +0800 Subject: [PATCH] 1 --- doc/BattleHistory.py | 16 +++ webapp/controller/BattleController.class.php | 110 ++++++++++++++---- .../BattleHistoryController.class.php | 40 ++++++- webapp/models/BattleSettlement.php | 12 ++ 4 files changed, 157 insertions(+), 21 deletions(-) diff --git a/doc/BattleHistory.py b/doc/BattleHistory.py index 7954db89..36c6275a 100644 --- a/doc/BattleHistory.py +++ b/doc/BattleHistory.py @@ -20,6 +20,22 @@ class BattleHistory(object): _common.RspHead(), ['!data', [BattleSettlementInfo()], '战绩数据'], ] + },{ + 'method': 'GET', + 'name': 'showBattleHistory', + 'desc': '战绩详情', + 'group': 'Battle', + 'url': 'webapp/index.php?c=BattleHistory&a=showBattleHistory', + 'params': [ + _common.ReqHead(), + ['target_id', '', ' target_id'], + ['battle_uuid', '', ' 战斗唯一id'], + ['room_uuid', '', ' 房间唯一id'] + ], + 'response': [ + _common.RspHead(), + ['!info', [_common.BattleSettlement()], '战绩详情'], + ] }, ] diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index bc1aaf4e..16157a4c 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -127,9 +127,8 @@ class BattleController extends BaseAuthedController { )); } - public function teamReport() - { - error_log('teamReport'); + public function mobaReport(){ + error_log('mobaReport'); $userInfo = $this->_getOrmUserInfo(); if (!$userInfo) { $this->_rspErr(1, 'Without this player1'); @@ -137,8 +136,16 @@ class BattleController extends BaseAuthedController { } $data = json_decode(file_get_contents('php://input'), true); error_log(json_encode($data)); - $battle_uuid = getXVal($data,'battle_uuid', 0); - $room_uuid = getXVal($data,'room_uuid', 0); + foreach ($data as $teamData){ + $this->_handleTeamReport($teamData); + } + + $this->_rspOk(); + } + + private function _handleTeamReport($teamData){ + $battle_uuid = getXVal($teamData,'battle_uuid', 0); + $room_uuid = getXVal($teamData,'room_uuid', 0); $battleSettlementDb = BattleSettlement::findTeam($battle_uuid,$room_uuid); if ($battleSettlementDb){ $this->_rspErr(1, 'Repeated request'); @@ -152,29 +159,27 @@ class BattleController extends BaseAuthedController { 'room_uuid' => $room_uuid, ), array( - 'input' => json_encode($data) + 'input' => json_encode($teamData) ), array( 'battle_uuid' => $battle_uuid, 'room_uuid' => $room_uuid, - 'input' => json_encode($data), + 'input' => json_encode($teamData), 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), ) ); $teamList = array(); - if ($data) { - $teamList = $data['team_list']; + if ($teamData) { + $teamList = $teamData['team_list']; } $teamBattleDataService = new services\TameBattleDataService(); - $teamBattleDataService->allInfo = $data; + $teamBattleDataService->allInfo = $teamData; $teamBattleDataService->teamList = $teamList; - $teamBattleDataService->teamInfo = isset($data['members']) ? $data['members'] : array(); - - + $teamBattleDataService->teamInfo = isset($teamData['members']) ? $teamData['members'] : array(); $teamBattleDataService->addBattleSettlementTeam(); - foreach ($data['members'] as $member){ - $member['pvp_team_rank'] = getXVal($data,'pvp_team_rank', 0); + foreach ($teamData['members'] as $member){ + $member['pvp_team_rank'] = getXVal($teamData,'pvp_team_rank', 0); if ($member['account_id'] && !myself()->_isAndroidAccountId($member['account_id'])){ $this->switchAccount($member['account_id']); $teamBattleDataService->battleInfo = $member; @@ -191,14 +196,79 @@ class BattleController extends BaseAuthedController { ) ); } - } - $this->switchAccount(getReqVal('account_id', 0)); -// $data = array( -// 'reward' => $teamBattleDataService->getTeamReward() + } + + public function teamReport() + { + error_log('teamReport'); + $userInfo = $this->_getOrmUserInfo(); + if (!$userInfo) { + $this->_rspErr(1, 'Without this player1'); + return; + } + $data = json_decode(file_get_contents('php://input'), true); + error_log(json_encode($data)); + $this->_handleTeamReport($data); +// $battle_uuid = getXVal($data,'battle_uuid', 0); +// $room_uuid = getXVal($data,'room_uuid', 0); +// $battleSettlementDb = BattleSettlement::findTeam($battle_uuid,$room_uuid); +// if ($battleSettlementDb){ +// $this->_rspErr(1, 'Repeated request'); +// return; +// } +// SqlHelper::upsert +// (myself()->_getSelfMysql(), +// 't_battle_input', +// array( +// 'battle_uuid' => $battle_uuid, +// 'room_uuid' => $room_uuid, +// ), +// array( +// 'input' => json_encode($data) +// ), +// array( +// 'battle_uuid' => $battle_uuid, +// 'room_uuid' => $room_uuid, +// 'input' => json_encode($data), +// 'createtime' => myself()->_getNowTime(), +// 'modifytime' => myself()->_getNowTime(), +// ) // ); -// $this->_rspData($data); +// $teamList = array(); +// if ($data) { +// $teamList = $data['team_list']; +// } +// $teamBattleDataService = new services\TameBattleDataService(); +// $teamBattleDataService->allInfo = $data; +// $teamBattleDataService->teamList = $teamList; +// $teamBattleDataService->teamInfo = isset($data['members']) ? $data['members'] : array(); +// +// +// $teamBattleDataService->addBattleSettlementTeam(); +// foreach ($data['members'] as $member){ +// $member['pvp_team_rank'] = getXVal($data,'pvp_team_rank', 0); +// if ($member['account_id'] && !myself()->_isAndroidAccountId($member['account_id'])){ +// $this->switchAccount($member['account_id']); +// $teamBattleDataService->battleInfo = $member; +// $teamBattleDataService->updateBattleData(); +// $teamBattleDataService->addBattleSettlementSingle(); +// SqlHelper::insert( +// $this->_getSelfMysql(), +// 't_battle_record', +// array( +// 'account_id' => $this->_getAccountId(), +// 'request' => json_encode($member), +// 'createtime' => $this->_getNowTime(), +// 'modifytime' => $this->_getNowTime(), +// ) +// ); +// } +// +// } +// +// $this->switchAccount(getReqVal('account_id', 0)); $this->_rspOk(); } diff --git a/webapp/controller/BattleHistoryController.class.php b/webapp/controller/BattleHistoryController.class.php index dd6c8a6f..51396112 100644 --- a/webapp/controller/BattleHistoryController.class.php +++ b/webapp/controller/BattleHistoryController.class.php @@ -2,7 +2,7 @@ require_once('models/BattleSettlement.php'); require_once('models/BattleHistory.php'); - +require_once('services/TameBattleDataService.php'); use models\BattleSettlement; use models\BattleHistory; @@ -27,4 +27,42 @@ class BattleHistoryController extends BaseAuthedController { )); } + public function showBattleHistory(){ + $accountId = getReqVal('target_id', ''); + $battleUuid = getReqVal('battle_uuid', 0); + $roomUuid = getReqVal('room_uuid', 0); + if ( !$battleUuid){ + $this->_rspErr(1,'param battle_uuid error'); + return; + } + if ( !$roomUuid){ + $this->_rspErr(1,'param room_uuid error'); + return; + } + $teamBattleDb= BattleSettlement::findTeamByTargetId($accountId,$battleUuid,$roomUuid); + if (!$teamBattleDb){ + $this->_rspErr(1,'param error'); + return; + } + $data = json_decode($teamBattleDb['data'],true); + $room_mode = getXVal($data,'room_mode', 0); + $list = array($data); + if ($room_mode == \services\TameBattleDataService::ROOM_MODE_MOBA){ + $rows = BattleSettlement::findTeamByRoomUuid($accountId,$roomUuid); + foreach ($rows as $row){ + if ($battleUuid != $row['battle_uuid']){ + array_push($list,json_decode($row['data'],true)); + } + } + } + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addUserChg(); + $this->_rspData( + array( + 'info'=>$list, + 'property_chg' => $propertyChgService->toDto(), + ) + ); + } + } diff --git a/webapp/models/BattleSettlement.php b/webapp/models/BattleSettlement.php index 0149670a..6e4b3eb3 100644 --- a/webapp/models/BattleSettlement.php +++ b/webapp/models/BattleSettlement.php @@ -174,5 +174,17 @@ class BattleSettlement extends BaseModel return $row; } + public static function findTeamByRoomUuid($targetId, $roomUuid) + { + $rows = SqlHelper::ormSelect + (myself()->_getMysql($targetId), + 't_battle_settlement_team', + array( + 'room_uuid' => $roomUuid, + ) + ); + return $rows; + } + }