WeightUpdateInstantBill.php 1.4 KB

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