Fixed cronjobs
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
+14
-12
@@ -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,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user