重构DiceLotteryConfig为DiceLotteryPoolConfig

This commit is contained in:
2026-03-10 17:56:14 +08:00
parent 1a748745cb
commit 54aa0bd34f
22 changed files with 160 additions and 160 deletions

View File

@@ -5,7 +5,7 @@ namespace app\api\logic;
use app\api\cache\UserCache;
use app\api\service\LotteryService;
use app\dice\model\lottery_config\DiceLotteryConfig;
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
use app\dice\model\play_record\DicePlayRecord;
use app\dice\model\player\DicePlayer;
use app\dice\model\player_ticket_record\DicePlayerTicketRecord;
@@ -70,8 +70,8 @@ class PlayStartLogic
$lotteryService = LotteryService::getOrCreate($playerId);
$ticketType = LotteryService::drawTicketType($paid, $free);
$config = $ticketType === self::LOTTERY_TYPE_PAID
? ($lotteryService->getConfigType0Id() ? DiceLotteryConfig::find($lotteryService->getConfigType0Id()) : null)
: ($lotteryService->getConfigType1Id() ? DiceLotteryConfig::find($lotteryService->getConfigType1Id()) : null);
? ($lotteryService->getConfigType0Id() ? DiceLotteryPoolConfig::find($lotteryService->getConfigType0Id()) : null)
: ($lotteryService->getConfigType1Id() ? DiceLotteryPoolConfig::find($lotteryService->getConfigType1Id()) : null);
if (!$config) {
throw new ApiException('奖池配置不存在');
}
@@ -232,7 +232,7 @@ class PlayStartLogic
// 累加彩金池盈利额度(累加值为 -real_ev。若 dice_lottery_config 表有 ev 字段则执行
try {
DiceLotteryConfig::where('id', $configId)->update([
DiceLotteryPoolConfig::where('id', $configId)->update([
'ev' => Db::raw('IFNULL(ev,0) - ' . (float) $realEv),
]);
} catch (\Throwable $_) {

View File

@@ -3,7 +3,7 @@ declare(strict_types=1);
namespace app\api\service;
use app\dice\model\lottery_config\DiceLotteryConfig;
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
use app\dice\model\player\DicePlayer;
use support\think\Cache;
@@ -37,7 +37,7 @@ class LotteryService
return self::REDIS_KEY_START_INDEX . $playerId;
}
/** 从 Redis 加载或根据玩家与 DiceLotteryConfig 创建并保存 */
/** 从 Redis 加载或根据玩家与 DiceLotteryPoolConfig 创建并保存 */
public static function getOrCreate(int $playerId): self
{
$key = self::getRedisKey($playerId);
@@ -56,8 +56,8 @@ class LotteryService
if (!$player) {
throw new \RuntimeException('玩家不存在');
}
$config0 = DiceLotteryConfig::where('type', 0)->find();
$config1 = DiceLotteryConfig::where('type', 1)->find();
$config0 = DiceLotteryPoolConfig::where('type', 0)->find();
$config1 = DiceLotteryPoolConfig::where('type', 1)->find();
$s = new self($playerId);
$s->configType0Id = $config0 ? (int) $config0->id : null;
$s->configType1Id = $config1 ? (int) $config1->id : null;
@@ -84,7 +84,7 @@ class LotteryService
}
/** 根据奖池配置的 t1_weight..t5_weight 权重随机抽取档位 T1-T5 */
public static function drawTierByWeights(DiceLotteryConfig $config): string
public static function drawTierByWeights(DiceLotteryPoolConfig $config): string
{
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5'];
$weights = [