فهرست منبع

顺丰异常优于自定义异常

ANG YU 5 سال پیش
والد
کامیت
0186cf19dc
2فایلهای تغییر یافته به همراه64 افزوده شده و 52 حذف شده
  1. 49 40
      app/Http/Controllers/TestController.php
  2. 15 12
      app/Services/LogisticSFService.php

+ 49 - 40
app/Http/Controllers/TestController.php

@@ -164,24 +164,25 @@ class TestController extends Controller
         return view("test");
     }
 
-    public function assignBatch(){
+    public function assignBatch()
+    {
         $batches = collect([
             [
-                "id"=> 87255,
-                "code"=> "W210312000317",
-                "status"=> "\u672a\u5904\u7406",
-                "type"=> null,
-                "wms_type"=> "09.[BAOSHI]\u622a\u5355\u6ce2\u6b21\u3010\u65e0\u5907\u6ce8\u3011",
-                "wms_status"=> "\u90e8\u5206\u6536\u8d27",
-                "wms_created_at"=> "0000-00-00 00=>00=>00",
-                "created_at"=> "2021-03-12T09=>10=>44.000000Z",
-                "updated_at"=> "2021-03-12T09=>10=>44.000000Z",
-                "remark"=> null,
-                "owner_id"=> "42",
-                "station_task_batch"=> null
+                "id" => 87255,
+                "code" => "W210312000317",
+                "status" => "\u672a\u5904\u7406",
+                "type" => null,
+                "wms_type" => "09.[BAOSHI]\u622a\u5355\u6ce2\u6b21\u3010\u65e0\u5907\u6ce8\u3011",
+                "wms_status" => "\u90e8\u5206\u6536\u8d27",
+                "wms_created_at" => "0000-00-00 00=>00=>00",
+                "created_at" => "2021-03-12T09=>10=>44.000000Z",
+                "updated_at" => "2021-03-12T09=>10=>44.000000Z",
+                "remark" => null,
+                "owner_id" => "42",
+                "station_task_batch" => null
             ]
         ]);
-        $batches=Batch::query()->where('id',data_get($batches,'*.id'))->get();
+        $batches = Batch::query()->where('id', data_get($batches, '*.id'))->get();
         app('BatchService')->assignTasks($batches);
     }
 
@@ -282,32 +283,34 @@ class TestController extends Controller
             true
         );
     }
+
     function hHasTaken(Request $request)
     {
         app('ForeignHaiRoboticsService')->taskUpdate(
             301
-            ,1
-            ,0
-            ,'IDE0005714'
+            , 1
+            , 0
+            , 'IDE0005714'
         );
     }
+
     function hBatch(Request $request)
     {
-        $a=[
+        $a = [
             new Batch(
                 [
-                    "id"=> 91045,
-                    "code"=> "W210325000388",
-                    "status"=> "\u672a\u5904\u7406",
-                    "type"=> null,
-                    "wms_type"=> "09.[BAOSHI]\u622a\u5355\u6ce2\u6b21\u3010\u65e0\u5907\u6ce8\u3011",
-                    "wms_status"=> "\u90e8\u5206\u6536\u8d27",
-                    "wms_created_at"=> "0000-00-00 00:00:00",
-                    "created_at"=> "2021-03-25T10:58:46.000000Z",
-                    "updated_at"=> "2021-03-25T10:58:46.000000Z",
-                    "remark"=> null,
-                    "owner_id"=> "42"
-                ]            )
+                    "id" => 91045,
+                    "code" => "W210325000388",
+                    "status" => "\u672a\u5904\u7406",
+                    "type" => null,
+                    "wms_type" => "09.[BAOSHI]\u622a\u5355\u6ce2\u6b21\u3010\u65e0\u5907\u6ce8\u3011",
+                    "wms_status" => "\u90e8\u5206\u6536\u8d27",
+                    "wms_created_at" => "0000-00-00 00:00:00",
+                    "created_at" => "2021-03-25T10:58:46.000000Z",
+                    "updated_at" => "2021-03-25T10:58:46.000000Z",
+                    "remark" => null,
+                    "owner_id" => "42"
+                ])
         ];
         app('BatchService')->assignTasks($a);
         dd($a);
@@ -316,8 +319,8 @@ class TestController extends Controller
     function packageT(Request $request)
     {
 
-        $stationTaskBatch=app('StationTaskBatchService')->get(['batch_id'=>93037])->first();
-        dd($stationTaskBatch['id']??null);
+        $stationTaskBatch = app('StationTaskBatchService')->get(['batch_id' => 93037])->first();
+        dd($stationTaskBatch['id'] ?? null);
     }
 
     function injectJS(Request $request)
@@ -494,6 +497,7 @@ class TestController extends Controller
             $authority->delete();
         });
     }
+
     /*1*/
     function socket(Request $request)
     {/**/
@@ -560,6 +564,7 @@ class TestController extends Controller
         });
         dd($authorities);
     }
+
     public function output2()
     {
         StationTaskBatch::query()->insert([[
@@ -777,7 +782,6 @@ class TestController extends Controller
     }
 
 
-
     public function testUpdateSkuNameBarcodeToCommodity_id()
     {
         $amount = 1000;
@@ -933,11 +937,10 @@ class TestController extends Controller
     }
 
 
-
     public function updateLaborReport()
     {
-        UserDutyCheck::query()->find(13565)->update(['user_id'=>1004]);
-        LaborReportStatus::query()->find(26614)->update(['labor_report_id'=>6835]);
+        UserDutyCheck::query()->find(13565)->update(['user_id' => 1004]);
+        LaborReportStatus::query()->find(26614)->update(['labor_report_id' => 6835]);
     }
 
     public function cleanLaborsCache()
@@ -954,9 +957,9 @@ class TestController extends Controller
             }
         }
         return $count;
-        $procurementQuotations=ProcurementQuotation::query()
+        $procurementQuotations = ProcurementQuotation::query()
             ->with('procurement.ownerMaterial.material')
-            ->where('status',0)
+            ->where('status', 0)
             ->whereNull('offer')
             //->where('created_at','>=',Carbon::parse($now)->subHours(4))
             //->where('created_at','<=',$now)
@@ -964,9 +967,15 @@ class TestController extends Controller
         dd($procurementQuotations->toJson());
     }
 
-    public function testWeight(Request $request )
+    public function testWeight(Request $request)
     {
 
-        Log::query()->create(['method'=>'test hengli','description'=>json_encode($request->all())]);
+        Log::query()->create(['method' => 'test hengli', 'description' => json_encode($request->all())]);
+    }
+
+    public function order_packages_exception_type_sync()
+    {
+        $count = OrderPackage::query()->where('status', '派送异常')->update(['exception_type' => '派件异常']);
+        dump('更新了: '.$count);
     }
 }

+ 15 - 12
app/Services/LogisticSFService.php

@@ -100,7 +100,9 @@ xml;
             $lastRoute = get_object_vars($routeResponse['Route'][count($routeResponse['Route']) - 1])['@attributes'];//获取最新的路由信息
             $data = $this->switchOpCodeToStatus($lastRoute, $data);
             $data['transfer_status'] = $this->transformRoutes($routeResponse['Route']);
-            $data = $this->setExceptionType($data, $lastRoute['accept_time']);
+            if (!array_key_exists('exception', $data)) {//当顺丰返回异常时,不需要再根据时间判断是否异常,直接用顺丰的异常就好
+                $data = $this->setExceptionType($data, $lastRoute['accept_time']);
+            }
         } catch (Exception $e) {
             throw new WarningException("单号没有查询到快递路由信息','LogisticSFService->transformSFOneToArr->{$data['logistic_number']}");
         } finally {
@@ -148,6 +150,7 @@ xml;
                 case 70:
                 case 33:
                     $data['status'] = '派送异常';
+                    $data['exception_type'] = '派件异常';
                     $data['exception'] = '是';
                     break;
                 case 204:
@@ -302,21 +305,21 @@ xml;
                 $data['exception_type'] = '揽件异常';
                 break;
             case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SHORT_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SHORT_NO_RESPONSE |$IS_WEIGHED:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SHORT_NO_RESPONSE | $IS_WEIGHED:
                 $data['exception_type'] = '中转异常';
                 break;
-            case $IS_ROUTED | $IS_IN_VALID_TIME| $IS_LONG_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME| $IS_LONG_NO_RESPONSE|$IS_WEIGHED:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_LONG_NO_RESPONSE:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_LONG_NO_RESPONSE | $IS_WEIGHED:
                 $data['exception_type'] = '疑似丢件';
                 break;
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_WEIGHED:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_WEIGHED|$IS_SHORT_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_WEIGHED|$IS_SHORT_NO_RESPONSE|$IS_LONG_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_WEIGHED|$IS_LONG_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_SHORT_NO_RESPONSE|$IS_LONG_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_SHORT_NO_RESPONSE:
-            case $IS_ROUTED | $IS_IN_VALID_TIME|$IS_SENDING|$IS_SENDING_NO_RESPONSE|$IS_LONG_NO_RESPONSE:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_WEIGHED:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_WEIGHED | $IS_SHORT_NO_RESPONSE:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_WEIGHED | $IS_SHORT_NO_RESPONSE | $IS_LONG_NO_RESPONSE:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_WEIGHED | $IS_LONG_NO_RESPONSE:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_SHORT_NO_RESPONSE | $IS_LONG_NO_RESPONSE:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_SHORT_NO_RESPONSE:
+            case $IS_ROUTED | $IS_IN_VALID_TIME | $IS_SENDING | $IS_SENDING_NO_RESPONSE | $IS_LONG_NO_RESPONSE:
                 $data['exception_type'] = '派件异常';
                 break;
             default: