Explorar el Código

feat(core): add logistics interfaces and response implementation

- Add CoreExtensionInterface with documentation comment
- Add ExtensionInterface with documentation comment
- Introduce LogisticsInformationResponse class implementing JsonSerializable
- Add properties and constructor for logistics extension ID, number, type, and raw data
- Implement jsonSerialize method for LogisticsInformationResponse
- Define LogisticsInterface with logisticsInformation method to fetch logistics data
- Update CoreService to skip unavailable extensions during boot process
runphp hace 5 meses
padre
commit
6e3c96e3cc

+ 3 - 0
src/Contracts/CoreExtensionInterface.php

@@ -3,6 +3,9 @@ declare(strict_types=1);
 
 namespace SixShop\Core\Contracts;
 
+/**
+ * 核心扩展接口
+ */
 interface CoreExtensionInterface
 {
 

+ 3 - 0
src/Contracts/ExtensionInterface.php

@@ -3,6 +3,9 @@ declare(strict_types=1);
 
 namespace SixShop\Core\Contracts;
 
+/**
+ * 扩展接口
+ */
 interface ExtensionInterface
 {
     /**

+ 35 - 0
src/Contracts/LogisticsInformationResponse.php

@@ -0,0 +1,35 @@
+<?php
+declare(strict_types=1);
+namespace SixShop\Core\Contracts;
+
+use JsonSerializable;
+
+/**
+ * 物流信息响应
+ */
+class LogisticsInformationResponse implements JsonSerializable
+{
+    /**
+     * @param string $extensionID 物流模块扩展ID
+     * @param string $number 物流单号
+     * @param string $type 物流类型
+     * @param array $raw 原始数据
+     */
+    public function __construct(
+        public string $extensionID,
+        public string $number,
+        public string $type,
+        public array $raw)
+    {
+    }
+
+    public function jsonSerialize(): mixed
+    {
+        return [
+            'extension_id' => $this->extensionID,
+            'number' => $this->number,
+            'type' => $this->type,
+            'raw' => $this->raw
+        ];
+    }
+}

+ 17 - 0
src/Contracts/LogisticsInterface.php

@@ -0,0 +1,17 @@
+<?php
+declare(strict_types=1);
+
+namespace SixShop\Core\Contracts;
+
+/**
+ * 物流接口
+ */
+interface LogisticsInterface
+{
+    /**
+     * 获取物流信息
+     * @param string $number 物流单号
+     * @param string $type 快递类型
+     */
+    public function logisticsInformation(string $number, string $type = ''): LogisticsInformationResponse;
+}

+ 3 - 0
src/Service/CoreService.php

@@ -105,6 +105,9 @@ class CoreService extends Service
                 continue;
             }
             $extension = $autoloadService->getExtension($moduleName);
+            if (!$extension->available()) {
+                continue;
+            }
             $extension->boot();
             $this->app->event->trigger('extension.boot', $extension);
         }