重新设置抽奖底注金额为1,优化页面样式
This commit is contained in:
@@ -74,7 +74,7 @@ class GameController extends BaseController
|
||||
* 购买抽奖券
|
||||
* POST /api/game/buyLotteryTickets
|
||||
* header: token(由 TokenMiddleware 注入 request->player_id)
|
||||
* body: count = 1 | 5 | 10(1次/100coin, 5次/500coin, 10次/1000coin)
|
||||
* body: count = 1 | 5 | 10(1次/1coin, 5次/5coin, 10次/10coin)
|
||||
*/
|
||||
// public function buyLotteryTickets(Request $request): Response
|
||||
// {
|
||||
@@ -217,6 +217,7 @@ class GameController extends BaseController
|
||||
}
|
||||
}
|
||||
}
|
||||
$data['tier'] = $data['reward_tier'] ?? '';
|
||||
|
||||
return $this->success($data);
|
||||
} catch (ApiException $e) {
|
||||
|
||||
@@ -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张/500coin(5购买+1赠送,共6次)
|
||||
10 => ['coin' => 1000, 'paid' => 10, 'free' => 3], // 10张/1000coin(10购买+3赠送,共13次)
|
||||
1 => ['coin' => 1, 'paid' => 1, 'free' => 0], // 1次/1coin
|
||||
5 => ['coin' => 5, 'paid' => 5, 'free' => 1], // 5张/5coin(5购买+1赠送,共6次)
|
||||
10 => ['coin' => 10, 'paid' => 10, 'free' => 3], // 10张/10coin(10购买+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,
|
||||
|
||||
@@ -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-10000,10000=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_amount(ante*100)」
|
||||
// 付费:每局按「本局赢取平台币 win_coin - 抽奖费用 paid_amount(ante*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');
|
||||
|
||||
@@ -59,12 +59,12 @@ class DicePlayRecordController extends BaseController
|
||||
'diceLotteryPoolConfig',
|
||||
]);
|
||||
|
||||
// 按当前筛选条件统计:平台总盈利 = 付费抽奖(lottery_type=0)次数×100 - 玩家总收益(win_coin 求和)
|
||||
// 按当前筛选条件统计:平台总盈利 = 付费金额(paid_amount 求和) - 玩家总收益(win_coin 求和)
|
||||
$sumQuery = clone $query;
|
||||
$playerTotalWin = (float) $sumQuery->sum('win_coin');
|
||||
$paidAmountQuery = clone $query;
|
||||
$paidAmount = (float) $paidAmountQuery->where('lottery_type', 0)->sum('paid_amount');
|
||||
$totalWinCoin = $paidAmount - $playerTotalWin;
|
||||
$totalWinCoin = round($paidAmount - $playerTotalWin, 2);
|
||||
|
||||
$data = $this->logic->getList($query);
|
||||
$data['total_win_coin'] = $totalWinCoin;
|
||||
|
||||
@@ -30,7 +30,7 @@ class DicePlayRecordTestController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表,并在结果中附带当前筛选条件下测试数据的平台总盈利 total_win_coin(付费抽奖次数×100 - 玩家总收益)
|
||||
* 数据列表,并在结果中附带当前筛选条件下测试数据的平台总盈利 total_win_coin(付费金额 paid_amount 求和 - 玩家总收益)
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
@@ -57,7 +57,7 @@ class DicePlayRecordTestController extends BaseController
|
||||
$playerTotalWin = (float) $sumQuery->sum('win_coin');
|
||||
$paidAmountQuery = clone $query;
|
||||
$paidAmount = (float) $paidAmountQuery->where('lottery_type', 0)->sum('paid_amount');
|
||||
$totalWinCoin = $paidAmount - $playerTotalWin;
|
||||
$totalWinCoin = round($paidAmount - $playerTotalWin, 2);
|
||||
|
||||
$data = $this->logic->getList($query);
|
||||
$data['total_win_coin'] = $totalWinCoin;
|
||||
|
||||
@@ -23,7 +23,7 @@ use think\model\relation\BelongsTo;
|
||||
* @property $lottery_config_id 彩金池配置
|
||||
* @property $lottery_type 抽奖类型
|
||||
* @property $ante 底注/注数(dice_ante_config.mult)
|
||||
* @property $paid_amount 付费金额(付费局=ante*100,免费局=0)
|
||||
* @property $paid_amount 付费金额(付费局=ante*1,免费局=0)
|
||||
* @property $is_win 是否中大奖:豹子号[1,1,1,1,1]~[6,6,6,6,6]为1,否则0
|
||||
* @property $win_coin 赢取平台币(= super_win_coin + reward_win_coin)
|
||||
* @property $super_win_coin 中大奖平台币(豹子时发放)
|
||||
|
||||
@@ -22,7 +22,7 @@ use think\model\relation\BelongsTo;
|
||||
* @property $is_win 中大奖:0=无,1=中奖
|
||||
* @property $win_coin 赢取平台币
|
||||
* @property int|null $ante 底注/注数(dice_ante_config.mult)
|
||||
* @property int|null $paid_amount 付费金额(付费局=ante*100,免费局=0)
|
||||
* @property int|null $paid_amount 付费金额(付费局=ante*1,免费局=0)
|
||||
* @property $direction 方向:0=顺时针,1=逆时针
|
||||
* @property $reward_tier 中奖档位:T1,T2,T3,T4,T5,BIGWIN
|
||||
* @property $create_time 创建时间
|
||||
@@ -113,7 +113,7 @@ class DicePlayRecordTest extends BaseModel
|
||||
}
|
||||
}
|
||||
|
||||
/** 付费金额(付费局=ante*100,免费局=0) */
|
||||
/** 付费金额(付费局=ante*1,免费局=0) */
|
||||
public function searchPaidAmountAttr($query, $value)
|
||||
{
|
||||
if ($value !== '' && $value !== null) {
|
||||
|
||||
@@ -38,7 +38,7 @@ use think\model\relation\HasMany;
|
||||
* @property array|null $free_tier_weights 免费自定义档位权重 T1-T5
|
||||
* @property array $result_counts 落点统计 grid_number=>出现次数
|
||||
* @property array|null $tier_counts 档位出现次数 T1=>count
|
||||
* @property float|null $platform_profit 平台赚取金额(付费抽取次数×100-玩家总收益)
|
||||
* @property float|null $platform_profit 平台赚取金额(付费金额 paid_amount 求和-玩家总收益)
|
||||
* @property array|null $bigwin_weight 测试时 BIGWIN 档位权重快照(JSON:grid_number=>weight)
|
||||
* @property int|null $admin_id 执行测试的管理员ID
|
||||
* @property string|null $create_time 创建时间
|
||||
|
||||
Reference in New Issue
Block a user