DicePlayRecord添加字段super_win_coin和reward_win_coin记录不同的中奖金额类型

This commit is contained in:
2026-03-07 11:09:41 +08:00
parent fe1ceeb4fb
commit e312154b0f
15 changed files with 280 additions and 60 deletions

View File

@@ -51,7 +51,7 @@ class DiceRewardConfig extends BaseModel
/**
* 获取彩金池实例(含 list / 索引),无则从库加载并写入缓存;同请求内复用
* @return array{list: array, by_tier: array, by_s_end_index: array, by_n_end_index: array, min_real_ev: float}
* @return array{list: array, by_tier: array, by_tier_grid: array, by_s_end_index: array, by_n_end_index: array, min_real_ev: float}
*/
public static function getCachedInstance(): array
{
@@ -86,6 +86,7 @@ class DiceRewardConfig extends BaseModel
{
$list = (new self())->order('id', 'asc')->select()->toArray();
$byTier = [];
$byTierGrid = [];
$bySEndIndex = [];
$byNEndIndex = [];
foreach ($list as $row) {
@@ -95,6 +96,13 @@ class DiceRewardConfig extends BaseModel
$byTier[$tier] = [];
}
$byTier[$tier][] = $row;
$gridNum = isset($row['grid_number']) ? (int) $row['grid_number'] : 0;
if (!isset($byTierGrid[$tier])) {
$byTierGrid[$tier] = [];
}
if (!isset($byTierGrid[$tier][$gridNum])) {
$byTierGrid[$tier][$gridNum] = $row;
}
}
$sEnd = isset($row['s_end_index']) ? (int) $row['s_end_index'] : 0;
if ($sEnd !== 0) {
@@ -115,6 +123,7 @@ class DiceRewardConfig extends BaseModel
self::$instance = [
'list' => $list,
'by_tier' => $byTier,
'by_tier_grid' => $byTierGrid,
'by_s_end_index' => $bySEndIndex,
'by_n_end_index' => $byNEndIndex,
'min_real_ev' => $minRealEv,
@@ -128,12 +137,28 @@ class DiceRewardConfig extends BaseModel
return [
'list' => [],
'by_tier' => [],
'by_tier_grid' => [],
'by_s_end_index' => [],
'by_n_end_index' => [],
'min_real_ev' => 0.0,
];
}
/**
* 从缓存按档位 + 色子点数取一条奖励配置(用于超级大奖 tier=BIGWIN + grid_number=roll_number
* @param string $tier 档位,如 BIGWIN
* @param int $gridNumber 色子点数(如摇出总和)
* @return array|null 配置行或 null
*/
public static function getCachedByTierAndGridNumber(string $tier, int $gridNumber): ?array
{
$inst = self::getCachedInstance();
$byTierGrid = $inst['by_tier_grid'] ?? [];
$tierData = $byTierGrid[$tier] ?? [];
$row = $tierData[$gridNumber] ?? null;
return is_array($row) ? $row : null;
}
/**
* 从缓存取最小 real_ev
*/