[接口]优化新增购买抽奖券时记录DicePlayerTicketRecord

This commit is contained in:
2026-03-04 17:36:52 +08:00
parent bff8ea04e6
commit 2dcc9f479a
3 changed files with 38 additions and 4 deletions

View File

@@ -53,8 +53,14 @@ class GameController extends OpenController
$logic = new GameLogic();
$data = $logic->buyLotteryTickets($userId, $count);
return $this->success($data);
} catch (\plugin\saiadmin\exception\ApiException $e) {
return $this->fail($e->getMessage(), ReturnCode::EMPTY_PARAMS);
} catch (ApiException $e) {
$msg = $e->getMessage();
if ($msg === '平台币不足') {
$player = DicePlayer::find($userId);
$coin = $player ? (float) $player->coin : 0;
return $this->success(['coin' => $coin], $msg);
}
return $this->fail($msg, ReturnCode::EMPTY_PARAMS);
}
}