feat: 扩展玩法配置快照字段并切换目录生效来源
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace App\Services\Ticket;
|
||||
|
||||
use App\Models\OddsItem;
|
||||
use App\Models\PlayType;
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Models\OddsVersion;
|
||||
use App\Models\RiskCapItem;
|
||||
@@ -80,18 +79,10 @@ final class PlayCatalogResolver
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{play_type: PlayType, play_config: PlayConfigItem, odds_items: Collection<int, OddsItem>}
|
||||
* @return array{play_config: PlayConfigItem, odds_items: Collection<int, OddsItem>}
|
||||
*/
|
||||
public function resolve(string $playCode, string $currencyCode): array
|
||||
{
|
||||
$playType = PlayType::query()->where('play_code', $playCode)->first();
|
||||
if ($playType === null) {
|
||||
throw new TicketOperationException('play_not_found', ErrorCode::BetPlayUnsupported->value);
|
||||
}
|
||||
if (! $playType->is_enabled) {
|
||||
throw new TicketOperationException('play_master_disabled', ErrorCode::PlayModeClosed->value);
|
||||
}
|
||||
|
||||
$playVersion = PlayConfigVersion::query()
|
||||
->where('status', ConfigVersionStatus::Active->value)
|
||||
->firstOrFail();
|
||||
@@ -120,7 +111,6 @@ final class PlayCatalogResolver
|
||||
}
|
||||
|
||||
return [
|
||||
'play_type' => $playType,
|
||||
'play_config' => $playConfig,
|
||||
'odds_items' => $oddsItems,
|
||||
];
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Services\Ticket;
|
||||
|
||||
use App\Models\OddsItem;
|
||||
use App\Models\PlayType;
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Models\PlayConfigItem;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -20,7 +19,7 @@ final class PlayRuleEngine
|
||||
* @param Collection<int, OddsItem> $oddsItems
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function evaluateLine(array $line, PlayType $playType, PlayConfigItem $playConfig, Collection $oddsItems): array
|
||||
public function evaluateLine(array $line, PlayConfigItem $playConfig, Collection $oddsItems): array
|
||||
{
|
||||
$playCode = (string) $line['play_code'];
|
||||
$dimension = $line['dimension'] ?? null;
|
||||
@@ -61,9 +60,9 @@ final class PlayRuleEngine
|
||||
'original_number' => (string) $line['number'],
|
||||
'normalized_number' => $number,
|
||||
'play_code' => $playCode,
|
||||
'dimension' => $this->toDimensionInt(is_string($dimension) ? $dimension : null, $playType),
|
||||
'dimension' => $this->toDimensionInt(is_string($dimension) ? $dimension : null, $playConfig),
|
||||
'digit_slot' => $digitSlotInt,
|
||||
'bet_mode' => $playType->bet_mode,
|
||||
'bet_mode' => $playConfig->bet_mode,
|
||||
'unit_bet_amount' => $unitBetAmount,
|
||||
'total_bet_amount' => $totalBetAmount,
|
||||
'rebate_rate_snapshot' => number_format($rebateRate, 4, '.', ''),
|
||||
@@ -300,13 +299,13 @@ final class PlayRuleEngine
|
||||
return $oddsItems->firstOrFail();
|
||||
}
|
||||
|
||||
private function toDimensionInt(?string $dimension, PlayType $playType): ?int
|
||||
private function toDimensionInt(?string $dimension, PlayConfigItem $playConfig): ?int
|
||||
{
|
||||
return match ($dimension) {
|
||||
'D2' => 2,
|
||||
'D3' => 3,
|
||||
'D4' => 4,
|
||||
default => $playType->dimension === null ? null : (int) $playType->dimension,
|
||||
default => $playConfig->dimension === null ? null : (int) $playConfig->dimension,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,6 @@ final class TicketPlacementService
|
||||
}
|
||||
$evaluated = $this->ruleEngine->evaluateLine(
|
||||
(array) $line,
|
||||
$resolved['play_type'],
|
||||
$resolved['play_config'],
|
||||
$resolved['odds_items'],
|
||||
);
|
||||
|
||||
@@ -54,7 +54,6 @@ final class TicketPreviewService
|
||||
}
|
||||
$evaluated = $this->ruleEngine->evaluateLine(
|
||||
(array) $line,
|
||||
$resolved['play_type'],
|
||||
$resolved['play_config'],
|
||||
$resolved['odds_items'],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user