|
@@ -52,19 +52,8 @@ class SuperballUpdatePoolAndStats extends Command
|
|
|
|
|
|
|
|
// 2. 确保当日 superball_daily 记录存在
|
|
// 2. 确保当日 superball_daily 记录存在
|
|
|
DB::connection('write')->transaction(function () use ($dateStr, $poolAmount, $today) {
|
|
DB::connection('write')->transaction(function () use ($dateStr, $poolAmount, $today) {
|
|
|
- // getOrCreateDaily 已经保证有一条记录(带 lucky_number),此处再加锁更新
|
|
|
|
|
- $daily = DB::connection('write')->table(TableName::agent() . 'superball_daily')
|
|
|
|
|
- ->where('pool_date', $dateStr)
|
|
|
|
|
- ->lockForUpdate()
|
|
|
|
|
- ->first();
|
|
|
|
|
-
|
|
|
|
|
- if (!$daily) {
|
|
|
|
|
- $this->service->getOrCreateDaily($dateStr);
|
|
|
|
|
- $daily = DB::connection('write')->table(TableName::agent() . 'superball_daily')
|
|
|
|
|
- ->where('pool_date', $dateStr)
|
|
|
|
|
- ->lockForUpdate()
|
|
|
|
|
- ->first();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 确保记录存在(getOrCreateDaily 只在不存在时插入)
|
|
|
|
|
+ $this->service->getOrCreateDaily($dateStr);
|
|
|
|
|
|
|
|
// 3. 计算本次要增加的 completed_count 和 total_balls
|
|
// 3. 计算本次要增加的 completed_count 和 total_balls
|
|
|
$hour = (int)$today->format('G'); // 0-23
|
|
$hour = (int)$today->format('G'); // 0-23
|
|
@@ -86,8 +75,8 @@ class SuperballUpdatePoolAndStats extends Command
|
|
|
->where('pool_date', $dateStr)
|
|
->where('pool_date', $dateStr)
|
|
|
->update([
|
|
->update([
|
|
|
'pool_amount' => $poolAmount,
|
|
'pool_amount' => $poolAmount,
|
|
|
- 'completed_count' => (int)$daily->completed_count + $completedInc,
|
|
|
|
|
- 'total_balls' => (int)$daily->total_balls + $ballsInc,
|
|
|
|
|
|
|
+ 'completed_count' => DB::raw("completed_count + {$completedInc}"),
|
|
|
|
|
+ 'total_balls' => DB::raw("total_balls + {$ballsInc}"),
|
|
|
'updated_at' => now()->format('Y-m-d H:i:s'),
|
|
'updated_at' => now()->format('Y-m-d H:i:s'),
|
|
|
]);
|
|
]);
|
|
|
});
|
|
});
|
|
@@ -103,4 +92,5 @@ class SuperballUpdatePoolAndStats extends Command
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
+}
|
|
|
|
|
+
|