diff --git a/.DS_Store b/.DS_Store index a0d7e00..c81fa46 100755 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/App/.DS_Store b/App/.DS_Store index e5893a8..67ce38e 100755 Binary files a/App/.DS_Store and b/App/.DS_Store differ diff --git a/App/Controllers/.DS_Store b/App/Controllers/.DS_Store index 94d94f2..fd23da5 100755 Binary files a/App/Controllers/.DS_Store and b/App/Controllers/.DS_Store differ diff --git a/App/Controllers/Admin/PK10PeriodController.php b/App/Controllers/Admin/PK10PeriodController.php index ebe58e2..a920965 100644 --- a/App/Controllers/Admin/PK10PeriodController.php +++ b/App/Controllers/Admin/PK10PeriodController.php @@ -201,27 +201,24 @@ class PK10PeriodController extends AdminBaseController { 'win_amount' => $winAmount, ], ['id' => $bet['id']]); - // 非虚拟账户才更新余额 - if (!(int)$bet['is_virtual']) { - $stmt = $this->db->medoo->pdo->prepare("SELECT balance FROM users WHERE id = :id FOR UPDATE"); - $stmt->execute([':id' => $bet['user_id']]); - $user = $stmt->fetch(\PDO::FETCH_ASSOC); - $newBalance = (float)$user['balance'] + $payout; + $stmt = $this->db->medoo->pdo->prepare("SELECT balance FROM users WHERE id = :id FOR UPDATE"); + $stmt->execute([':id' => $bet['user_id']]); + $user = $stmt->fetch(\PDO::FETCH_ASSOC); + $newBalance = (float)$user['balance'] + $payout; - $this->db->update('users', ['balance' => $newBalance], ['id' => $bet['user_id']]); - $this->db->insert('transactions', [ - 'user_id' => $bet['user_id'], - 'type' => 'win', - 'amount' => $payout, - 'balance_before' => $user['balance'], - 'balance_after' => $newBalance, - 'related_id' => $periodId, - 'description' => 'PK10 Win - Period ' . $period['period_number'], - 'is_virtual' => $bet['is_virtual'], - 'created_at' => date('Y-m-d H:i:s'), - ]); - $totalPayout += $payout; - } + $this->db->update('users', ['balance' => $newBalance], ['id' => $bet['user_id']]); + $this->db->insert('transactions', [ + 'user_id' => $bet['user_id'], + 'type' => 'win', + 'amount' => $payout, + 'balance_before' => $user['balance'], + 'balance_after' => $newBalance, + 'related_id' => $periodId, + 'description' => 'PK10 Win - Period ' . $period['period_number'], + 'is_virtual' => $bet['is_virtual'], + 'created_at' => date('Y-m-d H:i:s'), + ]); + $totalPayout += $payout; $wins++; } else { $this->db->update('bets', ['status' => 'lose', 'win_amount' => 0], ['id' => $bet['id']]); diff --git a/App/Views/.DS_Store b/App/Views/.DS_Store index 90951bd..0cfcd92 100755 Binary files a/App/Views/.DS_Store and b/App/Views/.DS_Store differ diff --git a/App/Views/Web/live.php b/App/Views/Web/live.php index 5a1a7f7..755fde1 100755 --- a/App/Views/Web/live.php +++ b/App/Views/Web/live.php @@ -1437,6 +1437,13 @@ $getOdds = function($type, $target = 'all') use ($oddsList) { _lastPollPeriodId = data.data.id || 0; _lastPollStatus = data.data.status; + + // 同步余额(结算后中奖加款) + if (data.balance !== null && data.balance !== undefined) { + var balanceEl = document.querySelector('.live-balance-amount'); + if (balanceEl) balanceEl.textContent = formatAmount(data.balance); + } + updatePeriodUI(); } else { periodState.status = 'settled'; diff --git a/cron/auto_period_task.php b/cron/auto_period_task.php index c3b4728..f50912c 100644 --- a/cron/auto_period_task.php +++ b/cron/auto_period_task.php @@ -377,22 +377,20 @@ function doSettle($db, $period, $algoClass, $gameType) { 'status' => 'win', 'win_amount' => $winAmount, 'settled_at' => date('Y-m-d H:i:s'), ], ['id' => $bet['id']]); - if (!(int)$bet['is_virtual']) { - $stmt = $db->medoo->pdo->prepare("SELECT balance FROM users WHERE id = :id FOR UPDATE"); - $stmt->execute([':id' => $bet['user_id']]); - $user = $stmt->fetch(\PDO::FETCH_ASSOC); - $newBalance = (float)$user['balance'] + $payout; + $stmt = $db->medoo->pdo->prepare("SELECT balance FROM users WHERE id = :id FOR UPDATE"); + $stmt->execute([':id' => $bet['user_id']]); + $user = $stmt->fetch(\PDO::FETCH_ASSOC); + $newBalance = (float)$user['balance'] + $payout; - $db->update('users', ['balance' => $newBalance], ['id' => $bet['user_id']]); - $db->insert('transactions', [ - 'user_id' => $bet['user_id'], 'type' => 'win', - 'amount' => $payout, 'balance_before' => $user['balance'], - 'balance_after' => $newBalance, 'related_id' => $periodId, - 'description' => $gameName . ' Auto Win - ' . $period['period_number'], - 'is_virtual' => $bet['is_virtual'], 'created_at' => date('Y-m-d H:i:s'), - ]); - $totalPayout += $payout; - } + $db->update('users', ['balance' => $newBalance], ['id' => $bet['user_id']]); + $db->insert('transactions', [ + 'user_id' => $bet['user_id'], 'type' => 'win', + 'amount' => $payout, 'balance_before' => $user['balance'], + 'balance_after' => $newBalance, 'related_id' => $periodId, + 'description' => $gameName . ' Auto Win - ' . $period['period_number'], + 'is_virtual' => $bet['is_virtual'], 'created_at' => date('Y-m-d H:i:s'), + ]); + $totalPayout += $payout; $wins++; } else { $db->update('bets', [