WeightUpdateInstantBill.php 1.3 KB

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