feat(odds): 支持基于开注商的赔率区分与优先级处理
- 在赔率数据表中新增 provider_code 字段,默认值为 GLOBAL - 赔率接口与服务中新增 provider_code 参数支持,实现开注商特定赔率加载 - 解析赔率集合时,根据 provider_code 优先级进行排序与筛选,保证特定开注商赔率优先 - 优化赔率唯一索引,新增 provider_code 列以防止不同开注商赔率重复冲突 - 调整赔率相关验证规则,支持开注商代码的合法性与可选性检查 - 玩法解析与出票相关逻辑改造,支持多开注商环境下的投注处理 - 管理界面赔率替换接口增加 provider_code 字段支持 - 同步和测试用例覆盖 provider_code 相关功能,验证开注商赔率隔离与优先切换 - PlayEffectiveCatalogController 支持按 provider_code 返回赔率目录数据 - TicketPlacementService 与 TicketPreviewService 修改为支持 provider_code 多开注商玩法解析 - 维护 OddsStandardScopes 同步逻辑,保证开注商维度佣金与赔率正确同步 - AdminConfigPresenter 增加了对应数据的 provider_code 与 dimension 输出字段 - SDK接口添加 odds_snapshot_json 中开注商字段,完善赔率快照信息 - 路由配置调整管理文档地址,无关改动细微修改
This commit is contained in:
@@ -88,7 +88,7 @@ final class PlayCatalogResolver
|
||||
/**
|
||||
* @return array{play_config: PlayConfigItem, odds_items: Collection<int, OddsItem>}
|
||||
*/
|
||||
public function resolve(string $playCode, string $currencyCode): array
|
||||
public function resolve(string $playCode, string $currencyCode, ?string $providerCode = null): array
|
||||
{
|
||||
$playVersion = PlayConfigVersion::query()
|
||||
->where('status', ConfigVersionStatus::Active->value)
|
||||
@@ -107,12 +107,16 @@ final class PlayCatalogResolver
|
||||
->where('status', ConfigVersionStatus::Active->value)
|
||||
->firstOrFail();
|
||||
|
||||
$oddsItems = OddsItem::query()
|
||||
$providerCode = strtoupper((string) ($providerCode ?: 'GLOBAL'));
|
||||
$rawOddsItems = OddsItem::query()
|
||||
->where('version_id', $oddsVersion->id)
|
||||
->where('play_code', $playCode)
|
||||
->where('currency_code', strtoupper($currencyCode))
|
||||
->whereIn('provider_code', ['GLOBAL', $providerCode])
|
||||
->get();
|
||||
|
||||
$oddsItems = $this->resolveProviderOddsItems($rawOddsItems, $providerCode);
|
||||
|
||||
if ($oddsItems->isEmpty()) {
|
||||
throw new TicketOperationException('odds_missing', ErrorCode::BetPlayUnsupported->value);
|
||||
}
|
||||
@@ -123,6 +127,30 @@ final class PlayCatalogResolver
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection<int, OddsItem> $items
|
||||
* @return Collection<int, OddsItem>
|
||||
*/
|
||||
private function resolveProviderOddsItems(Collection $items, string $providerCode): Collection
|
||||
{
|
||||
$selected = [];
|
||||
|
||||
foreach ($items->sortBy(fn (OddsItem $row): int => (string) $row->provider_code === $providerCode ? 0 : 1) as $row) {
|
||||
$dimension = $row->dimension === null ? 'null' : (string) $row->dimension;
|
||||
$key = implode('|', [
|
||||
(string) $row->prize_scope,
|
||||
strtoupper((string) $row->currency_code),
|
||||
$dimension,
|
||||
]);
|
||||
|
||||
if (! isset($selected[$key])) {
|
||||
$selected[$key] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
return collect(array_values($selected));
|
||||
}
|
||||
|
||||
public function resolveCapAmount(int $drawId, string $number4d): int
|
||||
{
|
||||
$riskVersion = RiskCapVersion::query()
|
||||
|
||||
@@ -73,6 +73,7 @@ final class PlayRuleEngine
|
||||
'combination_count' => $combinationCount,
|
||||
'estimated_max_payout' => $estimatedMaxPayout,
|
||||
'odds_snapshot_json' => $oddsItems->map(fn (OddsItem $row) => [
|
||||
'provider_code' => (string) ($row->provider_code ?? 'GLOBAL'),
|
||||
'prize_scope' => $row->prize_scope,
|
||||
'odds_value' => (int) $row->odds_value,
|
||||
'rebate_rate' => (string) $row->rebate_rate,
|
||||
|
||||
@@ -131,21 +131,22 @@ final class TicketPlacementService
|
||||
$closedPlayCleanupRows = [];
|
||||
|
||||
foreach ((array) $payload['lines'] as $index => $line) {
|
||||
try {
|
||||
$resolved = $this->catalogResolver->resolve((string) $line['play_code'], $currencyCode);
|
||||
} catch (TicketOperationException $e) {
|
||||
if ($e->lotteryCode === ErrorCode::PlayModeClosed->value) {
|
||||
$closedPlayCleanupRows[] = [
|
||||
'client_line_no' => $index + 1,
|
||||
'play_code' => (string) ($line['play_code'] ?? ''),
|
||||
];
|
||||
foreach ($providers as $provider) {
|
||||
try {
|
||||
$resolved = $this->catalogResolver->resolve((string) $line['play_code'], $currencyCode, (string) $provider['code']);
|
||||
} catch (TicketOperationException $e) {
|
||||
if ($e->lotteryCode === ErrorCode::PlayModeClosed->value) {
|
||||
$closedPlayCleanupRows[] = [
|
||||
'client_line_no' => $index + 1,
|
||||
'play_code' => (string) ($line['play_code'] ?? ''),
|
||||
];
|
||||
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
foreach ($providers as $provider) {
|
||||
$evaluated = $this->ruleEngine->evaluateLine(
|
||||
(array) $line,
|
||||
$resolved['play_config'],
|
||||
|
||||
@@ -52,21 +52,22 @@ final class TicketPreviewService
|
||||
$closedPlayCleanupRows = [];
|
||||
|
||||
foreach ((array) $payload['lines'] as $index => $line) {
|
||||
try {
|
||||
$resolved = $this->catalogResolver->resolve((string) $line['play_code'], $currencyCode);
|
||||
} catch (TicketOperationException $e) {
|
||||
if ($e->lotteryCode === ErrorCode::PlayModeClosed->value) {
|
||||
$closedPlayCleanupRows[] = [
|
||||
'client_line_no' => $index + 1,
|
||||
'play_code' => (string) ($line['play_code'] ?? ''),
|
||||
];
|
||||
foreach ($providers as $provider) {
|
||||
try {
|
||||
$resolved = $this->catalogResolver->resolve((string) $line['play_code'], $currencyCode, (string) $provider['code']);
|
||||
} catch (TicketOperationException $e) {
|
||||
if ($e->lotteryCode === ErrorCode::PlayModeClosed->value) {
|
||||
$closedPlayCleanupRows[] = [
|
||||
'client_line_no' => $index + 1,
|
||||
'play_code' => (string) ($line['play_code'] ?? ''),
|
||||
];
|
||||
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
foreach ($providers as $provider) {
|
||||
$evaluated = $this->ruleEngine->evaluateLine(
|
||||
(array) $line,
|
||||
$resolved['play_config'],
|
||||
|
||||
Reference in New Issue
Block a user