优化游玩记录DicePlayRecord

This commit is contained in:
2026-03-07 14:40:33 +08:00
parent 316506b597
commit 6632923213
13 changed files with 286 additions and 55 deletions

View File

@@ -20,6 +20,7 @@ use support\think\Cache;
* @property $ui_text 前端显示文本
* @property $real_ev 真实资金结算
* @property $tier 所属档位
* @property $weight 权重%(仅 tier=BIGWIN 时可设定0-100
* @property $s_end_index 顺时针结束索引
* @property $n_end_index 逆时针结束索引
* @property $remark 备注
@@ -80,7 +81,8 @@ class DiceRewardConfig extends BaseModel
}
/**
* 重新从数据库加载并写入缓存(保存时调用),构建列表与索引
* 重新从数据库加载并写入缓存(DiceRewardConfig 新增/修改/删除后调用),构建列表与索引
* 实例化结果含完整行(含 weight供 playStart 从缓存中查找 BIGWIN 的 weight 按概率抽奖
*/
public static function refreshCache(): void
{
@@ -148,10 +150,11 @@ class DiceRewardConfig extends BaseModel
}
/**
* 从缓存按档位 + 色子点数取一条奖励配置(用于超级大奖 tier=BIGWIN + grid_number=roll_number
* 从缓存实例按档位 + 色子点数取一条奖励配置(用于超级大奖 tier=BIGWIN + grid_number=roll_number
* 返回行含 weight0-100playStart 据此概率抽奖weight=100 表示摇到该 roll_number 时 100% 中超级大奖
* @param string $tier 档位,如 BIGWIN
* @param int $gridNumber 色子点数(摇出总和)
* @return array|null 配置行或 null
* @param int $gridNumber 色子点数(摇出总和 roll_number
* @return array|null 配置行(含 weight、real_ev 等)或 null
*/
public static function getCachedByTierAndGridNumber(string $tier, int $gridNumber): ?array
{
@@ -277,4 +280,20 @@ class DiceRewardConfig extends BaseModel
$query->where('tier', '=', $value);
}
}
/** 权重下限(仅 tier=BIGWIN 时有意义) */
public function searchWeightMinAttr($query, $value)
{
if ($value !== '' && $value !== null) {
$query->where('weight', '>=', $value);
}
}
/** 权重上限 */
public function searchWeightMaxAttr($query, $value)
{
if ($value !== '' && $value !== null) {
$query->where('weight', '<=', $value);
}
}
}