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('仓库不存在');