This commit is contained in:
hujiabin 2022-10-10 16:33:22 +08:00
parent 4d0b73ff0d
commit 19b7b31865
2 changed files with 6 additions and 7 deletions

View File

@ -162,17 +162,15 @@ class BattleController extends BaseAuthedController {
public function getBattleHistory(){ public function getBattleHistory(){
$mode = getReqVal('mode', 0); $mode = getReqVal('mode', 0);
$historyList = BattleHistory::getMyBattleHistory(); $historyList = BattleHistory::orderBy(BattleHistory::getMyBattleHistoryByMode($mode),'desc');
$data = array(); $data = array();
foreach ($historyList as $history){ foreach ($historyList as $k=>$history){
if ($history['match_mode'] == $mode){ if ($k < 20){
array_push($data,BattleHistory::toDto($history)); array_push($data,BattleHistory::toDto($history));
} }
} }
$list = BattleHistory::orderBy($data,'desc');
$this->_rspData(array( $this->_rspData(array(
'data' => $list 'data' => $data
)); ));
} }
} }

View File

@ -21,13 +21,14 @@ class BattleHistory extends BaseModel
); );
} }
public static function getMyBattleHistory() public static function getMyBattleHistoryByMode($mode)
{ {
$row = SqlHelper::ormSelect( $row = SqlHelper::ormSelect(
myself()->_getSelfMysql(), myself()->_getSelfMysql(),
't_battle_history', 't_battle_history',
array( array(
'account_id' => myself()->_getAccountId(), 'account_id' => myself()->_getAccountId(),
'match_mode' => $mode,
) )
); );
return $row; return $row;