feat: enhance configuration and logging for admin services
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
- Updated .env.example to enable Redis Lua for lottery risk pool and added configuration for agent settlement. - Improved AGENTS.md to clarify site operations and admin roles. - Enhanced PHPUnit configuration with memory limit and cache directory settings. - Refactored AdminReportQueryService and related services to utilize LimitedQuery for better data handling and truncation warnings. - Added logging for draw settlement failures in DrawTickService. - Introduced credit preflight checks and reverse bet hold functionality in PlayerCreditService. - Improved risk pool management with new Redis lock handling in RiskPoolService and TicketPlacementService.
This commit is contained in:
@@ -72,6 +72,8 @@ final class TicketPlacementService
|
||||
}
|
||||
|
||||
try {
|
||||
$riskRedisCompensation = [];
|
||||
|
||||
$placement = DB::transaction(function () use (
|
||||
$player,
|
||||
$currencyCode,
|
||||
@@ -79,7 +81,17 @@ final class TicketPlacementService
|
||||
$expectedVersions,
|
||||
$clientTraceId,
|
||||
$drawNo,
|
||||
&$riskRedisCompensation,
|
||||
): array {
|
||||
DB::afterRollback(function () use (&$riskRedisCompensation): void {
|
||||
foreach ($riskRedisCompensation as $entry) {
|
||||
$this->riskPoolService->compensateRedisAcquires(
|
||||
(int) $entry['draw_id'],
|
||||
$entry['locks'],
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$draw = Draw::query()
|
||||
->where('draw_no', $drawNo)
|
||||
->lockForUpdate()
|
||||
@@ -162,7 +174,9 @@ final class TicketPlacementService
|
||||
|
||||
$creditLine = PlayerFundingMode::usesCredit($player);
|
||||
|
||||
if (! $creditLine) {
|
||||
if ($creditLine) {
|
||||
$this->playerCreditService->assertCreditPreflight($player, $totalActualDeduct);
|
||||
} else {
|
||||
$wallet = PlayerWallet::query()
|
||||
->where('player_id', $player->id)
|
||||
->where('wallet_type', 'lottery')
|
||||
@@ -295,6 +309,10 @@ final class TicketPlacementService
|
||||
$successTotalRebate += $rebateAmount;
|
||||
$successTotalActualDeduct += (int) $evaluated['actual_deduct_amount'];
|
||||
$successTotalEstimatedPayout += (int) $evaluated['estimated_max_payout'];
|
||||
$riskRedisCompensation[] = [
|
||||
'draw_id' => (int) $draw->id,
|
||||
'locks' => $locks,
|
||||
];
|
||||
}
|
||||
|
||||
if ($successfulItems === []) {
|
||||
@@ -370,7 +388,7 @@ final class TicketPlacementService
|
||||
])->save();
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
DB::transaction(function () use ($order, $player): void {
|
||||
DB::transaction(function () use ($order, $player, $placement): void {
|
||||
$items = TicketItem::query()
|
||||
->where('order_id', $order->id)
|
||||
->where('status', 'pending_confirm')
|
||||
@@ -401,6 +419,11 @@ final class TicketPlacementService
|
||||
if (! PlayerFundingMode::usesCredit($player)) {
|
||||
$this->ticketWalletService->reverseBetDeduct($order);
|
||||
$this->ticketWalletService->releaseReservedBetDeduct($order, 'wallet_deduct_failed_release');
|
||||
} else {
|
||||
$this->playerCreditService->reverseBetHold(
|
||||
$player,
|
||||
(int) $placement['success_total_actual_deduct'],
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user