增加获取物流快递静态方法

This commit is contained in:
ZweiCD 2020-08-27 14:43:39 +08:00
parent 7a7fb7b1fd
commit 471edb975d
2 changed files with 37 additions and 19 deletions

View File

@ -6,12 +6,21 @@ return [
'other_express_weight' => 45, 'other_express_weight' => 45,
'logistics' => [ 'logistics' => [
'toB' => [ 'toB' => [
[
'code' => 'CN7000001003751', 'code' => 'CN7000001003751',
'name' => '跨越', 'name' => '跨越',
], ],
[
'code' => 'CN7000001000869',
'name' => '安能快运',
],
],
'toC' => [ 'toC' => [
[
'code' => 'STO', 'code' => 'STO',
'name' => '申通', 'name' => '申通',
],
] ]
], ],
]; ];

View File

@ -115,23 +115,32 @@ class WmsStrategy
public function chooseLogisticsCompany($province, $weight) public function chooseLogisticsCompany($province, $weight)
{ {
$expressChooseConf = require(dirname(dirname(__FILE__)) . '/config/express_choose.php'); $expressChooseConf = require(dirname(dirname(__FILE__)) . '/config/express_choose.php');
if (in_array($province, $expressChooseConf['address_list'])) { $type = self::getOrderType($province, $weight, $expressChooseConf);
if ($weight >= $expressChooseConf['jzh_express_weight']) {
$type = 'toB';
} else {
$type = 'toC';
}
} else {
if ($weight >= $expressChooseConf['other_express_weight']) {
$type = 'toB';
} else {
$type = 'toC';
}
}
return [ return [
'type' => $type, 'type' => $type,
'code' => $expressChooseConf['logistics'][$type]['code'], 'code' => $expressChooseConf['logistics'][$type][0]['code'],
'name' => $expressChooseConf['logistics'][$type]['name'], 'name' => $expressChooseConf['logistics'][$type][0]['name'],
]; ];
} }
/**
* 判断订单BC类型
* @param $province
* @param $weight
* @return string
*/
static public function getOrderType($province, $weight, $expressChooseConf)
{
if (in_array($province, $expressChooseConf['address_list'])) {
if ($weight >= $expressChooseConf['jzh_express_weight']) {
return 'toB';
}
return 'toC';
} else {
if ($weight >= $expressChooseConf['other_express_weight']) {
return 'toB';
}
return 'toC';
}
}
} }