重新设置抽奖底注金额为1,优化页面样式

This commit is contained in:
2026-03-31 17:23:16 +08:00
parent d54a9c9281
commit 6ed34b97df
24 changed files with 118 additions and 94 deletions

View File

@@ -17,9 +17,9 @@ use support\think\Db;
class GameLogic
{
public const PACKAGES = [
1 => ['coin' => 100, 'paid' => 1, 'free' => 0], // 1次/100coin
5 => ['coin' => 500, 'paid' => 5, 'free' => 1], // 5张/500coin5购买+1赠送共6次
10 => ['coin' => 1000, 'paid' => 10, 'free' => 3], // 10张/1000coin10购买+3赠送共13次
1 => ['coin' => 1, 'paid' => 1, 'free' => 0], // 1次/1coin
5 => ['coin' => 5, 'paid' => 5, 'free' => 1], // 5张/5coin5购买+1赠送共6次
10 => ['coin' => 10, 'paid' => 10, 'free' => 3], // 10张/10coin10购买+3赠送共13次
];
/** 钱包流水类型:购买抽奖次数 */
@@ -52,7 +52,7 @@ class GameLogic
throw new ApiException('Insufficient balance');
}
$coinAfter = $coinBefore - $cost;
$coinAfter = round($coinBefore - $cost, 2);
$totalBefore = (int) ($player->total_ticket_count ?? 0);
$paidBefore = (int) ($player->paid_ticket_count ?? 0);
$freeBefore = (int) ($player->free_ticket_count ?? 0);
@@ -94,7 +94,7 @@ class GameLogic
DicePlayerWalletRecord::create([
'player_id' => $playerId,
'admin_id' => $adminId,
'coin' => -$cost,
'coin' => round(-$cost, 2),
'type' => self::WALLET_TYPE_BUY_DRAW,
'wallet_before' => $coinBefore,
'wallet_after' => $coinAfter,
@@ -107,7 +107,7 @@ class GameLogic
DicePlayerTicketRecord::create([
'player_id' => $playerId,
'admin_id' => $adminId,
'use_coins' => $cost,
'use_coins' => round($cost, 2),
'ante' => 1,
'total_ticket_count' => $addTotal,
'paid_ticket_count' => $addPaid,
@@ -121,7 +121,7 @@ class GameLogic
}
return [
'coin' => (float) $coinAfter,
'coin' => round((float) $coinAfter, 2),
'total_ticket_count' => (int) $totalAfter,
'paid_ticket_count' => (int) $paidAfter,
'free_ticket_count' => (int) $freeAfter,

View File

@@ -37,8 +37,8 @@ class PlayStartLogic
/** 对局状态:超时/失败 */
public const RECORD_STATUS_TIMEOUT = 0;
/** 单注费用(对应原票价 100 */
private const UNIT_COST = 100;
/** 单注费用(抽奖券基础费用 */
private const UNIT_COST = 1.0;
/** 免费抽奖注数缓存 key 前缀(用于强制下一局注数一致) */
private const FREE_ANTE_KEY_PREFIX = 'api:game:free_ante:';
/** 免费抽奖注数缓存过期(秒) */
@@ -122,8 +122,8 @@ class PlayStartLogic
throw new ApiException('未达抽奖余额 ' . $needMinBalance . ',无法开始游戏');
}
// 付费抽奖:开始前扣除费用 ante * 100,不足则提示余额不足
$paidAmount = $ticketType === self::LOTTERY_TYPE_PAID ? ($ante * self::UNIT_COST) : 0;
// 付费抽奖:开始前扣除费用 ante * UNIT_COST,不足则提示余额不足
$paidAmount = $ticketType === self::LOTTERY_TYPE_PAID ? round($ante * self::UNIT_COST, 2) : 0.0;
if ($ticketType === self::LOTTERY_TYPE_PAID && $coin < $paidAmount) {
throw new ApiException('余额不足');
}
@@ -188,12 +188,12 @@ class PlayStartLogic
if ($isTierT5 === false && (string) ($tier ?? '') === 'T5') {
$isTierT5 = true;
}
// 摇色子中奖:按 dice_reward_config.real_ev 直接结算(已乘 ante;不再叠加票价 100
$rewardWinCoin = $realEv * $ante;
// 摇色子中奖:按 dice_reward_config.real_ev 直接结算(已乘 ante
$rewardWinCoin = round($realEv * $ante, 2);
// 豹子判定5/30 必豹子10/15/20/25 按 DiceRewardConfig 中 BIGWIN 该点数的 weight 判定0-1000010000=100%
// 杀分档位不触发豹子5/30 已在上方抽取时排除10/15/20/25 仅生成非豹子组合
$superWinCoin = 0;
$superWinCoin = 0.0;
$isWin = 0;
$bigWinRealEv = 0.0;
if (in_array($rollNumber, self::SUPER_WIN_GRID_NUMBERS, true)) {
@@ -223,10 +223,10 @@ class PlayStartLogic
$rollArray = $this->getSuperWinRollArray($rollNumber);
$isWin = 1;
$bigWinEv = $bigWinRealEv > 0 ? $bigWinRealEv : self::SUPER_WIN_BONUS;
$superWinCoin = $bigWinEv * $ante;
$superWinCoin = round($bigWinEv * $ante, 2);
// 中 BIGWIN 豹子:不走原奖励流程,不记录原奖励,不触发 T5 再来一次,仅发放豹子奖金
$rewardWinCoin = 0;
$realEv = 0;
$rewardWinCoin = 0.0;
$realEv = 0.0;
$isTierT5 = false;
} else {
$rollArray = $this->generateNonSuperWinRollArrayWithSum($rollNumber);
@@ -243,7 +243,7 @@ class PlayStartLogic
$startIndex,
$targetIndex
));
$winCoin = $superWinCoin + $rewardWinCoin; // 赢取平台币 = 中大奖 + 摇色子中奖(豹子时 rewardWinCoin 已为 0
$winCoin = round($superWinCoin + $rewardWinCoin, 2); // 赢取平台币 = 中大奖 + 摇色子中奖(豹子时 rewardWinCoin 已为 0
$record = null;
$configId = (int) $config->id;
@@ -302,7 +302,7 @@ class PlayStartLogic
}
$coinBefore = (float) $p->coin;
// 开始前先扣付费金额,再加中奖金额(免费抽奖 paid_amount=0
$coinAfter = $coinBefore - $paidAmount + $winCoin;
$coinAfter = round($coinBefore - $paidAmount + $winCoin, 2);
$p->coin = $coinAfter;
// 免费抽奖消耗:优先消耗 free_ticket.count耗尽则清空 free_ticket否则兼容旧 free_ticket_count
if ($ticketType === self::LOTTERY_TYPE_FREE) {
@@ -400,13 +400,13 @@ class PlayStartLogic
$p->save();
// 彩金池累计盈利累加在 name=default 彩金池上:
// 付费:每局按「本局赢取平台币 win_coin - 抽奖费用 paid_amountante*100)」
// 付费:每局按「本局赢取平台币 win_coin - 抽奖费用 paid_amountante*UNIT_COST)」
// 免费券paid_amount=0只计入 win_coin
$perPlayProfit = ($ticketType === self::LOTTERY_TYPE_PAID) ? ($winCoin - (float) $paidAmount) : $winCoin;
$addProfit = $perPlayProfit;
$perPlayProfit = ($ticketType === self::LOTTERY_TYPE_PAID) ? ($winCoin - $paidAmount) : $winCoin;
$addProfit = round($perPlayProfit, 2);
try {
DiceLotteryPoolConfig::where('id', $type0ConfigId)->update([
'profit_amount' => Db::raw('IFNULL(profit_amount,0) + ' . (float) $addProfit),
'profit_amount' => Db::raw('IFNULL(profit_amount,0) + ' . sprintf('%.2f', $addProfit)),
]);
} catch (\Throwable $e) {
Log::warning('彩金池盈利累加失败', [
@@ -418,11 +418,11 @@ class PlayStartLogic
// 钱包流水拆分:先记录购券扣费,再记录抽奖结果(中奖/惩罚)
if ($paidAmount > 0) {
$walletAfterBuy = $coinBefore - $paidAmount;
$walletAfterBuy = round($coinBefore - $paidAmount, 2);
DicePlayerWalletRecord::create([
'player_id' => $playerId,
'admin_id' => $adminId,
'coin' => -$paidAmount,
'coin' => round(-$paidAmount, 2),
'type' => self::WALLET_TYPE_BUY_DRAW,
'wallet_before' => $coinBefore,
'wallet_after' => $walletAfterBuy,
@@ -437,7 +437,7 @@ class PlayStartLogic
'admin_id' => $adminId,
'coin' => $winCoin,
'type' => self::WALLET_TYPE_DRAW,
'wallet_before' => $walletBeforeDraw,
'wallet_before' => round($walletBeforeDraw, 2),
'wallet_after' => $coinAfter,
'remark' => $drawRemark,
]);
@@ -484,9 +484,9 @@ class PlayStartLogic
$arr['roll_number'] = is_array($arr['roll_array'] ?? null) ? array_sum($arr['roll_array']) : 0;
$arr['reward_tier'] = ($isWin === 1 && $superWinCoin > 0) ? 'BIGWIN' : (string) ($tier ?? '');
// 记录完数据后返回当前玩家余额与抽奖次数
$arr['coin'] = $updated ? (float) $updated->coin : 0;
$arr['coin'] = $updated ? round((float) $updated->coin, 2) : 0.0;
// 本局从玩家货币中扣除的金额:付费抽奖为 ante*UNIT_COST免费抽奖为 0与 paid_amount 一致)
$arr['use_coin'] = $paidAmount;
$arr['use_coin'] = round($paidAmount, 2);
return $arr;
}
@@ -669,9 +669,9 @@ class PlayStartLogic
$rollNumber = (int) ($chosen['grid_number'] ?? 0);
$realEv = (float) ($chosen['real_ev'] ?? 0);
// 摇色子中奖:按 real_ev 直接结算(与正式抽奖 run() 一致)
$rewardWinCoin = $realEv * $ante;
$rewardWinCoin = round($realEv * $ante, 2);
$superWinCoin = 0;
$superWinCoin = 0.0;
$isWin = 0;
$bigWinRealEv = 0.0;
if (in_array($rollNumber, self::SUPER_WIN_GRID_NUMBERS, true)) {
@@ -699,8 +699,8 @@ class PlayStartLogic
$rollArray = $this->getSuperWinRollArray($rollNumber);
$isWin = 1;
$bigWinEv = $bigWinRealEv > 0 ? $bigWinRealEv : self::SUPER_WIN_BONUS;
$superWinCoin = $bigWinEv * $ante;
$rewardWinCoin = 0;
$superWinCoin = round($bigWinEv * $ante, 2);
$rewardWinCoin = 0.0;
// 中豹子时不走原奖励流程
$realEv = 0.0;
} else {
@@ -711,11 +711,11 @@ class PlayStartLogic
$rollArray = $this->generateRollArrayFromSum($rollNumber);
}
$winCoin = $superWinCoin + $rewardWinCoin;
$winCoin = round($superWinCoin + $rewardWinCoin, 2);
$configId = $config !== null ? (int) $config->id : 0;
$configName = $config !== null ? (string) ($config->name ?? '') : '自定义';
$costRealEv = $realEv + ($isWin === 1 ? $bigWinRealEv : 0.0);
$paidAmount = $lotteryType === 0 ? ($ante * self::UNIT_COST) : 0;
$paidAmount = $lotteryType === 0 ? round($ante * self::UNIT_COST, 2) : 0.0;
$rewardTier = ($isWin === 1 && $superWinCoin > 0) ? 'BIGWIN' : (string) ($tier ?? '');
// 与写入记录的 reward_tier 完全一致:仅当展示档位为 T5非豹子大奖时触发「再来一次」链式免费局
$grantsFreeTicket = ($rewardTier === 'T5');