LaborApplyRecordJob.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Jobs;
  3. use App\Exceptions\WarningException;
  4. use App\Services\LaborApplyService;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use Illuminate\Foundation\Bus\Dispatchable;
  8. use Illuminate\Queue\InteractsWithQueue;
  9. use Illuminate\Queue\SerializesModels;
  10. use Illuminate\Support\Facades\Log;
  11. /**
  12. * @Deprecated 临时工分配记录
  13. */
  14. class LaborApplyRecordJob implements ShouldQueue
  15. {
  16. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  17. /** @var $service LaborApplyService */
  18. private $service;
  19. //是否为追加
  20. private $isAppend = false;
  21. /**
  22. * Create a new job instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct(bool $isAppend = false)
  27. {
  28. $this->service = app('LaborApplyService');
  29. $this->isAppend = $isAppend;
  30. }
  31. /**
  32. * Execute the job.
  33. * @return void
  34. * @throws WarningException
  35. */
  36. public function handle()
  37. {
  38. $response = $this->service->allocationLaborToLaborCompany($this->isAppend);
  39. if (!$response['success']) throw new WarningException($response['error_message']);
  40. }
  41. }