Commit bcc3071c0ad8465b15e2d70f39f858f5cb460f32

Authored by Hayk Nazaryan
1 parent 9391c3aa3b
Exists in master

check send telegramm

Showing 1 changed file with 1 additions and 1 deletions 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 $employersAutoLift = 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 ->get(); 40 ->get();
41 41
42 42
43 43
44 LiftVacancyJob::dispatch( 44 LiftVacancyJob::dispatch(
45 $employersAutoLift->whereNotNull('time_send_first')->pluck('employer_id')->toArray(), 45 $employersAutoLift->whereNotNull('time_send_first')->pluck('employer_id')->toArray(),
46 ); 46 );
47 47
48 $employersSendTelegramm = EmployerAutoliftOption::query() 48 $employersSendTelegramm = EmployerAutoliftOption::query()
49 ->orWhere('time_send_tg', $now) 49 ->where('time_send_tg', $now)
50 ->get(); 50 ->get();
51 51
52 SendVacancyToTelegramJob::dispatch( 52 SendVacancyToTelegramJob::dispatch(
53 $employersSendTelegramm->whereNotNull('time_send_tg')->pluck('employer_id')->toArray() 53 $employersSendTelegramm->whereNotNull('time_send_tg')->pluck('employer_id')->toArray()
54 ); 54 );
55 55
56 return Command::SUCCESS; 56 return Command::SUCCESS;
57 } 57 }
58 } 58 }
59 59