StoreCreateInstantBill.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. */
  31. public function handle(StoreService $service)
  32. {
  33. try{
  34. $service->createInstantBill($this->store);
  35. }catch (\Exception $e){
  36. LogService::log(__METHOD__,"ERROR-入库生成即时账单",$this->store->toJson()." | ".$e->getMessage());
  37. }
  38. }
  39. }