diff --git a/beike/Repositories/PluginRepo.php b/beike/Repositories/PluginRepo.php index de6bd959..d9ea2147 100644 --- a/beike/Repositories/PluginRepo.php +++ b/beike/Repositories/PluginRepo.php @@ -15,6 +15,7 @@ use Beike\Models\Plugin; use Beike\Plugin\Plugin as BPlugin; use Illuminate\Support\Facades\File; use Illuminate\Database\Eloquent\Collection; +use Beike\Shop\Services\TotalServices\ShippingService; class PluginRepo { @@ -180,6 +181,7 @@ class PluginRepo */ public static function shippingEnabled($code): bool { + $code = ShippingService::parseShippingPluginCode($code); $shippingMethods = self::getShippingMethods(); return $shippingMethods->where('code', $code)->count() > 0; } diff --git a/beike/Shop/Services/TotalServices/ShippingService.php b/beike/Shop/Services/TotalServices/ShippingService.php index 3347987e..a0b80d04 100644 --- a/beike/Shop/Services/TotalServices/ShippingService.php +++ b/beike/Shop/Services/TotalServices/ShippingService.php @@ -30,8 +30,7 @@ class ShippingService return null; } - $methodArray = explode('.', $shippingMethod); - $shippingPluginCode = $methodArray[0]; + $shippingPluginCode = self::parseShippingPluginCode($shippingMethod); $pluginCode = Str::studly($shippingPluginCode); $plugin = app('plugin')->getPlugin($shippingPluginCode); @@ -59,4 +58,17 @@ class ShippingService return $totalData; } + + + /** + * 通过配送方式获取插件编码 + * + * @param $shippingMethod + * @return string + */ + public static function parseShippingPluginCode($shippingMethod): string + { + $methodArray = explode('.', $shippingMethod); + return $methodArray[0]; + } }