Add baccarat loss cover activity

This commit is contained in:
2026-04-11 23:27:29 +08:00
parent dd9a8c5db8
commit e43dceab2c
22 changed files with 1898 additions and 5 deletions
+7 -2
View File
@@ -20,6 +20,7 @@ use App\Events\MessageSent;
use App\Models\BaccaratBet;
use App\Models\BaccaratRound;
use App\Models\GameConfig;
use App\Services\BaccaratLossCoverService;
use App\Services\ChatStateService;
use App\Services\UserCurrencyService;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -49,6 +50,7 @@ class CloseBaccaratRoundJob implements ShouldQueue
public function handle(
UserCurrencyService $currency,
ChatStateService $chatState,
BaccaratLossCoverService $lossCoverService,
): void {
$round = $this->round->fresh();
@@ -95,7 +97,7 @@ class CloseBaccaratRoundJob implements ShouldQueue
$winners = [];
$losers = [];
DB::transaction(function () use ($bets, $result, $config, $currency, &$totalPayout, &$winners, &$losers) {
DB::transaction(function () use ($bets, $result, $config, $currency, $lossCoverService, &$totalPayout, &$winners, &$losers) {
foreach ($bets as $bet) {
/** @var \App\Models\BaccaratBet $bet */
$username = $bet->user->username ?? '匿名';
@@ -103,6 +105,7 @@ class CloseBaccaratRoundJob implements ShouldQueue
if ($result === 'kill') {
// 庄家收割:全灭无退款
$bet->update(['status' => 'lost', 'payout' => 0]);
$lossCoverService->registerSettlement($bet->fresh());
$losers[] = "{$username}-{$bet->amount}";
if ($username === 'AI小班长') {
@@ -126,6 +129,7 @@ class CloseBaccaratRoundJob implements ShouldQueue
"百家乐 #{$this->round->id}{$bet->betTypeLabel()} 中奖",
);
$totalPayout += $payout;
$lossCoverService->registerSettlement($bet->fresh());
$winners[] = "{$username}+".number_format($payout);
if ($username === 'AI小班长') {
@@ -133,6 +137,7 @@ class CloseBaccaratRoundJob implements ShouldQueue
}
} else {
$bet->update(['status' => 'lost', 'payout' => 0]);
$lossCoverService->registerSettlement($bet->fresh());
$losers[] = "{$username}-".number_format($bet->amount);
if ($username === 'AI小班长') {
@@ -227,7 +232,7 @@ class CloseBaccaratRoundJob implements ShouldQueue
// 触发微信机器人消息推送 (百家乐结果,无人参与时不推送微信群防止刷屏)
try {
if (!empty($winners) || !empty($losers)) {
if (! empty($winners) || ! empty($losers)) {
$wechatService = new \App\Services\WechatBot\WechatNotificationService;
$wechatService->notifyBaccaratResult($content);
}