|
|
@@ -258,19 +258,15 @@ class SuperballActivityService
|
|
|
->where('task_date', $today)
|
|
|
->update(['status' => 1, 'updated_at' => now()->format('Y-m-d H:i:s')]);
|
|
|
|
|
|
- $daily = DB::connection('write')->table(TableName::agent() . 'superball_daily')
|
|
|
+ // Perform atomic increments in a single query to avoid holding an explicit row lock via SELECT ... FOR UPDATE.
|
|
|
+ // This is safe because we only increment if the record already exists (same behavior as before).
|
|
|
+ DB::connection('write')->table(TableName::agent() . 'superball_daily')
|
|
|
->where('pool_date', $today)
|
|
|
- ->lockForUpdate()
|
|
|
- ->first();
|
|
|
- if ($daily) {
|
|
|
- DB::connection('write')->table(TableName::agent() . 'superball_daily')
|
|
|
- ->where('pool_date', $today)
|
|
|
- ->update([
|
|
|
- 'total_balls' => (int) $daily->total_balls + $ballCount,
|
|
|
- 'completed_count' => (int) $daily->completed_count + 1,
|
|
|
- 'updated_at' => now()->format('Y-m-d H:i:s'),
|
|
|
- ]);
|
|
|
- }
|
|
|
+ ->update([
|
|
|
+ 'total_balls' => DB::raw("total_balls + {$ballCount}"),
|
|
|
+ 'completed_count' => DB::raw('completed_count + 1'),
|
|
|
+ 'updated_at' => now()->format('Y-m-d H:i:s'),
|
|
|
+ ]);
|
|
|
|
|
|
$this->updateUserMultiplier($userId, $today);
|
|
|
});
|