feat(risk): 支持按开注商隔离风险池并新增经营报表
This commit is contained in:
@@ -54,6 +54,7 @@ final class EffectivePlayCatalogService
|
||||
|
||||
$riskItems = RiskCapItem::query()
|
||||
->where('version_id', $riskVersion->id)
|
||||
->whereIn('provider_code', ['GLOBAL', $providerCode])
|
||||
->orderBy('normalized_number')
|
||||
->get();
|
||||
|
||||
@@ -92,7 +93,9 @@ final class EffectivePlayCatalogService
|
||||
'risk_cap' => $this->serializeVersionHead($riskVersion),
|
||||
],
|
||||
'plays' => $plays,
|
||||
'risk_cap_items' => $riskItems->map(fn (RiskCapItem $r) => $this->serializeRiskItem($r))->all(),
|
||||
'risk_cap_items' => $this->resolveProviderRiskItems($riskItems, $providerCode)
|
||||
->map(fn (RiskCapItem $r) => $this->serializeRiskItem($r))
|
||||
->all(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -120,6 +123,29 @@ final class EffectivePlayCatalogService
|
||||
return collect(array_values($selected));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection<int, RiskCapItem> $items
|
||||
* @return Collection<int, RiskCapItem>
|
||||
*/
|
||||
private function resolveProviderRiskItems(Collection $items, string $providerCode): Collection
|
||||
{
|
||||
$selected = [];
|
||||
|
||||
foreach ($items->sortBy(fn (RiskCapItem $row): int => (string) ($row->provider_code ?? 'GLOBAL') === $providerCode ? 0 : 1) as $row) {
|
||||
$key = implode('|', [
|
||||
$row->draw_id === null ? 'null' : (string) $row->draw_id,
|
||||
(string) $row->normalized_number,
|
||||
(string) $row->cap_type,
|
||||
]);
|
||||
|
||||
if (! isset($selected[$key])) {
|
||||
$selected[$key] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
return collect(array_values($selected));
|
||||
}
|
||||
|
||||
/**
|
||||
* 大厅列表展示单档赔率:优先头奖档 {@see first},兼容历史 {@see default}。
|
||||
*
|
||||
@@ -210,6 +236,7 @@ final class EffectivePlayCatalogService
|
||||
private function serializeRiskItem(RiskCapItem $r): array
|
||||
{
|
||||
return [
|
||||
'provider_code' => $r->provider_code ?? 'GLOBAL',
|
||||
'draw_id' => $r->draw_id,
|
||||
'normalized_number' => $r->normalized_number,
|
||||
'cap_amount' => (int) $r->cap_amount,
|
||||
|
||||
Reference in New Issue
Block a user