1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Jobs\Cron;
- use App\Models\QueueAutoRefresh;
- use App\Models\Resume;
- use App\Services\Person\ResumeService;
- use Illuminate\Bus\Queueable;
- use Illuminate\Queue\SerializesModels;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Support\Facades\Cache;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Log;
- class ResumeAutoRefresh implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- const CREATE_LIST = 'create';
- const UPDATE_LIST = 'update';
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct()
- {
- }
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle(ResumeService $resumeService)
- {
- $resume_id = $resumeService->resumeAutoRefresh();
- if($resume_id){
- $Resume = Resume::whereIn('id', $resume_id)->get();
- try {
- Resume::whereIn('id', $resume_id)->update(['updated_at'=>date('Y-m-d H:i:s')]);
- QueueAutoRefresh::whereIn('pid', $resume_id)->update(['start_time'=>strtotime("+1 day")]);
- $utype = 2;
- $startTime = time();
- $endTime = strtotime(date('Y-m-d 23:59:59', time()));
- foreach ($Resume as $val){
- if (Cache::has($val->uid.$utype)) {
- $value = Cache::get($val->uid.$utype);
- } else {
- $value = 0;
- }
- Cache::put($val->uid.$utype, $value+1, intval(($endTime-$startTime)/60));
- }
- DB::commit();
- } catch (\Exception $e) {
- DB::rollback();
- }
- }
- }
- }
|