Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $time = time();
     $city = $this->option('city');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     $tm = new TMBase($this->city);
     $res = $tm->get_drivers_info();
     if ($res->code == 0) {
         foreach ($res->data->drivers_info as $value) {
             $driver = Driver::on($this->city->db)->find($value->driver_id);
             $type = $this->getDriverType($value->name);
             if (!isset($driver)) {
                 $insertion = ['id' => $value->driver_id, 'name' => $value->name, 'mobile' => $value->mobile_phone, 'balans' => $value->balance, 'is_locked' => $value->is_locked, 'is_new' => 1, 'uptime' => $time, 'deleted' => 0, 'type' => $type];
                 Driver::on($this->city->db)->insert($insertion);
                 $this->call('drivers:create', ['id' => $value->driver_id, '--city' => $city]);
             } else {
                 $driver->name = $value->name;
                 $driver->type = $type;
                 $driver->is_locked = $value->is_locked;
                 $driver->mobile = $value->mobile_phone;
                 $driver->balans = $value->balance;
                 $driver->uptime = $time;
                 $driver->save();
             }
         }
     }
     $this->endUpdate($time);
 }
Ejemplo n.º 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     $start_day = strtotime('now 00:00:00');
     $end_day = strtotime('now 23:59:59');
     $insertCollection = Collection::make();
     $updateCollection = Collection::make();
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     $tm = new TMBase($this->city);
     $shifts = $tm->get_shifts($start_day, $end_day);
     DB::beginTransaction();
     foreach ($shifts as $v) {
         $crew = Crews::on($this->city->db)->where('driver', $v->driver_id)->first();
         $insertion = ['id' => empty($v->shift_id) ? 'NULL' : $v->shift_id, 'driver' => empty($v->driver_id) ? 'NULL' : $v->driver_id, 'begin' => empty($v->plan_shift_start_time) ? 'NULL' : strtotime($v->plan_shift_start_time), 'end' => empty($v->plan_shift_finish_time) ? 'NULL' : strtotime($v->plan_shift_finish_time), 'crew' => isset($crew->id) ? $crew->id : 'NULL', 'type' => empty($v->shift_state) ? 'NULL' : $v->shift_state, 'uptime' => time()];
         $shift = \App\Models\Smens::on($this->city->db)->find($v->shift_id);
         if (empty($shift)) {
             $insertCollection->push($insertion);
             $driver = Driver::on($this->city->db)->find($v->driver_id);
             if (!empty($driver) && $v->plan_shift_cost != 1 && $this->city->transfer_to_debtors == "1") {
                 $locked_alias = Driver::getLockedDriver($this->city->db, $driver->name);
                 if (!empty($locked_alias)) {
                     $summ = $locked_alias->balans > -2000 ? abs($locked_alias->balans) : $this->city->transfer_to_debtor_price;
                     $this->call('drivers:operations', ['driver' => $driver->id, 'op' => '0', 'summ' => $summ, 'reason' => 'Перевод в счет долга', 'time' => time(), '--city' => $city]);
                     $this->call('drivers:operations', ['driver' => $locked_alias->id, 'op' => '1', 'summ' => $summ, 'reason' => 'Перевод в счет долга', 'time' => time(), '--city' => $city]);
                     $locked_a2 = Driver::on($this->city->db)->find($locked_alias->id);
                     if (isset($locked_a2) && $locked_a2->balans >= 0) {
                         $this->call('drivers:delete', ['id' => $locked_a2->id, '--city' => $city]);
                     }
                 }
             }
         }
     }
     if (!$insertCollection->isEmpty()) {
         \App\Models\Smens::on($this->city->db)->insert($insertCollection->toArray());
     }
     DB::commit();
 }
Ejemplo n.º 3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     $tm = new TMBase($this->city);
     $cars = $tm->get_cars_info();
     $collection = Collection::make();
     if (!empty($cars)) {
         DB::beginTransaction();
         DB::connection($this->city->db)->table('cars')->truncate();
         foreach ($cars as $v) {
             $insertion = ['id' => empty($v->car_id) ? 'NULL' : $v->car_id, 'code' => empty($v->code) ? 'NULL' : $v->code, 'gn' => empty($v->gos_number) ? 'NULL' : $v->gos_number, 'color' => empty($v->color) ? 'NULL' : $v->color, 'mark' => empty($v->mark) ? 'NULL' : $v->mark, 'is_locked' => empty($v->is_locked) ? 'NULL' : $v->is_locked, 'deleted' => 0, 'uptime' => time(), 'last_call' => 0];
             $collection->push($insertion);
         }
         DB::connection($this->city->db)->table('cars')->insert($collection->toArray());
     }
     DB::commit();
 }
Ejemplo n.º 4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     $tm = new TMBase($this->city);
     $crews = $tm->get_all_crews();
     $collection = Collection::make();
     DB::beginTransaction();
     if (!empty($crews)) {
         DB::connection($this->city->db)->table('crews')->truncate();
         foreach ($crews as $v) {
             $insertion = ['id' => isset($v->crew_id) ? $v->crew_id : 0, 'code' => isset($v->code) ? $v->code : 0, 'car' => isset($v->car_id) ? $v->car_id : NULL, 'driver' => isset($v->driver_id) ? $v->driver_id : NULL, 'uptime' => time(), 'deleted' => 0];
             $collection->push($insertion);
         }
         DB::connection($this->city->db)->table('crews')->insert($collection->toArray());
     }
     DB::commit();
 }
Ejemplo n.º 5
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     $tm = new TMBase($this->city);
     $cars = $tm->get_cars_info();
     $collection = Collection::make();
     if (!empty($cars)) {
         DB::beginTransaction();
         DB::connection($this->city->db)->table('cars_info')->truncate();
         foreach ($cars as $v) {
             $insertion = ['car_id' => empty($v->car_id) ? 'NULL' : $v->car_id, 'code' => empty($v->code) ? 'NULL' : $v->code, 'name' => empty($v->name) ? 'NULL' : $v->name, 'gos_nomer' => empty($v->gos_number) ? 'NULL' : $v->gos_number, 'color' => empty($v->color) ? 'NULL' : $v->color, 'mark' => empty($v->mark) ? 'NULL' : $v->mark, 'model' => empty($v->model) ? 'NULL' : $v->model, 'short_name' => empty($v->short_name) ? 'NULL' : $v->short_name, 'production_year' => empty($v->production_year) ? 'NULL' : $v->production_year, 'is_locked' => empty($v->is_locked) ? 'NULL' : $v->is_locked, 'updated' => date('Y-m-d H:i:s', time())];
             $collection->push($insertion);
         }
         DB::connection($this->city->db)->table('cars_info')->insert($collection->toArray());
     }
     DB::commit();
 }
Ejemplo n.º 6
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     $tm = new TMBase($this->city);
     $crews = $tm->get_crew_coords();
     $collection = Collection::make();
     DB::beginTransaction();
     if (!empty($crews)) {
         DB::connection($this->city->db)->table('crews_inline')->truncate();
         foreach ($crews as $v) {
             $insertion = ['id' => empty($v->crew_id) ? 'NULL' : $v->crew_id, 'code' => empty($v->crew_code) ? 'NULL' : $v->crew_code, 'lat' => empty($v->lat) ? 'NULL' : $v->lat, 'lon' => empty($v->lon) ? 'NULL' : $v->lon, 'status' => empty($v->state_kind) ? 'NULL' : $v->state_kind, 'uptime' => time()];
             $collection->push($insertion);
         }
         DB::connection($this->city->db)->table('crews_inline')->insert($collection->toArray());
     }
     DB::commit();
 }
Ejemplo n.º 7
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     $tm = new TMBase($this->city);
     $crews = $tm->get_all_crews();
     $collection = Collection::make();
     DB::beginTransaction();
     if (!empty($crews)) {
         DB::connection($this->city->db)->table('crews_info')->truncate();
         foreach ($crews as $v) {
             $insertion = ['crew_id' => empty($v->crew_id) ? 'NULL' : $v->crew_id, 'code' => empty($v->code) ? 'NULL' : $v->code, 'name' => empty($v->name) ? 'NULL' : $v->name, 'driver_id' => empty($v->driver_id) ? 'NULL' : $v->driver_id, 'car_id' => empty($v->car_id) ? 'NULL' : $v->car_id, 'shashka' => empty($v->car_id) ? 'NULL' : $v->has_light_house, 'updated' => date('Y-m-d H:i:s', time())];
             $collection->push($insertion);
         }
         DB::connection($this->city->db)->table('crews_info')->insert($collection->toArray());
     }
     DB::commit();
 }