From 6bb3acd2bd88a0b424727b290c7cdd00c25ca5bb Mon Sep 17 00:00:00 2001 From: ZweiCD <416931358@qq.com> Date: Wed, 25 Mar 2020 14:16:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E4=BB=93=E5=BA=93id=E5=86=99=E5=85=A5?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/wms.php | 2 ++ src/GwallWms.php | 2 +- src/WmsStrategy.php | 9 +++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/config/wms.php b/config/wms.php index 05c8ffe..1cacfe7 100644 --- a/config/wms.php +++ b/config/wms.php @@ -11,6 +11,7 @@ return [ 'sign_method' => 'md5', 'warehouse_code' => env('WMS_WAREHOUSE_CODE','test0912'), 'shipper_code' => env('WMS_SHIPPER_CODE','BJPD'), + 'warehouse_id' => env('WMS_WAREHOUSE_ID', 1), ], 'gwall' => [ 'base_uri' => env('GWALL_HOST', 'http://s.gwall.cn:8092/GwallServices3.0/WMSService?'), @@ -21,5 +22,6 @@ return [ 'encrypt' => 1, 'warehouse_code' => env('GWALL_WAREHOUSE_CODE', 'test2306'), 'shipper_code' => env('GWALL_SHIPPER_CODE', 'BJPD'), + 'warehouse_id' => env('GWALL_WAREHOUSE_ID', 2), ], ]; diff --git a/src/GwallWms.php b/src/GwallWms.php index c4c7993..43145cb 100644 --- a/src/GwallWms.php +++ b/src/GwallWms.php @@ -8,7 +8,7 @@ class GwallWms extends BaseWms implements WmsInterface { protected $config = []; - public function __construct() + public function __construct($config = null) { $wmsConf = $config ?? (require(dirname(dirname(__FILE__)) . '/config/wms.php'))['gwall']; $this->config = $wmsConf; diff --git a/src/WmsStrategy.php b/src/WmsStrategy.php index aa7f758..7dd85eb 100644 --- a/src/WmsStrategy.php +++ b/src/WmsStrategy.php @@ -8,13 +8,14 @@ class WmsStrategy public function __construct($warehouseId) { + $config = require(dirname(dirname(__FILE__)) . '/config/wms.php'); switch ($warehouseId) { - case 1: - $this->wmsClient = new XinyiWms(); + case $config['xinyi']['warehouse_id']: + $this->wmsClient = new XinyiWms($config['xinyi']); break; - case 2: - $this->wmsClient = new GwallWms(); + case $config['gwall']['warehouse_id']: + $this->wmsClient = new GwallWms($config['gwall']); break; default: throw new \Exception('仓库不存在');