From 471edb975d1d60e2812ea8a8f0ca19d9922a5b5a Mon Sep 17 00:00:00 2001 From: ZweiCD <416931358@qq.com> Date: Thu, 27 Aug 2020 14:43:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E7=89=A9?= =?UTF-8?q?=E6=B5=81=E5=BF=AB=E9=80=92=E9=9D=99=E6=80=81=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/express_choose.php | 17 +++++++++++++---- src/WmsStrategy.php | 39 ++++++++++++++++++++++++--------------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/config/express_choose.php b/config/express_choose.php index 605b450..933f3e3 100644 --- a/config/express_choose.php +++ b/config/express_choose.php @@ -6,12 +6,21 @@ return [ 'other_express_weight' => 45, 'logistics' => [ 'toB' => [ - 'code' => 'CN7000001003751', - 'name' => '跨越', + [ + 'code' => 'CN7000001003751', + 'name' => '跨越', + ], + [ + 'code' => 'CN7000001000869', + 'name' => '安能快运', + ], + ], 'toC' => [ - 'code' => 'STO', - 'name' => '申通', + [ + 'code' => 'STO', + 'name' => '申通', + ], ] ], ]; \ No newline at end of file diff --git a/src/WmsStrategy.php b/src/WmsStrategy.php index bcb2811..a770890 100644 --- a/src/WmsStrategy.php +++ b/src/WmsStrategy.php @@ -115,23 +115,32 @@ class WmsStrategy public function chooseLogisticsCompany($province, $weight) { $expressChooseConf = require(dirname(dirname(__FILE__)) . '/config/express_choose.php'); - if (in_array($province, $expressChooseConf['address_list'])) { - if ($weight >= $expressChooseConf['jzh_express_weight']) { - $type = 'toB'; - } else { - $type = 'toC'; - } - } else { - if ($weight >= $expressChooseConf['other_express_weight']) { - $type = 'toB'; - } else { - $type = 'toC'; - } - } + $type = self::getOrderType($province, $weight, $expressChooseConf); return [ 'type' => $type, - 'code' => $expressChooseConf['logistics'][$type]['code'], - 'name' => $expressChooseConf['logistics'][$type]['name'], + 'code' => $expressChooseConf['logistics'][$type][0]['code'], + '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'; + } + } }