Add baccarat loss cover activity
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user