LaborApplyRecordJob.php 1.2 KB

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