Przeglądaj źródła

快递信息同步

ANG YU 4 lat temu
rodzic
commit
dbd045c1aa

+ 18 - 152
app/Jobs/LogisticZopSync.php

@@ -2,10 +2,8 @@
 
 namespace App\Jobs;
 
-use App\library\zop\ZopClient;
-use App\library\zop\ZopProperties;
-use App\library\zop\ZopRequest;
-use App\OrderPackage;
+
+use App\Services\LogisticZopService;
 use App\Services\LogService;
 use App\Services\OrderPackageReceivedSyncService;
 use Illuminate\Bus\Queueable;
@@ -13,13 +11,23 @@ use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;
 use Illuminate\Queue\InteractsWithQueue;
 use Illuminate\Queue\SerializesModels;
-use Illuminate\Support\Carbon;
 
 class LogisticZopSync implements ShouldQueue
 {
     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 
+    /**
+     * @var string $logistic_number
+     */
     protected $logistic_number;
+    /**
+     * @var LogisticZopService $logistic_zop_service
+     */
+    protected $logistic_zop_service;
+    /**
+     * @var  OrderPackageReceivedSyncService $order_package_received_sync_service
+     */
+    protected $order_package_received_sync_service;
 
     /**
      * Create a new job instance.
@@ -29,6 +37,8 @@ class LogisticZopSync implements ShouldQueue
     public function __construct($logistic_number)
     {
         $this->logistic_number = $logistic_number;
+        $this->logistic_zop_service = app('LogisticZopService');
+        $this->order_package_received_sync_service = app('OrderPackageReceivedSyncService');
     }
 
     /**
@@ -40,152 +50,8 @@ class LogisticZopSync implements ShouldQueue
     {
         ini_set('max_execution_time', 60);
         LogService::log(LogisticZopSync::class, "{$this->logistic_number}-JOB-ZOP", '');
-        $zopResult = [];
-        $response = $this->sentRequestToZT();
-        if(is_null($response)) return;
-        if ($response->status) {
-            $zopResult[] = [
-                'routes' => $response->result,
-                'logisticNum' => $this->logistic_number,
-            ];
-        }
-        $result = $this->transformRoutes($zopResult);
-        /* @var $orderPackageReceivedSyncService OrderPackageReceivedSyncService */
-        $orderPackageReceivedSyncService = app('OrderPackageReceivedSyncService');
-        !empty($result) && $orderPackageReceivedSyncService->update($result);
-    }
-
-    /**
-     * 转换快递路由信息
-     * @param array $routs 快递路由
-     * @return array
-     */
-    public function transformRoutes(array $routs): array
-    {
-        $result = [];
-        foreach ($routs as $route) {
-            $result = $this->transformRouteItem($route, $result);
-        }
-        return $result;
-    }
-
-    /**
-     * @param $route
-     * @param array $result
-     * @return array
-     */
-    private function transformRouteItem($route, array $result): array
-    {
-        $resultItem = [];
-        $resultItem['logistic_number'] = $route['logisticNum'];
-        $itemRoutes = $route['routes'];
-        $lastRoute = null;
-        if (!empty($itemRoutes)) {
-            $lastRoute = $itemRoutes[count($itemRoutes) - 1];
-            $resultItem = $this->getNormalStatusAndReceivedAt($lastRoute, $resultItem);
-            $resultItem['transfer_status'] = $this->getTransferStatus($itemRoutes);
-        } else {
-            $resultItem['status'] = null;
-            $resultItem['transfer_status'] = [];
-        }
-        if (!array_key_exists('status', $resultItem)) {
-            $resultItem['status'] = null;
-            $resultItem['transfer_status'] = [];
-        }
-        try {
-            $orderPackageReceivedSyncService = app('OrderPackageReceivedSyncService');
-            $exceptionData = $orderPackageReceivedSyncService->setExceptionType($resultItem, $lastRoute ? $lastRoute->scanDate / 1000 : null);
-            $resultItem['exception_type'] = $exceptionData['exception_type'];
-            $resultItem['exception'] = $exceptionData['exception'];
-        } catch (\Exception $e) {
-        }
-        if ($resultItem['status'] == null) {
-            unset($resultItem['status']);
-            unset($resultItem['transfer_status']);
-        }
-        //如果没有发现额外的异常,且查询到物流轨迹,将异常置为无
-        if (!array_key_exists('exception', $resultItem)
-            && !array_key_exists('exception_type', $resultItem)
-            && array_key_exists('transfer_status', $resultItem)
-        ) {
-            $resultItem['exception_type'] = '无';
-            $resultItem['exception'] = '否';
-        }
-        $resultItem['routes_length'] = array_key_exists('transfer_status', $resultItem) ? count($resultItem['transfer_status']) : 0;
-        $result[] = $resultItem;
-        return $result;
-    }
-    /**
-     * 正常的状态与签收时间
-     * @param $lastRoute
-     * @param array $resultItem
-     * @return array
-     */
-    private function getNormalStatusAndReceivedAt($lastRoute, array $resultItem): array
-    {
-        switch ($lastRoute->scanType) {
-            case '收件':
-                $resultItem['status'] = '已揽收';
-                break;
-            case '到件':
-            case '发件':
-                $resultItem['status'] = '在途';
-                break;
-            case 'ARRIVAL':
-            case '派件':
-                $resultItem['status'] = '派送中';
-                break;
-            case 'SIGNED':
-            case '签收':
-                $resultItem['status'] = '已收件';
-                $resultItem['received_at'] = Carbon::parse($lastRoute->scanDate / 1000)->toDateTimeString();
-                break;
-            default:
-                $resultItem['status'] = '无';
-                break;
-        }
-        return $resultItem;
-    }
-
-    /**
-     * @param $itemRoutes
-     * @return array
-     */
-    private function getTransferStatus($itemRoutes): array
-    {
-        $transfer_status = [];
-        foreach ($itemRoutes as $item) {
-            $data = [];
-            $data['accept_time'] = Carbon::parse($item->scanDate / 1000)->addHours(8)->toDateTimeString();
-            $scanSite = $item->scanSite;
-            $data['accept_address'] = $scanSite->prov . '-' . $scanSite->name;
-            $data['remark'] = $item->desc;
-            $transfer_status[] = $data;
-        }
-        return $transfer_status;
-    }
-
-    /**
-     * 发送请求到中通
-     * @return mixed
-     */
-    private function sentRequestToZT()
-    {
-        $url = config('api_logistic.ZTO.url');
-        $xAppKey = config('api_logistic.ZTO.x-appKey');
-        $appSecret = config('api_logistic.ZTO.appSecret');
-        $properties = new ZopProperties($xAppKey, $appSecret);
-        $client = new ZopClient($properties);
-        $request = new ZopRequest();
-
-        $request->setUrl($url);
-        $request->setBody(json_encode([
-            'billCode' => $this->logistic_number,
-        ],JSON_UNESCAPED_UNICODE));
-        $response = $client->execute($request);
-        if (is_null($response)) {
-            return null;
-        }
-        return json_decode($response);
+        $nativeResponse = $this->logistic_zop_service->query($this->logistic_number);
+        $formatted_data = $this->logistic_zop_service->format($nativeResponse);
+        $this->order_package_received_sync_service->update([$formatted_data]);
     }
 }

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -26,6 +26,7 @@ use App\Services\InventoryCompareService;
 use App\Services\LaborReportsCountingRecordService;
 use App\Services\LogisticSFService;
 use App\Services\LogisticYTOService;
+use App\Services\LogisticZopService;
 use App\Services\LogService;
 use App\Services\MaterialBoxService;
 use App\Services\OracleBasCustomerService;
@@ -184,6 +185,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('FeatureService',FeatureService::class);
         app()->singleton('ForeignHaiRoboticsService',ForeignHaiRoboticsService::class);
         app()->singleton('ForeignZhenCangService',ForeignZhenCangService::class);
+        app()->singleton('LogisticZopService', LogisticZopService::class);
         app()->singleton('InventoryAccountMissionService',InventoryAccountMissionService::class);
         app()->singleton('InventoryCompareService',InventoryCompareService::class);
         app()->singleton('InventoryDailyLogService',InventoryDailyLogService::class);

+ 12 - 0
app/Services/LogisticRouteInterface.php

@@ -0,0 +1,12 @@
+<?php
+
+
+namespace App\Services;
+
+
+interface LogisticRouteInterface
+{
+    public function query($logistic_number);
+
+    public function format($nativeResponse);
+}

+ 90 - 77
app/Services/LogisticZopService.php

@@ -3,101 +3,114 @@
 
 namespace App\Services;
 
-
-use App\library\zop\ZopClient;
-use App\library\zop\ZopProperties;
-use App\library\zop\ZopRequest;
+use App\OrderPackage;
 use Carbon\Carbon;
+use Illuminate\Support\Facades\Http;
 
-class LogisticZopService
+class LogisticZopService implements LogisticRouteInterface
 {
 
-
-    /**
-     * 获取中通快递路由信息
-     * @param array $logisticNums
-     * @return array
-     */
-    public function get(array $logisticNums): array
+    public function query($logistic_number)
     {
-        $result = [];
-
         $url = config('api_logistic.ZTO.url');
         $xAppKey = config('api_logistic.ZTO.x-appKey');
         $appSecret = config('api_logistic.ZTO.appSecret');
+        $body = json_encode([
+            'billCode' => $logistic_number,
+        ], JSON_UNESCAPED_UNICODE);
+        $data_digest = base64_encode(md5($body . $appSecret, TRUE));
+        $headers = [
+            'Content-Type' => 'application/json; charset=UTF-8',
+            'x-companyid' => $xAppKey,
+            'x-datadigest' => $data_digest,
+        ];
+        $response = Http::withHeaders($headers)->withBody($body, 'application/json')->post($url);
+        return json_decode($response->body());
+    }
 
-        $properties = new ZopProperties($xAppKey, $appSecret);
-        $client = new ZopClient($properties);
-        $request = new ZopRequest();
+    public function format($nativeResponse)
+    {
+        if (is_null($nativeResponse)) {
+            return [];
+        }
+        $nativeRoutes = $nativeResponse->result;
+//        $nativeMessages = $nativeResponse->messages;
+//        $nativeStatus = $nativeResponse->status;
+//        $nativeStatusCode = $nativeResponse->statusCode;
+        $this->logistic_number = $nativeRoutes[0]->billCode;
+        $order_package = OrderPackage::query()->where('logistic_number', $this->logistic_number)->first();
 
-        $request->setUrl($url);
-        foreach ($logisticNums as $logisticNum) {
-            $request->setBody(json_encode([
-                'billCode' => $logisticNum,
-            ]));
-            $response = json_decode($client->execute($request));
+        $lastRoute = $nativeRoutes[count($nativeRoutes) - 1];
 
-            if ($response->status) {
-                $result[] = [
-                    'routes' => $response->result,
-                    'logisticNum' => $logisticNum,
-                ];
-            } else {
-//                throw new WarningException("单号没有查询到快递路由信息','LogisticZopService->get->{$logisticNum}");
-            }
+        $result = [
+            'logistic_number' => $this->logistic_number,
+            'exception_type' => $order_package->exception_type,
+            'exception'=>$order_package->exception,
+            'status' => $order_package->status,
+            'transfer_status' => $order_package->transfer_status,
+            'received_at' =>$order_package->received_at,
+        ];
+        list($status, $received_at) = $this->getNormalStatusAndReceivedAt($lastRoute);
+        $result['status'] = $status;
+        $result['received_at'] = $received_at;
+        $result['transfer_status'] = $this->getTransferStatus($nativeRoutes);
+        $result['routes_length'] = count($result['transfer_status']);
+        $orderPackageReceivedSyncService = app('OrderPackageReceivedSyncService');
+        $lastRouteDate = Carbon::parse($lastRoute->scanDate / 1000)->addHours(8)->toDateTimeString();
+        $exceptionData = $orderPackageReceivedSyncService->setExceptionType($result, $lastRouteDate);
+        $result['exception_type'] = $exceptionData['exception_type'];
+        $result['exception'] = $exceptionData['exception'];
+        return $result;
+    }
+
+    /**
+     * 正常的状态与签收时间
+     */
+    private function getNormalStatusAndReceivedAt($lastRoute): array
+    {
+        $status = null;
+        $received_at = null;
+        switch ($lastRoute->scanType) {
+            case '收件':
+                $status = '已揽收';
+                break;
+            case '到件':
+            case '发件':
+                $status = '在途';
+                break;
+            case 'ARRIVAL':
+            case '派件':
+                $status = '派送中';
+                break;
+            case 'SIGNED':
+            case '签收':
+                $status = '已收件';
+                $received_at = Carbon::parse($lastRoute->scanDate / 1000)->toDateTimeString();
+                break;
+            default:
+                $status = '无';
+                break;
         }
-        return $this->transformRoutes($result);
+        return array($status, $received_at);
     }
 
+
     /**
-     * 转换快递路由信息
-     * @param array $routs 快递路由
+     * @param $nativeRoutes
      * @return array
      */
-    public function transformRoutes(array $routs): array
+    private function getTransferStatus($nativeRoutes): array
     {
-        $result = [];
-        foreach ($routs as $route) {
-            $resultItem = [];
-            $resultItem['logistic_number'] = $route['logisticNum'];
-            $itemRoutes = $route['routes'];
-            if (empty($itemRoutes)) {
-                continue;
-            }
-            $lastRoute = $itemRoutes[count($itemRoutes) - 1];
-            switch ($lastRoute->scanType) {
-                case '收件':
-                    $resultItem['status'] = '已揽收';
-                    break;
-                case '到件':
-                case '发件':
-                    $resultItem['status'] = '在途';
-                    break;
-                case 'ARRIVAL':
-                case '派件':
-                    $resultItem['status'] = '派送中';
-                    break;
-                case 'SIGNED':
-                case '签收':
-                    $resultItem['status'] = '已收件';
-                    $resultItem['received_at'] = Carbon::parse($lastRoute->scanDate / 1000)->toDateTimeString();
-                    break;
-                default:
-                    break;
-            }
-            $transfer_status = [];
-            foreach ($itemRoutes as $item) {
-                $data = [];
-                $data['accept_time'] = Carbon::parse($item->scanDate / 1000)->toDateTimeString();
-                $scanSite = $item->scanSite;
-                $data['accept_address'] = $scanSite->prov . '-' . $scanSite->name;
-                $data['remark'] = $item->scanType;
-
-                $transfer_status[] = $data;
-            }
-            $resultItem['transfer_status'] = $transfer_status;
-            $result[] = $resultItem;
+        $transfer_status = [];
+        foreach ($nativeRoutes as $item) {
+            $data = [];
+            $data['accept_time'] = Carbon::parse($item->scanDate / 1000)->addHours(8)->toDateTimeString();
+            $scanSite = $item->scanSite;
+            $data['accept_address'] = $scanSite->prov . '-' . $scanSite->name;
+            $data['remark'] = $item->desc;
+            $transfer_status[] = $data;
         }
-        return $result;
+        return $transfer_status;
     }
+
 }

+ 4 - 4
app/Services/OrderPackageReceivedSyncService.php

@@ -26,8 +26,8 @@ class OrderPackageReceivedSyncService
      */
     public function syncLogisticRoute()
     {
+        ini_set('max_execution_time', 2 * 60 * 60);
         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()
@@ -141,17 +141,17 @@ class OrderPackageReceivedSyncService
                     unset($data['exception']);
                 }
             } catch (Exception $e) {
-                LogService::log(OrderPackageReceivedSyncService::class, "标记问题件不需要更新异常状态失败", $data['logistic_number'].'-'.json_encode($e));
+                LogService::log(OrderPackageReceivedSyncService::class, "标记问题件不需要更新异常状态失败", $data['logistic_number'] . '-' . json_encode($e));
             }
             //如果已经收货,将异常更新为正常
-            if (array_key_exists('received_at',$data)) {
+            if (array_key_exists('received_at', $data)) {
                 $data['exception_type'] = '无';
                 $data['exception'] = '否';
             }
             if (isset($data['status'])) $orderPackage->status = $data['status'];
             if (isset($data['received_at'])) $orderPackage->received_at = $data['received_at'];
             if (isset($data['exception'])) $orderPackage->exception = $data['exception'];
-            if (isset($data['transfer_status'])&&!empty($data['transfer_status'])) $orderPackage->transfer_status = $data['transfer_status'];
+            if (isset($data['transfer_status']) && !empty($data['transfer_status'])) $orderPackage->transfer_status = $data['transfer_status'];
             if (isset($data['exception_type'])) $orderPackage->exception_type = $data['exception_type'];
             $orderPackage->save();
         }

+ 0 - 23
app/library/zop/README.md

@@ -1,23 +0,0 @@
-# 中通开放平台SDK(php版)
-
-## 使用方式
-
-```php
-use App\library\zop\ZopClient;
-use App\library\zop\ZopProperties;
-use App\library\zop\ZopRequest;
-
-// ZopProperties类的构造方法接收两个参数,分别是companyid和key,都需要注册中通开放平台后到个人中心查看
-$properties = new ZopProperties("kfpttestCode", "kfpttestkey==");
-$client = new ZopClient($properties);
-
-$request = new ZopRequest();
-$request->setUrl("http://58.40.16.120:9001/submitOrderCode");
-$request->setData('{"data":{"content":{"branchId":"","buyer":"","collectMoneytype":"CNY","collectSum":"12.00","freight":"10.00","id":"xfs2018031500002222333","orderSum":"0.00","orderType":"1","otherCharges":"0.00","packCharges":"1.00","premium":"0.50","price":"126.50","quantity":"2","receiver":{"address":"育德路XXX号","area":"501022","city":"四川省,XXX,XXXX","company":"XXXX有限公司","email":"yyj@abc.com","id":"130520142097","im":"yangyijia-abc","mobile":"136*****321","name":"XXX","phone":"010-222***89","zipCode":"610012"},"remark":"请勿摔货","seller":"","sender":{"address":"华新镇华志路XXX号","area":"310118","city":"上海,上海市,青浦区","company":"XXXXX有限公司","email":"ll@abc.com","endTime":1369033200000,"id":"131*****010","im":"1924656234","mobile":"1391***5678","name":"XXX","phone":"021-87***321","startTime":1369022400000,"zipCode":"610012"},"size":"12,23,11","tradeId":"2701843","type":"1","typeId":"","weight":"0.753"},"datetime":"2018-3-30 12:00:00","partner":"test","verify":"ZTO123"}}');
-
-echo $client->execute($request);
-```
-
-## 其他
-1. 该项目刚创建,功能还很不完善,如有问题请提issue
-2. 由于中通开放平台各个接口返回值格式没有统一,所以未封装返回值,未来可能会做封装

+ 0 - 65
app/library/zop/ZopClient.php

@@ -1,65 +0,0 @@
-<?php
-
-
-namespace App\library\zop;
-
-use App\Jobs\LogisticZopSync;
-use App\library\zop\ZopHttpUtil;
-use App\Services\LogService;
-use Illuminate\Support\Facades\Http;
-
-class ZopClient
-{
-    private $zopProperties;
-
-    private $httpClient;
-
-    /**
-     * ZopClient constructor.
-     * @param $zopProperties
-     */
-    public function __construct($zopProperties)
-    {
-        $this->zopProperties = $zopProperties;
-        $this->httpClient = new ZopHttpUtil();
-    }
-
-    public function execute($zopRequest)
-    {
-        if ($zopRequest->getBody() == null) {
-            $url = $zopRequest->getUrl();
-            $params = $zopRequest->getParams();
-            $fixedParams = array();
-            foreach ($params as $k => $v) {
-                if (gettype($v) != "string") {
-                    $fixedParams += [$k => json_encode($v)];
-                } else {
-                    $fixedParams += [$k => $v];
-                }
-            }
-            $str_to_digest = "";
-            foreach ($fixedParams as $k => $v) {
-                $str_to_digest = $str_to_digest . $k . "=" . $v . "&";
-            }
-            $str_to_digest = substr($str_to_digest, 0, -1) . $this->zopProperties->getKey();
-            $data_digest = base64_encode(md5($str_to_digest, TRUE));
-            $headers = array(
-                "Content-Type: application/x-www-form-urlencoded; charset=UTF-8",
-                "x-companyid: " . $this->zopProperties->getCompanyid(),
-                "x-datadigest: " . $data_digest
-            );
-            return $this->httpClient->post($url, $headers, http_build_query($fixedParams), 2000);
-        } else {
-            $url = $zopRequest->getUrl();
-            $body = $zopRequest->getBody();
-            $str_to_digest = $body . $this->zopProperties->getKey();
-            $data_digest = base64_encode(md5($str_to_digest, TRUE));
-            $response = Http::withHeaders([
-                'Content-Type' => 'application/json; charset=UTF-8',
-                'x-companyid' => $this->zopProperties->getCompanyid(),
-                'x-datadigest' => $data_digest,
-            ])->withBody(json_encode((array)json_decode($body), JSON_UNESCAPED_UNICODE), 'application/json')->post($url);
-            return $response->body();
-        }
-    }
-}

+ 0 - 20
app/library/zop/ZopHttpUtil.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace App\library\zop;
-
-class ZopHttpUtil
-{
-    public function post($url, $headers, $querystring, $timeout)
-    {
-        $ch = curl_init();
-        curl_setopt($ch, CURLOPT_URL, $url);//设置链接
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//设置是否返回信息
-        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);//设置HTTP头
-        curl_setopt($ch, CURLOPT_POST, 1);//设置为POST方式
-        curl_setopt($ch, CURLOPT_TIMEOUT_MS, $timeout);
-        curl_setopt($ch, CURLOPT_POSTFIELDS, $querystring);
-        $response = curl_exec($ch);
-        return $response;
-    }
-
-}

+ 0 - 46
app/library/zop/ZopProperties.php

@@ -1,46 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: choco
- * Date: 6/13/18
- * Time: 5:47 PM
- */
-namespace App\library\zop;
-
-
-class ZopProperties
-{
-    private $companyid;
-    private $key;
-
-    /**
-     * ZopProperties constructor.
-     * @param $companyid
-     * @param $key
-     */
-    public function __construct($companyid, $key)
-    {
-        $this->companyid = $companyid;
-        $this->key = $key;
-    }
-
-    /**
-     * @return mixed
-     */
-    public function getCompanyid()
-    {
-        return $this->companyid;
-    }
-
-    /**
-     * @return mixed
-     */
-    public function getKey()
-    {
-        return $this->key;
-    }
-
-
-
-
-}

+ 0 - 59
app/library/zop/ZopRequest.php

@@ -1,59 +0,0 @@
-<?php
-
-namespace App\library\zop;
-
-
-class ZopRequest
-{
-    private $url;
-    private $params = Array();
-    private $body;
-
-    public function addParam($k, $v)
-    {
-        $this->params += [$k => $v];
-    }
-
-    /**
-     * @param mixed $url
-     */
-    public function setUrl($url)
-    {
-        $this->url = $url;
-    }
-
-    public function setData($data)
-    {
-        $this->params = json_decode($data);
-    }
-
-    public function setBody($body)
-    {
-        $this->body = $body;
-    }
-
-    public function getBody()
-    {
-        return $this->body;
-    }
-
-
-
-    /**
-     * @return mixed
-     */
-    public function getUrl()
-    {
-        return $this->url;
-    }
-
-    /**
-     * @return array
-     */
-    public function getParams()
-    {
-        return $this->params;
-    }
-
-
-}

+ 1 - 1
tests/Feature/LogisticZopSyncTest.php

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

+ 5 - 5
tests/Services/LogisticYDService/LogisticYDSyncTest.php

@@ -34,9 +34,9 @@ class LogisticYDSyncTest extends TestCase
     /**
      * @test
      */
-//    public function sync_test()
-//    {
-//        LogisticYDSync::dispatch('4314543143889');
-//        $this->assertTrue(OrderPackage::query()->where('logistic_number','4314543143889')->first()->transfer_status);
-//    }
+    public function sync_test()
+    {
+        LogisticYDSync::dispatch('4314543143889');
+        $this->assertTrue(OrderPackage::query()->where('logistic_number','4314543143889')->first()->transfer_status);
+    }
 }

+ 2 - 2
tests/Services/OrderPackageReceivedSyncService/SyncLogisticRouteTest.php

@@ -34,7 +34,7 @@ class SyncLogisticRouteTest extends TestCase
      */
     public function sync_test()
     {
-//        $this->service->syncLogisticRoute();
-        $this->assertTrue(true);
+        $this->service->syncLogisticRoute();
+//        $this->assertTrue(true);
     }
 }