RejectedPushJob.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace App\Jobs;
  3. use App\OracleDOCASNDetail;
  4. use App\OracleDOCASNHeader;
  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\Queue\SerializesModels;
  10. use Illuminate\Support\Facades\Http;
  11. use Illuminate\Support\Facades\Log;
  12. /**
  13. * @Deprecated 退货推单
  14. */
  15. class RejectedPushJob implements ShouldQueue
  16. {
  17. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  18. public $tries = 5;
  19. public $timeout = 120;
  20. /**
  21. * type: 推单,上架
  22. * [
  23. * ['sku' => '75603675975072','taskNum' => 'JI20220316211', 'asnNo' => 'asn002', 'type' => '推单'],
  24. * ['sku' => '75603675975072','taskNum' => 'JI20220316211', 'asnNo' => 'asn002', 'type' => '推单'],
  25. * ]
  26. */
  27. private $asnNos;
  28. /**
  29. * RejectedPushJob constructor.
  30. * @param array $asnNos
  31. */
  32. public function __construct(array $asnNos)
  33. {
  34. $this->asnNos = $asnNos;
  35. }
  36. /**
  37. * Execute the job.
  38. *
  39. * @return void
  40. */
  41. public function handle()
  42. {
  43. $result = array();
  44. $array = array();
  45. if (count($this->asnNos) > 0) {
  46. $asnHerders=OracleDOCASNHeader::query()->whereIn('asnno',$this->asnNos)
  47. ->select('asnno','notes','asntype','asnstatus')
  48. ->get();
  49. foreach ($asnHerders as $asnHerder) {
  50. if ($asnHerder->asntype == 'THRK' && $asnHerder->notes) {
  51. preg_match('/^[A-Z]{2}[0-9]{8}\d{0,8}/', $asnHerder->notes, $result);
  52. if (count($result) < 1) continue;
  53. $details = OracleDOCASNDetail::query()->select('sku', 'linestatus')->where('asnno', $asnHerder->asnno)->get();
  54. if (count($details) < 1) continue;
  55. foreach ($details as $detail) {
  56. $array[] = [
  57. 'sku' => $detail->sku,
  58. 'taskNum' => $result[0],
  59. 'asnNo' => $asnHerder->asnno,
  60. 'type' => $detail->linestatus == '99' ? '上架' : '推单'
  61. ];
  62. }
  63. }
  64. }
  65. }
  66. $url = config('api.java.wms.rejectedPushTask.receivePush');
  67. if (count($array) > 0) {
  68. $response = Http::post($url, $array);
  69. Log::info("推送信息!", ['res' => $response->body(), 'req' => $array]);
  70. }else{
  71. Log::info("推送信息失败!", ['res' => $this->asnNos,'array'=>$array]);
  72. }
  73. }
  74. }