将仓库id写入配置文件

This commit is contained in:
ZweiCD 2020-03-25 14:16:20 +08:00
parent 4feb989020
commit 6bb3acd2bd
3 changed files with 8 additions and 5 deletions

View File

@ -11,6 +11,7 @@ return [
'sign_method' => 'md5', 'sign_method' => 'md5',
'warehouse_code' => env('WMS_WAREHOUSE_CODE','test0912'), 'warehouse_code' => env('WMS_WAREHOUSE_CODE','test0912'),
'shipper_code' => env('WMS_SHIPPER_CODE','BJPD'), 'shipper_code' => env('WMS_SHIPPER_CODE','BJPD'),
'warehouse_id' => env('WMS_WAREHOUSE_ID', 1),
], ],
'gwall' => [ 'gwall' => [
'base_uri' => env('GWALL_HOST', 'http://s.gwall.cn:8092/GwallServices3.0/WMSService?'), 'base_uri' => env('GWALL_HOST', 'http://s.gwall.cn:8092/GwallServices3.0/WMSService?'),
@ -21,5 +22,6 @@ return [
'encrypt' => 1, 'encrypt' => 1,
'warehouse_code' => env('GWALL_WAREHOUSE_CODE', 'test2306'), 'warehouse_code' => env('GWALL_WAREHOUSE_CODE', 'test2306'),
'shipper_code' => env('GWALL_SHIPPER_CODE', 'BJPD'), 'shipper_code' => env('GWALL_SHIPPER_CODE', 'BJPD'),
'warehouse_id' => env('GWALL_WAREHOUSE_ID', 2),
], ],
]; ];

View File

@ -8,7 +8,7 @@ class GwallWms extends BaseWms implements WmsInterface
{ {
protected $config = []; protected $config = [];
public function __construct() public function __construct($config = null)
{ {
$wmsConf = $config ?? (require(dirname(dirname(__FILE__)) . '/config/wms.php'))['gwall']; $wmsConf = $config ?? (require(dirname(dirname(__FILE__)) . '/config/wms.php'))['gwall'];
$this->config = $wmsConf; $this->config = $wmsConf;

View File

@ -8,13 +8,14 @@ class WmsStrategy
public function __construct($warehouseId) public function __construct($warehouseId)
{ {
$config = require(dirname(dirname(__FILE__)) . '/config/wms.php');
switch ($warehouseId) switch ($warehouseId)
{ {
case 1: case $config['xinyi']['warehouse_id']:
$this->wmsClient = new XinyiWms(); $this->wmsClient = new XinyiWms($config['xinyi']);
break; break;
case 2: case $config['gwall']['warehouse_id']:
$this->wmsClient = new GwallWms(); $this->wmsClient = new GwallWms($config['gwall']);
break; break;
default: default:
throw new \Exception('仓库不存在'); throw new \Exception('仓库不存在');