WeightUpdateInstantBill.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Jobs;
  3. use App\Components\ErrorPush;
  4. use App\OrderPackage;
  5. use App\Services\OrderService;
  6. use Illuminate\Bus\Queueable;
  7. use Illuminate\Contracts\Queue\ShouldQueue;
  8. use Illuminate\Foundation\Bus\Dispatchable;
  9. use Illuminate\Queue\InteractsWithQueue;
  10. class WeightUpdateInstantBill implements ShouldQueue
  11. {
  12. use Dispatchable, InteractsWithQueue, Queueable, ErrorPush;
  13. /** @var \stdClass */
  14. protected $package;
  15. /**
  16. * Create a new job instance.
  17. *
  18. * @param OrderPackage $package
  19. *
  20. * @return void
  21. */
  22. public function __construct(OrderPackage $package)
  23. {
  24. $this->package = $package;
  25. }
  26. /**
  27. * Execute the job.
  28. *
  29. * @param OrderService $service
  30. *
  31. * @return void
  32. * @throws
  33. */
  34. public function handle(OrderService $service)
  35. {
  36. if (!$this->package->weight)return;
  37. $this->package->loadMissing("order");
  38. if (!$this->package->order)return;
  39. try {
  40. $service->reviseLogisticFee($this->package->order);
  41. }catch (\Exception $e){
  42. $this->push(__METHOD__."->".__LINE__,"称重重置订单计费",$e->getMessage()." | ".$this->package->toJson());
  43. throw $e;
  44. }
  45. }
  46. }