Explorar o código

快递信息同步修复 添加日志

ANG YU %!s(int64=4) %!d(string=hai) anos
pai
achega
f5b0e80c3e

+ 1 - 1
app/Console/Commands/SyncOrderPackageLogisticRouteTask.php

@@ -43,7 +43,7 @@ class SyncOrderPackageLogisticRouteTask extends Command
      */
     public function handle()
     {
-        LogService::log(__CLASS__, "同步快递信息", '');
+        LogService::log(SyncOrderPackageLogisticRouteTask::class, "同步快递信息定时任务启动", '');
         ini_set('memory_limit', '2226M');
         $this->service->syncLogisticRoute();
     }

+ 2 - 0
app/Jobs/LogisticSFSync.php

@@ -3,6 +3,7 @@
 namespace App\Jobs;
 
 use App\Services\LogisticSFService;
+use App\Services\LogService;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
@@ -40,6 +41,7 @@ class LogisticSFSync implements ShouldQueue
     public function handle()
     {
         ini_set('max_execution_time', 60);
+        LogService::log(LogisticSFSync::class, "{$this->logistic_number}-JOB-SF", '');
         $this->logisticSFService = app('LogisticSFService');
         $formedData = $this->logisticSFService->get([$this->logistic_number]);
         $this->orderPackageReceivedSyncService = app('OrderPackageReceivedSyncService');

+ 2 - 0
app/Jobs/LogisticYDSync.php

@@ -3,6 +3,7 @@
 namespace App\Jobs;
 
 use App\Services\LogisticYDService;
+use App\Services\LogService;
 use App\Services\OrderPackageReceivedSyncService;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
@@ -43,6 +44,7 @@ class LogisticYDSync implements ShouldQueue
     public function handle()
     {
         ini_set('max_execution_time', 60);
+        LogService::log(LogisticYDSync::class, "{$this->logistic_number}-JOB-YD", '');
         $this->logisticYDService = app('LogisticYDService');
         //先订阅订单
         $this->logisticYDService->registerApi([$this->logistic_number]);

+ 2 - 0
app/Jobs/LogisticYTOSync.php

@@ -4,6 +4,7 @@ namespace App\Jobs;
 
 use App\Services\LogisticYDService;
 use App\Services\LogisticYTOService;
+use App\Services\LogService;
 use App\Services\OrderPackageReceivedSyncService;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
@@ -43,6 +44,7 @@ class LogisticYTOSync implements ShouldQueue
     public function handle()
     {
         ini_set('max_execution_time', 10);
+        LogService::log(LogisticYTOSync::class, "{$this->logistic_number}-JOB-YTO", '');
         $this->logisticYTOService = app('LogisticYTOService');
         $nativeResponse = $this->logisticYTOService->query($this->logistic_number);
         $formattedData = $this->logisticYTOService->format($nativeResponse);

+ 2 - 0
app/Jobs/LogisticZopSync.php

@@ -6,6 +6,7 @@ use App\library\zop\ZopClient;
 use App\library\zop\ZopProperties;
 use App\library\zop\ZopRequest;
 use App\OrderPackage;
+use App\Services\LogService;
 use App\Services\OrderPackageReceivedSyncService;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
@@ -38,6 +39,7 @@ class LogisticZopSync implements ShouldQueue
     public function handle()
     {
         ini_set('max_execution_time', 60);
+        LogService::log(LogisticZopSync::class, "{$this->logistic_number}-JOB-ZOP", '');
         $zopResult = [];
         $response = $this->sentRequestToZT();
         if(is_null($response)) return;

+ 10 - 4
app/Services/OrderPackageReceivedSyncService.php

@@ -26,8 +26,8 @@ class OrderPackageReceivedSyncService
      */
     public function syncLogisticRoute()
     {
+        LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法", '');
         ini_set('max_execution_time', 60 * 60);
-
         //初始化时间 2020-12-31 23:59:59
         $initDate = Carbon::parse(config('api_logistic.init_date'));
         $query = OrderPackage::query()
@@ -48,6 +48,7 @@ class OrderPackageReceivedSyncService
             //sf
             if (array_key_exists('SF', $logisticNumbers)) {
                 $SFLogisticNumbers = $logisticNumbers['SF'];
+                LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-SF", '');
                 foreach ($SFLogisticNumbers as $logisticNumber) {
                     LogisticSFSync::dispatch($logisticNumber);
                 }
@@ -55,6 +56,7 @@ class OrderPackageReceivedSyncService
             //更新中通
             if (array_key_exists('ZTO', $logisticNumbers)) {
                 $ZTOLogisticNumbers = $logisticNumbers['ZTO'];
+                LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-ZTO", '');
                 foreach ($ZTOLogisticNumbers as $logisticNumber) {
                     LogisticZopSync::dispatch($logisticNumber);
                 }
@@ -62,14 +64,18 @@ class OrderPackageReceivedSyncService
             //更新韵达
             if (array_key_exists('YUNDA', $logisticNumbers)) {
                 $YDLogisticNumbers = $logisticNumbers['YUNDA'];
+                LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-YUNDA", '');
                 foreach ($YDLogisticNumbers as $logistic_number) {
                     LogisticYDSync::dispatch($logistic_number);
                 }
             }
             //更新圆通
-            $YTOLogisticNumbers = $logisticNumbers['YTO'];
-            foreach ($YTOLogisticNumbers as $logistic_number) {
-                LogisticYTOSync::dispatch($logistic_number);
+            if (array_key_exists('YTO', $logisticNumbers)) {
+                $YTOLogisticNumbers = $logisticNumbers['YTO'];
+                LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-YTO", '');
+                foreach ($YTOLogisticNumbers as $logistic_number) {
+                    LogisticYTOSync::dispatch($logistic_number);
+                }
             }
         });
     }

+ 0 - 1
tests/Services/OrderPackageReceivedSyncService/SyncLogisticRouteTest.php

@@ -3,7 +3,6 @@
 namespace Tests\Services\OrderPackageReceivedSyncService;
 use App\Services\OrderPackageReceivedSyncService;
 use Tests\TestCase;
-use App\OrderPackageReceivedSync;
 use App\Traits\TestMockSubServices;
 
 class SyncLogisticRouteTest extends TestCase