ProcessCreateInstantBill.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Jobs;
  3. use App\Process;
  4. use App\Services\LogService;
  5. use App\Services\ProcessService;
  6. use Illuminate\Bus\Queueable;
  7. use Illuminate\Contracts\Queue\ShouldQueue;
  8. use Illuminate\Foundation\Bus\Dispatchable;
  9. use Illuminate\Queue\InteractsWithQueue;
  10. use Illuminate\Queue\SerializesModels;
  11. class ProcessCreateInstantBill implements ShouldQueue
  12. {
  13. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  14. protected $process;
  15. /**
  16. * Create a new job instance.
  17. *
  18. * @param Process $process
  19. * @return void
  20. */
  21. public function __construct(Process $process)
  22. {
  23. $this->process = $process;
  24. }
  25. /**
  26. * Execute the job.
  27. *
  28. * @param ProcessService $service
  29. * @return void
  30. * @throws
  31. */
  32. public function handle(ProcessService $service)
  33. {
  34. try{
  35. $service->createInstantBill($this->process);
  36. }catch (\Exception $e){
  37. LogService::log(__METHOD__,"ERROR-入库生成即时账单",$this->process->toJson()." | ".$e->getMessage());
  38. throw new \Exception($e->getMessage());
  39. }
  40. }
  41. }