Commit 17934ed8c044ffb72e0b5426a5b3cc064cc49c3d

Authored by Hayk Nazaryan
Exists in master

Merge branch 'master' of http://gitlab.nologostudio.ru/alarionov/rekamore-su

Showing 1 changed file Inline Diff

app/Console/Commands/DispatchVacancyLiftJobCommand.php
1 <?php 1 <?php
2 2
3 namespace App\Console\Commands; 3 namespace App\Console\Commands;
4 4
5 use App\Jobs\LiftVacancyJob; 5 use App\Jobs\LiftVacancyJob;
6 use App\Jobs\SendVacancyToTelegramJob; 6 use App\Jobs\SendVacancyToTelegramJob;
7 use App\Models\EmployerAutoliftOption; 7 use App\Models\EmployerAutoliftOption;
8 use App\Models\WorkerAutoliftOption; 8 use App\Models\WorkerAutoliftOption;
9 use Illuminate\Console\Command; 9 use Illuminate\Console\Command;
10 10
11 class DispatchVacancyLiftJobCommand extends Command 11 class DispatchVacancyLiftJobCommand extends Command
12 { 12 {
13 protected $signature ='vacancy:dispatch'; 13 protected $signature ='vacancy:dispatch';
14 14
15 public function handle() 15 public function handle()
16 { 16 {
17 $now = now()->timezone('Europe/Moscow')->format('H:i'); 17 $now = now()->timezone('Europe/Moscow')->format('H:i');
18 18
19 $employers = EmployerAutoliftOption::query() 19 $employersAutoLift = EmployerAutoliftOption::query()
20 ->where(function ($query) use ($now) { 20 ->where(function ($query) use ($now) {
21 $query->where('times_per_day', 1) 21 $query->where('times_per_day', 1)
22 ->where('time_send_first', $now); 22 ->where('time_send_first', $now);
23 }) 23 })
24 ->orWhere(function ($query) use ($now) { 24 ->orWhere(function ($query) use ($now) {
25 $query->where('times_per_day', 2) 25 $query->where('times_per_day', 2)
26 ->where(function ($query) use ($now) { 26 ->where(function ($query) use ($now) {
27 $query->where('time_send_first', $now) 27 $query->where('time_send_first', $now)
28 ->orWhere('time_send_second', $now); 28 ->orWhere('time_send_second', $now);
29 }); 29 });
30 }) 30 })
31 ->orWhere(function ($query) use ($now) { 31 ->orWhere(function ($query) use ($now) {
32 $query->where('times_per_day', 3) 32 $query->where('times_per_day', 3)
33 ->where(function ($query) use ($now) { 33 ->where(function ($query) use ($now) {
34 $query->where('time_send_first', $now) 34 $query->where('time_send_first', $now)
35 ->orWhere('time_send_second', $now) 35 ->orWhere('time_send_second', $now)
36 ->orWhere('time_send_third', $now); 36 ->orWhere('time_send_third', $now);
37 }); 37 });
38 38
39 }) 39 })
40 ->orWhere('time_send_tg', $now)
41 ->get(); 40 ->get();
42 41
42
43
43 LiftVacancyJob::dispatch( 44 LiftVacancyJob::dispatch(
44 $employers->whereNotNull('time_send_first')->pluck('employer_id')->toArray(), 45 $employersAutoLift->whereNotNull('time_send_first')->pluck('employer_id')->toArray(),
45 ); 46 );
46 47
48 $employersSendTelegramm = EmployerAutoliftOption::query()
49 ->where('time_send_tg', $now)
50 ->get();
51
47 SendVacancyToTelegramJob::dispatch( 52 SendVacancyToTelegramJob::dispatch(
48 $employers->whereNotNull('time_send_tg')->pluck('employer_id')->toArray() 53 $employersSendTelegramm->whereNotNull('time_send_tg')->pluck('employer_id')->toArray()
49 ); 54 );
50 55
51 return Command::SUCCESS; 56 return Command::SUCCESS;
52 } 57 }
53 } 58 }