StoreCreateInstantBill.php 1.1 KB

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