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); }