LaborApplyRecordJob.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. class LaborApplyRecordJob implements ShouldQueue
  11. {
  12. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  13. /** @var $service LaborApplyService */
  14. private $service;
  15. //是否为追加
  16. private $isAppend = false;
  17. /**
  18. * Create a new job instance.
  19. *
  20. * @return void
  21. */
  22. public function __construct(bool $isAppend = false)
  23. {
  24. $this->service = app('LaborApplyService');
  25. $this->isAppend = $isAppend;
  26. }
  27. /**
  28. * Execute the job.
  29. * @return void
  30. * @throws WarningException
  31. */
  32. public function handle()
  33. {
  34. $response = $this->service->allocationLaborToLaborCompany($this->isAppend);
  35. if (!$response['success']) throw new WarningException($response['error_message']);
  36. }
  37. }