Просмотр исходного кода

快递信息同步修复
增加max_execution_time 到60s
优化快递号查询

ANG YU 4 лет назад
Родитель
Сommit
4cc8a9188d

+ 9 - 1
app/Filters/OrderPackageFilters.php

@@ -15,7 +15,7 @@ class OrderPackageFilters
     protected $request;
     protected $request;
     protected $queryBuilder;
     protected $queryBuilder;
     protected $filters = ['logistic_number', 'status', 'received_at_start',
     protected $filters = ['logistic_number', 'status', 'received_at_start',
-        'received_at_end', 'is_weighed', 'logistic_id', 'owner_id', 'sent_at_start', 'sent_at_end', 'is_exception', 'exception_type', 'default_date'];
+        'received_at_end', 'is_weighed', 'logistic_id', 'owner_id', 'sent_at_start', 'sent_at_end', 'is_exception', 'exception_type', 'default_date','has_transfer_status'];
 
 
     public function __construct(Request $request)
     public function __construct(Request $request)
     {
     {
@@ -49,6 +49,14 @@ class OrderPackageFilters
     {
     {
         $this->queryBuilder->where('exception_type', $exception_type);
         $this->queryBuilder->where('exception_type', $exception_type);
     }
     }
+    private function has_transfer_status($has_transfer_status)
+    {
+        if ($has_transfer_status=='是') {
+            $this->queryBuilder->whereNotNull('transfer_status');
+        } elseif ($has_transfer_status=='否') {
+            $this->queryBuilder->whereNull('transfer_status');
+        }
+    }
 
 
     private function status($status)
     private function status($status)
     {
     {

+ 1 - 1
app/Jobs/LogisticYDSync.php

@@ -42,7 +42,7 @@ class LogisticYDSync implements ShouldQueue
      */
      */
     public function handle()
     public function handle()
     {
     {
-        ini_set('max_execution_time', 10);
+        ini_set('max_execution_time', 60);
         $this->logisticYDService = app('LogisticYDService');
         $this->logisticYDService = app('LogisticYDService');
         //先订阅订单
         //先订阅订单
         $this->logisticYDService->registerApi([$this->logistic_number]);
         $this->logisticYDService->registerApi([$this->logistic_number]);

+ 1 - 2
app/Jobs/LogisticZopSync.php

@@ -37,8 +37,7 @@ class LogisticZopSync implements ShouldQueue
      */
      */
     public function handle()
     public function handle()
     {
     {
-        //
-        ini_set('max_execution_time', 10);
+        ini_set('max_execution_time', 60);
         $zopResult = [];
         $zopResult = [];
         $response = $this->sentRequestToZT();
         $response = $this->sentRequestToZT();
         if(is_null($response)) return;
         if(is_null($response)) return;

+ 13 - 7
app/Services/OrderPackageReceivedSyncService.php

@@ -27,15 +27,20 @@ class OrderPackageReceivedSyncService
         $logisticNumbers = $this->getLogisticNumbers();
         $logisticNumbers = $this->getLogisticNumbers();
         $this->update($this->getLogisticRoutes($logisticNumbers));
         $this->update($this->getLogisticRoutes($logisticNumbers));
         //更新中通
         //更新中通
-        $ZTOLogisticNumbers = $logisticNumbers['ZTO'];
-        foreach ($ZTOLogisticNumbers as $logisticNumber) {
-            LogisticZopSync::dispatch($logisticNumber);
+        if (array_key_exists('ZTO', $logisticNumbers)) {
+            $ZTOLogisticNumbers = $logisticNumbers['ZTO'];
+            foreach ($ZTOLogisticNumbers as $logisticNumber) {
+                LogisticZopSync::dispatch($logisticNumber);
+            }
         }
         }
         //更新韵达
         //更新韵达
-        $YDLogisticNumbers = $logisticNumbers['YUNDA'];
-        foreach ($YDLogisticNumbers as $logistic_number) {
-            LogisticYDSync::dispatch($logistic_number);
+        if (array_key_exists('YUNDA', $logisticNumbers)) {
+            $YDLogisticNumbers = $logisticNumbers['YUNDA'];
+            foreach ($YDLogisticNumbers as $logistic_number) {
+                LogisticYDSync::dispatch($logistic_number);
+            }
         }
         }
+
     }
     }
 
 
     /**
     /**
@@ -109,6 +114,7 @@ class OrderPackageReceivedSyncService
         //初始化时间 2020-12-31 23:59:59
         //初始化时间 2020-12-31 23:59:59
         $initDate = Carbon::parse(config('api_logistic.init_date'));
         $initDate = Carbon::parse(config('api_logistic.init_date'));
         $query = OrderPackage::query()
         $query = OrderPackage::query()
+            ->select(['logistic_number', 'order_id'])
             ->with(['order' => function ($query) {
             ->with(['order' => function ($query) {
                 return $query->with('logistic');
                 return $query->with('logistic');
             }]);
             }]);
@@ -121,7 +127,7 @@ class OrderPackageReceivedSyncService
                 ->whereNull('received_at');
                 ->whereNull('received_at');
         }
         }
         $result = [];
         $result = [];
-        $query->chunk(200, function ($orderPackages) use (&$result) {
+        $query->chunk(1000, function ($orderPackages) use (&$result) {
             return $result = array_merge($result, $this->buildData($orderPackages));
             return $result = array_merge($result, $this->buildData($orderPackages));
         });
         });
         return $result;
         return $result;

+ 11 - 6
resources/views/package/logistic/index.blade.php

@@ -215,10 +215,6 @@
 
 
 
 
                         {name: 'sent_at_start', type: 'dateTime', tip: '选择显示发出时间的起始时间'},
                         {name: 'sent_at_start', type: 'dateTime', tip: '选择显示发出时间的起始时间'},
-                        {name: 'sent_at_end', type: 'dateTime', tip: '选择显示发出时间的截止时间'},
-
-
-
                         {
                         {
                             name: 'is_weighed',
                             name: 'is_weighed',
                             type: 'select',
                             type: 'select',
@@ -226,6 +222,14 @@
                             placeholder: '是否称重',
                             placeholder: '是否称重',
                             data: [{name: false, value: '无'}, {name: true, value: '已称重'}]
                             data: [{name: false, value: '无'}, {name: true, value: '已称重'}]
                         },
                         },
+                        {name: 'received_at_start', type: 'dateTime', tip: '选择显示收货时间的起始时间'},
+                        {
+                            name: 'has_transfer_status',
+                            type: 'select',
+                            tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的状态'],
+                            placeholder: '是否有物流信息',
+                            data: [{name: '是', value: '是'}, {name: '否', value: '否'}]
+                        },
                         {name: 'default_date', type: 'checkbox', tip: '默认15天', data: [{name: 'ture', value: '默认15天'}]},
                         {name: 'default_date', type: 'checkbox', tip: '默认15天', data: [{name: 'ture', value: '默认15天'}]},
 
 
                     ], [
                     ], [
@@ -243,8 +247,7 @@
                             placeholder: ['货主', '定位或多选货主'],
                             placeholder: ['货主', '定位或多选货主'],
                             data: _this.owners
                             data: _this.owners
                         },
                         },
-                        {name: 'received_at_start', type: 'dateTime', tip: '选择显示收货时间的起始时间'},
-                        {name: 'received_at_end', type: 'dateTime', tip: '选择显示收货时间的截止时间'},
+                        {name: 'sent_at_end', type: 'dateTime', tip: '选择显示发出时间的截止时间'},
                         {
                         {
                             name: 'is_exception',
                             name: 'is_exception',
                             type: 'select',
                             type: 'select',
@@ -252,6 +255,8 @@
                             placeholder: '是否有异常',
                             placeholder: '是否有异常',
                             data: [{name: '是', value: '是'}, {name: '否', value: '否'}]
                             data: [{name: '是', value: '是'}, {name: '否', value: '否'}]
                         },
                         },
+                        {name: 'received_at_end', type: 'dateTime', tip: '选择显示收货时间的截止时间'},
+
                         {
                         {
                             name: 'exception_type',
                             name: 'exception_type',
                             type: 'select',
                             type: 'select',

+ 1 - 1
tests/Feature/LogisticZopSyncTest.php

@@ -39,7 +39,7 @@ class LogisticZopSyncTest extends TestCase
 
 
     public function test_get()
     public function test_get()
     {
     {
-        LogisticZopSync::dispatch('75600023806455');
+        LogisticZopSync::dispatch('75467972757443');
     }
     }