From 316506b5973d56ea92b766cd4c22919b8823ce5d Mon Sep 17 00:00:00 2001 From: zhenhui <1276357500@qq.com> Date: Sat, 7 Mar 2026 11:58:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=8E=A9=E5=AE=B6DicePlayer?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E7=9A=84lottery=5Fconfig=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app/api/logic/UserLogic.php | 3 +++ server/app/dice/model/player/DicePlayer.php | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/server/app/api/logic/UserLogic.php b/server/app/api/logic/UserLogic.php index 7aadafd..46c4cc9 100644 --- a/server/app/api/logic/UserLogic.php +++ b/server/app/api/logic/UserLogic.php @@ -55,6 +55,9 @@ class UserLogic $player = DicePlayer::where('username', $username)->find(); if ($player) { + if ((int) ($player->status ?? 1) === 0) { + throw new ApiException('账号已被禁用,无法登录'); + } $hashed = $this->hashPassword($password); if ($player->password !== $hashed) { throw new ApiException('密码错误'); diff --git a/server/app/dice/model/player/DicePlayer.php b/server/app/dice/model/player/DicePlayer.php index bb4e80c..d9c2ae3 100644 --- a/server/app/dice/model/player/DicePlayer.php +++ b/server/app/dice/model/player/DicePlayer.php @@ -77,6 +77,16 @@ class DicePlayer extends BaseModel if ($name === null || $name === '') { $model->setAttr('name', $uid); } + // 创建玩家时:未指定则自动保存 lottery_config_id 为 DiceLotteryConfig type=0 的 id,没有则为 0 + try { + $lotteryConfigId = $model->getAttr('lottery_config_id'); + } catch (\Throwable $e) { + $lotteryConfigId = null; + } + if ($lotteryConfigId === null || $lotteryConfigId === '' || (int) $lotteryConfigId === 0) { + $config = DiceLotteryConfig::where('type', 0)->find(); + $model->setAttr('lottery_config_id', $config ? (int) $config->id : 0); + } // 彩金池权重默认取 type=0 的奖池配置 self::setDefaultWeightsFromLotteryConfig($model); }