/** * Execute the console command. * * @return mixed */ public function fire(Almaty $almaty, Astana $astana) { $time = time() - 86400; $city = $this->option('city'); if ($city == 1) { $this->city = $almaty; } else { $this->city = $astana; } if ($this->city->overmilleage == "0") { return false; } $wialon = new Wialon($this->city); $wialon->get_report(); $milleages = Overmileage::on($this->city->db)->where('run', '=', '0')->where('time', '>', $time)->get(); if (!$milleages->isEmpty()) { foreach ($milleages as $v) { $km = $v->mileage - 350; $pcm = $this->city->overmilleage_price; $summ = $km * $pcm; $driver = Driver::getDriverInfoByCar($this->city->db, $v->gn); if (isset($driver->driver_id)) { $this->call('drivers:operations', ['driver' => $driver->driver_id, 'op' => 0, 'summ' => $summ, 'reason' => 'Суточный перепробег', 'time' => time(), '--city' => $city]); $v->run = 1; $v->save(); } } } }