From 454d83de2e8d3a1eb19c6eb38f7680577e59f7e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20G=C3=BCnther?=
Date: Thu, 14 May 2026 16:58:41 +0200
Subject: [PATCH] Fixed cronjobs
---
app/Providers/CronTaskHandleProvider.php | 7 +++++--
app/Tasks/CloseCostUnit.php | 17 +++++++++++++---
app/Tasks/CloseEvent.php | 2 +-
app/Tasks/NotifyTeam.php | 26 +++++++++++++-----------
4 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/app/Providers/CronTaskHandleProvider.php b/app/Providers/CronTaskHandleProvider.php
index 32b82f9..31283c6 100644
--- a/app/Providers/CronTaskHandleProvider.php
+++ b/app/Providers/CronTaskHandleProvider.php
@@ -41,10 +41,13 @@ class CronTaskHandleProvider extends CommonController
// --- Daily Tasks ---
if ($task->execution_type === CronTaskType::CRON_TASK_TYPE_DAILY) {
- $scheduledTime = $task->schedule_time;
+ $scheduledTime = \DateTime::createFromFormat('Y-m-d H:i:s', date('Y-m-d ') . $task->schedule_time);
+ $now = Carbon::now();
+
+
$alreadyRunToday = $task->last_run?->isToday() ?? false;
- if (!$alreadyRunToday && $now->format('H:i') === $scheduledTime) {
+ if (!$alreadyRunToday && $now >= $scheduledTime) {
$this->runTask($task);
}
}
diff --git a/app/Tasks/CloseCostUnit.php b/app/Tasks/CloseCostUnit.php
index 42a5ae3..a4dfdd2 100644
--- a/app/Tasks/CloseCostUnit.php
+++ b/app/Tasks/CloseCostUnit.php
@@ -2,6 +2,8 @@
namespace App\Tasks;
+use App\Domains\CostUnit\Actions\ChangeCostUnitState\ChangeCostUnitStateCommand;
+use App\Domains\CostUnit\Actions\ChangeCostUnitState\ChangeCostUnitStateRequest;
use App\Models\CostUnit;
use App\Repositories\CostUnitRepository;
@@ -12,9 +14,18 @@ class CloseCostUnit implements CronTask {
$costUnitRepository = new CostUnitRepository();
/** @var CostUnit $costUnit */
foreach ($costUnitRepository->getCurrentEvents() as $costUnit) {
- if (\DateTime::createFromFormat('Y-m-d', $costUnit->billing_deadline) < $now ) {
- $costUnit->allow_new = false;
- $costUnit->save();
+ $billingEndTime = \DateTime::createFromFormat('Y-m-d H:i:s', $costUnit['billing_deadline']);
+ $billingEndTime->setTime(0,0,0);
+ $billingEndTime->add(new \DateInterval('P1D'));
+
+ $now = now();
+
+ if ($billingEndTime < $now) {
+ new ChangeCostUnitStateCommand(
+ new ChangeCostUnitStateRequest(
+ CostUnit::where('id', $costUnit['id'])->first(),false, false
+ )
+ )->execute();
}
}
}
diff --git a/app/Tasks/CloseEvent.php b/app/Tasks/CloseEvent.php
index 77cd5fa..575578d 100644
--- a/app/Tasks/CloseEvent.php
+++ b/app/Tasks/CloseEvent.php
@@ -12,7 +12,7 @@ class CloseEvent implements CronTask {
$eventRepository = new EventRepository();
/** @var Event $event */
foreach ($eventRepository->getAvailable(false) as $event) {
- if ($event->registration_final_end < $now ) {
+ if ($event->registration_final_end <= $now ) {
$event->registration_allowed = false;
$event->save();
}
diff --git a/app/Tasks/NotifyTeam.php b/app/Tasks/NotifyTeam.php
index 13e9c23..95eac12 100644
--- a/app/Tasks/NotifyTeam.php
+++ b/app/Tasks/NotifyTeam.php
@@ -16,26 +16,28 @@ use Psr\Log\LoggerInterface;
class NotifyTeam implements CronTask {
public function handle(): void
{
- if (date('w') !== 0) {
- // return;
+ if ((int)date('w') !== 0) {
+ return;
}
$eventRepository = new EventRepository();
/** @var Event $event */
foreach ($eventRepository->getAvailable(false) as $event) {
foreach (Tenant::all() as $tenant) {
+ echo $tenant->slug . PHP_EOL;
$participants = $event->participants()->where('local_group', $tenant->slug)->whereNull('unregistered_at')->get();
+
+
+ if ($participants->isEmpty()) {
+ continue;
+ }
+
+
+ Mail::to($tenant->email)->send(new InformLocalGroupMail(
+ event: $event,
+ participants: $participants,
+ ));
}
-
- if ($participants->isEmpty()) {
- continue;
- }
-
-
- Mail::to($tenant->email)->send(new InformLocalGroupMail(
- event: $event,
- participants: $participants,
- ));
}
}
}