diff --git a/addons/shopro/controller/zy/Game.php b/addons/shopro/controller/zy/Game.php index 2d14363..29ea5f4 100644 --- a/addons/shopro/controller/zy/Game.php +++ b/addons/shopro/controller/zy/Game.php @@ -440,7 +440,34 @@ class Game extends Base $this->error('比赛不存在'); } $match = GameMatch::field('*,GREATEST(scoreA,scoreB) as score')->where('game_id', $game['id'])->order(['level' => 'desc', 'score' => 'desc'])->select(); - $this->success('Success', $match); + $teams = []; + $rank = 1; + foreach ($match as $m) { + $win = json_decode($m['winner'] ?? '', true); + if (empty($win)) { // 未决出胜负的按暂时得分 高的队伍排名靠前 + $teamA = json_decode($m['teamA'] ?? '', true); + $teamB = json_decode($m['teamB'] ?? '', true); + if (($m['scoreA'] >= $m['scoreB'])) { + $teamA['rank'] = $rank; + $teamB['rank'] = $rank + 1; + $teams[] = $teamA; + $teams[] = $teamB; + $rank += 2; + } else { + $teamB['rank'] = $rank; + $teamA['rank'] = $rank + 1; + $teams[] = $teamB; + $teams[] = $teamA; + $rank += 2; + } + } else { + $win['rank'] = $rank; + $rank++; + $teams[] = $win; + } + } + + $this->success('Success', $teams); } // 个人排名 @@ -452,7 +479,7 @@ class Game extends Base $this->error('比赛不存在'); } - $list = Participant::where('game_id', $game['id'])->order('score', 'desc')->select(); + $list = Participant::where('game_id', $game['id'])->where('status', '>', -1)->order('score', 'desc')->select(); $rank = 1; foreach ($list as &$l) { $l['rank'] = $rank;