From 2a1cec79094633f0ac403e19ebd94ab04588ad6f Mon Sep 17 00:00:00 2001 From: xiadc <251308692@qq.com> Date: Sat, 31 May 2025 20:10:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(shopro):=20=E4=BF=AE=E5=A4=8D=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E5=95=86=E5=93=81=E4=BB=B7=E6=A0=BC=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 Activity 控制器中的 original_price 字段赋值从 price 改为 cost - 在 Game 控制器中添加团队排名和个人排名接口 --- addons/shopro/controller/zy/Activity.php | 2 +- addons/shopro/controller/zy/Game.php | 32 +++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/addons/shopro/controller/zy/Activity.php b/addons/shopro/controller/zy/Activity.php index 9b43f9e..53b8c07 100644 --- a/addons/shopro/controller/zy/Activity.php +++ b/addons/shopro/controller/zy/Activity.php @@ -103,7 +103,7 @@ class Activity extends Base $goods->dispatch_type = 'autosend'; $goods->dispatch_id = 2; $goods->is_sku = 0; - $goods->original_price = $params['price'][$key]; + $goods->original_price = $params['cost'][$key]; $goods->price = $params['cost'][$key]; $goods->save(); $this->zySku($goods, 'add'); diff --git a/addons/shopro/controller/zy/Game.php b/addons/shopro/controller/zy/Game.php index a242d07..f3f4e14 100644 --- a/addons/shopro/controller/zy/Game.php +++ b/addons/shopro/controller/zy/Game.php @@ -378,7 +378,6 @@ class Game extends Base $u->save(); } $undone = GameMatch::where('level', $match['level'])->where('winner', null)->count(); - df($undone); if ($undone == 0) { //所有比赛完成,开启下一轮比赛 $gameClass = 'format\\Game' . $game['team_type'] . $game['rule_type']; if (!class_exists($gameClass)) { @@ -402,4 +401,35 @@ class Game extends Base $this->success('Success'); } + + // 团队排名 + public function teamRank() + { + $params = $this->request->param(); + $game = $this->model->get($params['game_id']) ?? null; + if (empty($game)) { + $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); + } + + // 个人排名 + public function rank() + { + $params = $this->request->param(); + $game = $this->model->get($params['game_id']) ?? null; + if (empty($game)) { + $this->error('比赛不存在'); + } + + $list = Participant::where('game_id', $game['id'])->order('score', 'desc')->select(); + $rank = 1; + foreach ($list as &$l) { + $l['rank'] = $rank; + $rank += 1; + } + + $this->success('Success', $list); + } }