소스 검색

祯仓推送波次

haozi 4 년 전
부모
커밋
ada1645090
3개의 변경된 파일50개의 추가작업 그리고 9개의 파일을 삭제
  1. 4 4
      app/Http/Controllers/TestController.php
  2. 45 0
      app/Jobs/BroadcastBatchToZhengCangJob.php
  3. 1 5
      app/Services/ForeignZhenCangService.php

+ 4 - 4
app/Http/Controllers/TestController.php

@@ -22,6 +22,7 @@ use App\Http\Controllers\api\thirdPart\syrius\units\StorageTypeAttribute;
 use App\Http\Requests\AndroidGateRequest;
 use App\Http\Requests\OrderDelivering;
 use App\Jobs\BatchTaskJob;
+use App\Jobs\BroadcastBatchToZhengCangJob;
 use App\Jobs\CacheShelfTaskJob;
 use App\Jobs\OrderCreateInstantBill;
 use App\Jobs\OrderCreateWaybill;
@@ -762,9 +763,8 @@ sql;
 
     public function testZhenCang()
     {
-        $batches=Batch::query()->with(['orders.orderCommodities.commodity.barcodes'])->find(161071);
-        /** @var ForeignZhenCangService  $foreignZhenCangService */
-       $foreignZhenCangService=app('ForeignZhenCangService');;
-       $foreignZhenCangService->broadcastBatch($batches);
+        $batches=Batch::query()->where('id',161071)->get();
+        BroadcastBatchToZhengCangJob::dispatch($batches);
+
     }
 }

+ 45 - 0
app/Jobs/BroadcastBatchToZhengCangJob.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Batch;
+use App\Services\ForeignZhenCangService;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+class BroadcastBatchToZhengCangJob implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    private $batches;
+
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct($batches)
+    {
+        $this->batches=$batches;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        /** @var ForeignZhenCangService  $foreignZhenCangService */
+        $foreignZhenCangService=app('ForeignZhenCangService');
+        foreach ($this->batches as &$batch){
+            $batch->loadMissing([
+                'orders.orderCommodities.commodity.barcodes'
+            ]);
+            $foreignZhenCangService->broadcastBatch($batch);
+        }
+    }
+}

+ 1 - 5
app/Services/ForeignZhenCangService.php

@@ -33,13 +33,9 @@ class ForeignZhenCangService
             }
             $body['orders'][] = $orderArr;
         }
+        dd($body);
         $response = Http::withHeaders([
             'Host' => 'zc-it.com',
         ])->post('http://1.116.164.201:8080/api/createBatch',$body);
     }
-
-    public function broadcastBatchByFlux()
-    {
-
-    }
 }