| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 | 
							- <?php
 
- /**
 
-  * Created by PhpStorm.
 
-  * User: wuzhenke
 
-  * Date: 2019/2/14
 
-  * Time: 10:03
 
-  */
 
- namespace App\Jobs\Cron;
 
- use App\Models\Company;
 
- use App\Models\Jobs;
 
- use App\Repositories\CompanyRepository;
 
- use App\Repositories\JobsRepository;
 
- use Illuminate\Bus\Queueable;
 
- use Illuminate\Contracts\Queue\ShouldQueue;
 
- use Illuminate\Foundation\Bus\Dispatchable;
 
- use Illuminate\Queue\InteractsWithQueue;
 
- use Illuminate\Queue\SerializesModels;
 
- use Illuminate\Support\Facades\DB;
 
- use Illuminate\Support\Facades\Log;
 
- class ClearExpiredJobsJob implements ShouldQueue
 
- {
 
-     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 
-     /**
 
-      * Create a new job instance.
 
-      *
 
-      * @return void
 
-      */
 
-     public function __construct()
 
-     {
 
-         //
 
-     }
 
-     public function handle(JobsRepository $jobsRepository, CompanyRepository $companyRepository)
 
-     {
 
-         $condition = [
 
-             ['deadline','<', time()],
 
-             ['audit','=',1],
 
-             ['display','=',1],
 
-             ['valid','=',1],
 
-             ['deadline','!=', 0],  //不需要0的
 
-         ];
 
-         $list = $jobsRepository->findWhere($condition);
 
-         $job_id = [];
 
-         $company_ids = [];
 
-         if ($list->isNotEmpty()) {
 
-             foreach ($list as $key => $val) {
 
-                 $job_id[] = $val['id'];
 
-                 $company_ids[]=$val['company_id'];
 
-             }
 
-             if (!empty($job_id)) {
 
-                 if (!$jobsRepository->closeJobs($job_id)) {
 
-                     Log::error('过期职位关闭失败!');
 
-                 }
 
-                 Log::debug("职位过期:", $job_id);
 
-                 $condition = [['whereIn','id', $job_id]];
 
-                 event_search_update(Jobs::class, $condition, 'update');
 
-                 $company_condition = [['whereIn','id', $company_ids]];
 
-                 event_search_update(Company::class, $company_condition, 'update');
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |