PackageCollectingAllocation.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Jobs;
  3. use App\OrderPackage;
  4. use App\Services\OrderPackageService;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use Illuminate\Foundation\Bus\Dispatchable;
  8. use Illuminate\Queue\InteractsWithQueue;
  9. use Illuminate\Support\Facades\Log;
  10. class PackageCollectingAllocation implements ShouldQueue
  11. {
  12. use Dispatchable, InteractsWithQueue, Queueable;
  13. /** @var OrderPackage|\stdClass $orderPackage */
  14. private $orderPackage;
  15. /** @var int|null|string */
  16. private $lineNo;
  17. /**
  18. * Create a new job instance.
  19. *
  20. * @return void
  21. */
  22. public function __construct(OrderPackage $package,int $lineNo)
  23. {
  24. $this->orderPackage = $package;
  25. $this->lineNo = $lineNo;
  26. }
  27. /**
  28. * Execute the job.
  29. *
  30. * @return void
  31. */
  32. public function handle()
  33. {
  34. /** @var OrderPackageService $orderPackageService */
  35. $orderPackageService = app('OrderPackageService');
  36. $result = $orderPackageService->collectUpload([$this->orderPackage->logistic_number]);
  37. if (!$result["success"]){
  38. Log::warning("自动揽收失败",["message"=>$result["message"],"param"=>$this->orderPackage->logistic_number]);
  39. return;
  40. }
  41. if (OrderPackage::query()->where("id",$this->orderPackage->id)
  42. ->where("collecting_status",'0')->update(["collecting_status"=>'1'])!=1)
  43. Log::warning("自动揽收异常",["message"=>"未能成功修改揽收标记","param"=>$this->orderPackage->toArray()]);
  44. /*$result = app("OrderService")->allocation($this->orderPackage->order->code,$this->lineNo);
  45. if (mb_substr($result,0,3)=='000'){
  46. if (OrderPackage::query()->where("id",$this->orderPackage->id)
  47. ->where("collecting_status",'0')->update(["collecting_status"=>'1'])!=1)
  48. Log::warning("自动揽收异常",["message"=>"未能成功修改揽收标记","param"=>$this->orderPackage->toArray()]);
  49. }else Log::warning("自动揽收失败",["message"=>"分配失败:{$result}","param"=>$this->orderPackage->order->code." : {$this->lineNo}"]);*/
  50. }
  51. }