feat(bet-provider): 添加开注商管理功能,包括增删改查接口及相关模型和迁移文件
This commit is contained in:
@@ -17,6 +17,7 @@ final class TicketPreviewService
|
||||
private readonly TicketLineInstantRebateApplicator $rebateApplicator,
|
||||
private readonly RiskPoolService $riskPoolService,
|
||||
private readonly DrawHallSnapshotBuilder $drawHallSnapshot,
|
||||
private readonly BetProviderResolver $betProviderResolver,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -38,6 +39,9 @@ final class TicketPreviewService
|
||||
|
||||
$currencyCode = strtoupper((string) $payload['currency_code']);
|
||||
$this->assertCreditCurrencyMatchesPlayer($player, $currencyCode);
|
||||
$providers = $this->betProviderResolver->resolve(
|
||||
is_array($payload['provider_codes'] ?? null) ? $payload['provider_codes'] : null,
|
||||
);
|
||||
|
||||
$lines = [];
|
||||
$totalBet = 0;
|
||||
@@ -62,48 +66,52 @@ final class TicketPreviewService
|
||||
|
||||
throw $e;
|
||||
}
|
||||
$evaluated = $this->ruleEngine->evaluateLine(
|
||||
(array) $line,
|
||||
$resolved['play_config'],
|
||||
$resolved['odds_items'],
|
||||
);
|
||||
$evaluated = $this->rebateApplicator->apply($player, $evaluated);
|
||||
foreach ($providers as $provider) {
|
||||
$evaluated = $this->ruleEngine->evaluateLine(
|
||||
(array) $line,
|
||||
$resolved['play_config'],
|
||||
$resolved['odds_items'],
|
||||
);
|
||||
$evaluated = $this->rebateApplicator->apply($player, $evaluated);
|
||||
|
||||
$locks = array_map(fn (array $combo): array => [
|
||||
'number_4d' => $combo['number_4d'],
|
||||
'amount' => $combo['estimated_payout'],
|
||||
], $evaluated['combinations']);
|
||||
$riskPreview = $this->riskPoolService->preview((int) $draw->id, $locks);
|
||||
foreach ($riskPreview as $riskRow) {
|
||||
if ($riskRow['warning']) {
|
||||
$warningRows[] = [
|
||||
'number_4d' => $riskRow['number_4d'],
|
||||
'message' => '该号码赔付池已使用 80% 以上,可能即将售罄',
|
||||
];
|
||||
$locks = array_map(fn (array $combo): array => [
|
||||
'number_4d' => $combo['number_4d'],
|
||||
'amount' => $combo['estimated_payout'],
|
||||
], $evaluated['combinations']);
|
||||
$riskPreview = $this->riskPoolService->preview((int) $draw->id, $locks);
|
||||
foreach ($riskPreview as $riskRow) {
|
||||
if ($riskRow['warning']) {
|
||||
$warningRows[] = [
|
||||
'number_4d' => $riskRow['number_4d'],
|
||||
'message' => '该号码赔付池已使用 80% 以上,可能即将售罄',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$rebateAmount = $this->rebateApplicator->displayRebateAmount($player, $evaluated);
|
||||
$totalBet += (int) $evaluated['total_bet_amount'];
|
||||
$totalRebate += $rebateAmount;
|
||||
$totalActualDeduct += (int) $evaluated['actual_deduct_amount'];
|
||||
$totalEstimatedPayout += (int) $evaluated['estimated_max_payout'];
|
||||
|
||||
$lines[] = [
|
||||
'client_line_no' => $index + 1,
|
||||
'provider_code' => $provider['code'],
|
||||
'provider_name' => $provider['name'],
|
||||
'number' => $evaluated['original_number'],
|
||||
'play_code' => $evaluated['play_code'],
|
||||
'normalized_number' => $evaluated['normalized_number'],
|
||||
'combination_count' => $evaluated['combination_count'],
|
||||
'total_bet_amount' => $evaluated['total_bet_amount'],
|
||||
'rebate_rate' => $evaluated['rebate_rate_snapshot'],
|
||||
'rebate_amount' => $rebateAmount,
|
||||
'actual_deduct_amount' => $evaluated['actual_deduct_amount'],
|
||||
'estimated_max_payout' => $evaluated['estimated_max_payout'],
|
||||
'risk_status' => 'ok',
|
||||
'warnings' => [],
|
||||
'rule_snapshot_json' => $evaluated['rule_snapshot_json'],
|
||||
];
|
||||
}
|
||||
|
||||
$rebateAmount = $this->rebateApplicator->displayRebateAmount($player, $evaluated);
|
||||
$totalBet += (int) $evaluated['total_bet_amount'];
|
||||
$totalRebate += $rebateAmount;
|
||||
$totalActualDeduct += (int) $evaluated['actual_deduct_amount'];
|
||||
$totalEstimatedPayout += (int) $evaluated['estimated_max_payout'];
|
||||
|
||||
$lines[] = [
|
||||
'client_line_no' => $index + 1,
|
||||
'number' => $evaluated['original_number'],
|
||||
'play_code' => $evaluated['play_code'],
|
||||
'normalized_number' => $evaluated['normalized_number'],
|
||||
'combination_count' => $evaluated['combination_count'],
|
||||
'total_bet_amount' => $evaluated['total_bet_amount'],
|
||||
'rebate_rate' => $evaluated['rebate_rate_snapshot'],
|
||||
'rebate_amount' => $rebateAmount,
|
||||
'actual_deduct_amount' => $evaluated['actual_deduct_amount'],
|
||||
'estimated_max_payout' => $evaluated['estimated_max_payout'],
|
||||
'risk_status' => 'ok',
|
||||
'warnings' => [],
|
||||
'rule_snapshot_json' => $evaluated['rule_snapshot_json'],
|
||||
];
|
||||
}
|
||||
|
||||
if ($closedPlayCleanupRows !== []) {
|
||||
|
||||
Reference in New Issue
Block a user