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

@@ -234,8 +234,11 @@ final class AdminPlayerStoreController extends Controller
$prefix = strtoupper(substr(preg_replace('/[^A-Za-z]/', '', $siteCode) ?: 'LP', 0, 2));
$prefix = str_pad($prefix, 2, 'P');
// 使用 10 位数字100 亿组合)显著降低并发碰撞概率;即使极小概率撞上,
// 上层 Player::create 有 (site_code, site_player_id) 唯一索引兜底,
// 错误会在调用方被显式处理为 422/500而非静默双写。
do {
$candidate = sprintf('%s%06d', $prefix, random_int(0, 999999));
$candidate = sprintf('%s%010d', $prefix, random_int(0, 9999999999));
$exists = Player::query()
->where('site_code', $siteCode)
->where('site_player_id', $candidate)