- 在赔率数据表中新增 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 中开注商字段,完善赔率快照信息 - 路由配置调整管理文档地址,无关改动细微修改
158 lines
5.5 KiB
PHP
158 lines
5.5 KiB
PHP
<?php
|
||
|
||
namespace App\Support;
|
||
|
||
use App\Models\OddsItem;
|
||
use App\Models\PlayType;
|
||
use App\Models\OddsVersion;
|
||
use App\Models\RiskCapItem;
|
||
use App\Models\PlayConfigItem;
|
||
use App\Models\RiskCapVersion;
|
||
use App\Models\PlayConfigVersion;
|
||
|
||
/** 后台 API:阶段 4 运营配置序列化(与其它 Admin*Controller 手写数组风格一致)。 */
|
||
final class AdminConfigPresenter
|
||
{
|
||
/** @return array<string, mixed> */
|
||
public static function playType(PlayType $t): array
|
||
{
|
||
return [
|
||
'id' => (int) $t->id,
|
||
'play_code' => $t->play_code,
|
||
'category' => $t->category,
|
||
'dimension' => $t->dimension,
|
||
'bet_mode' => $t->bet_mode,
|
||
'display_name' => $t->display_name,
|
||
'is_enabled' => (bool) $t->is_enabled,
|
||
'sort_order' => (int) $t->sort_order,
|
||
'supports_multi_number' => (bool) $t->supports_multi_number,
|
||
'reserved_rule_json' => $t->reserved_rule_json,
|
||
'updated_at' => $t->updated_at?->toIso8601String(),
|
||
];
|
||
}
|
||
|
||
/** @return array<string, mixed> */
|
||
public static function playConfigVersionSummary(PlayConfigVersion $v): array
|
||
{
|
||
return [
|
||
'id' => (int) $v->id,
|
||
'version_no' => (int) $v->version_no,
|
||
'status' => $v->status,
|
||
'effective_at' => $v->effective_at?->toIso8601String(),
|
||
'updated_by' => $v->updated_by,
|
||
'reason' => $v->reason,
|
||
'created_at' => $v->created_at?->toIso8601String(),
|
||
'updated_at' => $v->updated_at?->toIso8601String(),
|
||
];
|
||
}
|
||
|
||
/** @return array<string, mixed> */
|
||
public static function playConfigVersionDetail(PlayConfigVersion $v): array
|
||
{
|
||
$base = self::playConfigVersionSummary($v);
|
||
$base['items'] = $v->items->map(fn (PlayConfigItem $r) => self::playConfigItem($r))->values()->all();
|
||
|
||
return $base;
|
||
}
|
||
|
||
/** @return array<string, mixed> */
|
||
public static function playConfigItem(PlayConfigItem $r): array
|
||
{
|
||
return [
|
||
'id' => (int) $r->id,
|
||
'play_code' => $r->play_code,
|
||
'category' => $r->category,
|
||
'dimension' => $r->dimension === null ? null : (int) $r->dimension,
|
||
'bet_mode' => $r->bet_mode,
|
||
'display_name' => $r->display_name,
|
||
'is_enabled' => (bool) $r->is_enabled,
|
||
'min_bet_amount' => (int) $r->min_bet_amount,
|
||
'max_bet_amount' => (int) $r->max_bet_amount,
|
||
'display_order' => (int) $r->display_order,
|
||
'supports_multi_number' => (bool) $r->supports_multi_number,
|
||
'reserved_rule_json' => $r->reserved_rule_json,
|
||
'rule_text_zh' => $r->rule_text_zh,
|
||
'rule_text_en' => $r->rule_text_en,
|
||
'rule_text_ne' => $r->rule_text_ne,
|
||
'extra_config_json' => $r->extra_config_json,
|
||
];
|
||
}
|
||
|
||
/** @return array<string, mixed> */
|
||
public static function oddsVersionSummary(OddsVersion $v): array
|
||
{
|
||
return [
|
||
'id' => (int) $v->id,
|
||
'version_no' => (int) $v->version_no,
|
||
'status' => $v->status,
|
||
'effective_at' => $v->effective_at?->toIso8601String(),
|
||
'updated_by' => $v->updated_by,
|
||
'reason' => $v->reason,
|
||
'created_at' => $v->created_at?->toIso8601String(),
|
||
'updated_at' => $v->updated_at?->toIso8601String(),
|
||
];
|
||
}
|
||
|
||
/** @return array<string, mixed> */
|
||
public static function oddsVersionDetail(OddsVersion $v): array
|
||
{
|
||
$base = self::oddsVersionSummary($v);
|
||
$base['items'] = $v->items->map(fn (OddsItem $r) => self::oddsItem($r))->values()->all();
|
||
|
||
return $base;
|
||
}
|
||
|
||
/** @return array<string, mixed> */
|
||
public static function oddsItem(OddsItem $r): array
|
||
{
|
||
return [
|
||
'id' => (int) $r->id,
|
||
'provider_code' => $r->provider_code ?? 'GLOBAL',
|
||
'play_code' => $r->play_code,
|
||
'prize_scope' => $r->prize_scope,
|
||
'dimension' => $r->dimension === null ? null : (int) $r->dimension,
|
||
'odds_value' => (int) $r->odds_value,
|
||
'rebate_rate' => (string) $r->rebate_rate,
|
||
'commission_rate' => (string) $r->commission_rate,
|
||
'currency_code' => $r->currency_code,
|
||
'extra_config_json' => $r->extra_config_json,
|
||
];
|
||
}
|
||
|
||
/** @return array<string, mixed> */
|
||
public static function riskCapVersionSummary(RiskCapVersion $v): array
|
||
{
|
||
return [
|
||
'id' => (int) $v->id,
|
||
'version_no' => (int) $v->version_no,
|
||
'status' => $v->status,
|
||
'effective_at' => $v->effective_at?->toIso8601String(),
|
||
'updated_by' => $v->updated_by,
|
||
'reason' => $v->reason,
|
||
'created_at' => $v->created_at?->toIso8601String(),
|
||
'updated_at' => $v->updated_at?->toIso8601String(),
|
||
];
|
||
}
|
||
|
||
/** @return array<string, mixed> */
|
||
public static function riskCapVersionDetail(RiskCapVersion $v): array
|
||
{
|
||
$base = self::riskCapVersionSummary($v);
|
||
$base['items'] = $v->items->map(fn (RiskCapItem $r) => self::riskCapItem($r))->values()->all();
|
||
|
||
return $base;
|
||
}
|
||
|
||
/** @return array<string, mixed> */
|
||
public static function riskCapItem(RiskCapItem $r): array
|
||
{
|
||
return [
|
||
'id' => (int) $r->id,
|
||
'draw_id' => $r->draw_id,
|
||
'normalized_number' => $r->normalized_number,
|
||
'cap_amount' => (int) $r->cap_amount,
|
||
'cap_type' => $r->cap_type,
|
||
];
|
||
}
|
||
}
|