优化抽奖方式,以及记录相关信息
This commit is contained in:
@@ -76,28 +76,28 @@ class GameController extends BaseController
|
||||
* header: token(由 TokenMiddleware 注入 request->player_id)
|
||||
* body: count = 1 | 5 | 10(1次/100coin, 5次/500coin, 10次/1000coin)
|
||||
*/
|
||||
public function buyLotteryTickets(Request $request): Response
|
||||
{
|
||||
$userId = (int) ($request->player_id ?? 0);
|
||||
$count = (int) $request->post('count', 0);
|
||||
if (!in_array($count, [1, 5, 10], true)) {
|
||||
return $this->fail('Invalid lottery ticket purchase', ReturnCode::PARAMS_ERROR);
|
||||
}
|
||||
|
||||
try {
|
||||
$logic = new GameLogic();
|
||||
$data = $logic->buyLotteryTickets($userId, $count);
|
||||
return $this->success($data);
|
||||
} 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::BUSINESS_ERROR);
|
||||
}
|
||||
}
|
||||
// public function buyLotteryTickets(Request $request): Response
|
||||
// {
|
||||
// $userId = (int) ($request->player_id ?? 0);
|
||||
// $count = (int) $request->post('count', 0);
|
||||
// if (!in_array($count, [1, 5, 10], true)) {
|
||||
// return $this->fail('Invalid lottery ticket purchase', ReturnCode::PARAMS_ERROR);
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// $logic = new GameLogic();
|
||||
// $data = $logic->buyLotteryTickets($userId, $count);
|
||||
// return $this->success($data);
|
||||
// } 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::BUSINESS_ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取彩金池(中奖配置表)
|
||||
@@ -194,10 +194,11 @@ class GameController extends BaseController
|
||||
$langLower = strtolower($lang);
|
||||
$isEn = $langLower === 'en' || str_starts_with($langLower, 'en-');
|
||||
|
||||
if (is_array($data) && array_key_exists('reward_config_id', $data)) {
|
||||
$rewardConfigId = (int) $data['reward_config_id'];
|
||||
if ($rewardConfigId > 0) {
|
||||
$configRow = DiceRewardConfig::getCachedById($rewardConfigId);
|
||||
if (is_array($data)) {
|
||||
$rewardTier = array_key_exists('reward_tier', $data) ? (string) ($data['reward_tier'] ?? '') : '';
|
||||
$targetIndex = array_key_exists('target_index', $data) ? (int) ($data['target_index'] ?? 0) : 0;
|
||||
if ($rewardTier !== 'BIGWIN' && $targetIndex > 0) {
|
||||
$configRow = DiceRewardConfig::getCachedById($targetIndex);
|
||||
if ($configRow !== null) {
|
||||
$uiText = '';
|
||||
$uiTextEn = '';
|
||||
@@ -247,9 +248,8 @@ class GameController extends BaseController
|
||||
'win_coin' => 0,
|
||||
'super_win_coin' => 0,
|
||||
'reward_win_coin' => 0,
|
||||
'use_coins' => 0,
|
||||
'direction' => $direction,
|
||||
'reward_config_id' => 0,
|
||||
'reward_tier' => '',
|
||||
'start_index' => 0,
|
||||
'target_index' => 0,
|
||||
'roll_array' => '[]',
|
||||
|
||||
Reference in New Issue
Block a user