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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user