public function negativeBalance() { $day_st = strtotime(date('Y-m-d', time())); $has_subzero = Driver::getDriversWithNegativeBalance($this->city->db); foreach ($has_subzero as $v) { $cof = $v->is_locked == 1 ? 0.001 : 0.05; $summ = abs($v->balans) * $cof; $check = DB::connection($this->city->db)->table('operations')->where('driver', $v->id)->where('reason', 'op3')->where('time', '>', $day_st)->first(); if (empty($check)) { $this->dr->MoneyOperations($v->id, 0, 1, 'TEST ', ' NEGA BALANCE' . $summ); } } }
/** * 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; } if ($this->city->negative_balance == "0") { return false; } $drivers = Driver::getDriversWithNegativeBalance($this->city->db); if (!empty($drivers)) { foreach ($drivers as $v) { if ($v->is_locked) { $cof = 0.001; } else { if (abs($v->balans) < 2000) { $cof = 0.05; } else { if (abs($v->balans) >= 2000 && abs($v->balans) < 5000) { $cof = 0.03; } else { if (abs($v->balans) >= 5000 && abs($v->balans) < 7000) { $cof = 0.02; } else { if (abs($v->balans) >= 7000 && abs($v->balans) < 12000) { $cof = 0.01; } else { if (abs($v->balans) >= 12000) { $cof = 0.005; } } } } } } $summ = abs($v->balans) * $cof; $this->call('drivers:operations', ['driver' => $v->id, 'op' => '0', 'summ' => $summ, 'reason' => 'Штраф за отрицательный баланс', 'time' => time(), '--city' => 1]); } } }