fix: 修复并发竞态与幂等性缺陷并优化子树查询
Some checks failed
lotterLaravel CI / test (push) Has been cancelled

- 扩大玩家ID随机数位宽降低碰撞概率
- 授信额度变更加 lockForUpdate 防并发下调
- 结算冲正与入账利用唯一索引实现幂等闸门
- 失败登录计数加锁防丢失
- 代理子树查询改用子查询替代全表 pluck
- 修复返点默认值百分比单位转换
- 测试中全量 fake 广播事件防 CI 500
This commit is contained in:
2026-06-18 09:38:24 +08:00
parent 2e0b257160
commit 6b2ea39ea1
13 changed files with 400 additions and 135 deletions

View File

@@ -351,7 +351,9 @@ test('jackpot contribution uses total bet amount instead of actual deduct amount
});
test('jackpot bursts by configured play combination trigger before threshold', function (): void {
Event::fake([JackpotBurstBroadcast::class]);
// 该 case 切到 reverb driver必须 fake 流程中所有可能触发的 Broadcast 事件,
// 否则 fake 列表外的广播会真实连接 Reverb/Pusher在 CI 环境抛 500。
Event::fake(allBroadcastEvents());
config([
'broadcasting.default' => 'reverb',
'broadcasting.connections.reverb.driver' => 'reverb',

View File

@@ -428,7 +428,9 @@ test('play type patch toggles active config and broadcasts instantly', function
});
test('§9 play_config publish broadcasts changed play toggles', function (): void {
Event::fake([PlayToggleBroadcast::class]);
// fake 流程中可能触发的全部 BroadcastPlayToggle / PlayCatalogUpdated / DrawStatusChange 等),
// 否则未在 fake 列表中的事件会真实连接 Reverb/PusherCI 环境抛 500。
Event::fake(allBroadcastEvents());
config([
'broadcasting.default' => 'reverb',
'broadcasting.connections.reverb.driver' => 'reverb',
@@ -459,7 +461,9 @@ test('§9 play_config publish broadcasts changed play toggles', function (): voi
});
test('§9 odds publish broadcasts odds update', function (): void {
Event::fake([OddsUpdateBroadcast::class]);
// fake 流程中可能触发的全部 BroadcastOddsUpdate / PlayCatalogUpdated / DrawStatusChange 等),
// 否则未在 fake 列表中的事件会真实连接 Reverb/PusherCI 环境抛 500。
Event::fake(allBroadcastEvents());
config([
'broadcasting.default' => 'reverb',
'broadcasting.connections.reverb.driver' => 'reverb',

View File

@@ -137,3 +137,32 @@ function ensureAdminActionCatalogSeeded(): void
);
}
}
/**
* 返回项目内所有 Broadcast 事件类列表,供 Event::fake() 拦截广播使用。
*
* 业务切到 reverb driver fake 列表不全会导致未拦截的 broadcast 真实派发、
* 真实连接 Reverb/PusherCI 环境无可用 server 时直接 500。本 helper 保证:
* Event::fake(allBroadcastEvents())
* 一行覆盖流程中可能触发的所有事件。
*
* 不可使用 Event::fake() 无参形式:会同时拦截 Illuminate\Database\Events\* 等框架事件,
* 干扰 RefreshDatabase / model events / 自定义 boot hooks。
*
* @return list<class-string>
*/
function allBroadcastEvents(): array
{
return [
\App\Events\BalanceUpdateBroadcast::class,
\App\Events\DrawCountdownBroadcast::class,
\App\Events\DrawResultPublishedBroadcast::class,
\App\Events\DrawStatusChangeBroadcast::class,
\App\Events\JackpotBurstBroadcast::class,
\App\Events\OddsUpdateBroadcast::class,
\App\Events\PlayCatalogUpdatedBroadcast::class,
\App\Events\PlayToggleBroadcast::class,
\App\Events\RiskSoldOutBroadcast::class,
\App\Events\RiskWarningBroadcast::class,
];
}