1.修改彩金池配置中的playerDefault时自动修改绑定该配置的用户
This commit is contained in:
@@ -83,6 +83,47 @@ class LotteryService
|
||||
Cache::set($key, json_encode($data), self::EXPIRE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使玩家彩金池 Redis 快照失效(下次 getOrCreate 从库重建)
|
||||
*/
|
||||
public static function invalidatePlayerLotteryCache(int $playerId): void
|
||||
{
|
||||
if ($playerId <= 0) {
|
||||
return;
|
||||
}
|
||||
Cache::delete(self::getRedisKey($playerId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 若 Redis 中已有该玩家彩金池快照,则仅更新 player_weights(避免全量重建)
|
||||
*
|
||||
* @param array{t1_weight?:int,t2_weight?:int,t3_weight?:int,t4_weight?:int,t5_weight?:int} $weights
|
||||
*/
|
||||
public static function patchPlayerWeightsCache(int $playerId, array $weights): void
|
||||
{
|
||||
if ($playerId <= 0) {
|
||||
return;
|
||||
}
|
||||
$key = self::getRedisKey($playerId);
|
||||
$cached = Cache::get($key);
|
||||
if (!$cached || !is_string($cached)) {
|
||||
return;
|
||||
}
|
||||
$data = json_decode($cached, true);
|
||||
if (!is_array($data)) {
|
||||
Cache::delete($key);
|
||||
return;
|
||||
}
|
||||
$data['player_weights'] = [
|
||||
't1_weight' => (int) ($weights['t1_weight'] ?? 0),
|
||||
't2_weight' => (int) ($weights['t2_weight'] ?? 0),
|
||||
't3_weight' => (int) ($weights['t3_weight'] ?? 0),
|
||||
't4_weight' => (int) ($weights['t4_weight'] ?? 0),
|
||||
't5_weight' => (int) ($weights['t5_weight'] ?? 0),
|
||||
];
|
||||
Cache::set($key, json_encode($data), self::EXPIRE);
|
||||
}
|
||||
|
||||
/** 根据奖池配置的 t1_weight..t5_weight 权重随机抽取档位 T1-T5 */
|
||||
public static function drawTierByWeights(DiceLotteryPoolConfig $config): string
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user