Merge branch 'feature/new_wms' into 'master'
修改销售单BC单判断 See merge request composer/php-wms-client!9
This commit is contained in:
commit
6d7b4d5fde
|
@ -6,12 +6,21 @@ return [
|
|||
'other_express_weight' => 45,
|
||||
'logistics' => [
|
||||
'toB' => [
|
||||
[
|
||||
'code' => 'CN7000001003751',
|
||||
'name' => '跨越',
|
||||
],
|
||||
[
|
||||
'code' => 'CN7000001000869',
|
||||
'name' => '安能快运',
|
||||
],
|
||||
|
||||
],
|
||||
'toC' => [
|
||||
[
|
||||
'code' => 'STO',
|
||||
'name' => '申通',
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
|
@ -20,13 +20,26 @@ class WmsStrategy
|
|||
}
|
||||
|
||||
public function saleOrderCreate($params) {
|
||||
$orderLogisticsType = '';
|
||||
if ($params['delivery_type'] == 1) {
|
||||
$orderLogisticsType = 'toC';
|
||||
} else if ($params['delivery_type'] == 2) {
|
||||
$orderLogisticsType = 'toB';
|
||||
}
|
||||
|
||||
if (!$orderLogisticsType || !$params['express_code']) {
|
||||
//计算商品重量
|
||||
$skuTotalWeight = $this->getSkuTotalWeight($params['order_goods']);
|
||||
$logistics = $this->chooseLogisticsCompany($params['order_address']['receive_province'], $skuTotalWeight);
|
||||
$params['order_sender_info']['logistics_code'] = $logistics['code'];
|
||||
$params['order_sender_info']['logistics_name'] = $logistics['name'];
|
||||
$orderLogisticsType = $logistics['type'];
|
||||
} else {
|
||||
$params['order_sender_info']['logistics_code'] = $params['express_code'];
|
||||
$params['order_sender_info']['logistics_name'] = self::getExpressNameByExpressCode($params['express_code']);
|
||||
}
|
||||
|
||||
if ($logistics['type'] == 'toC') {
|
||||
if ($orderLogisticsType == 'toC') {
|
||||
// 2C订单发货
|
||||
$res = $this->deliveryOrderCreate($params);
|
||||
$type = 1;
|
||||
|
@ -115,23 +128,78 @@ 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 string $province
|
||||
* @param string $weight
|
||||
* @return array
|
||||
*/
|
||||
static public function getLogistics($province, $weight)
|
||||
{
|
||||
$expressChooseConf = require(dirname(dirname(__FILE__)) . '/config/express_choose.php');
|
||||
$type = self::getOrderType($province, $weight, $expressChooseConf);
|
||||
return $expressChooseConf['logistics'][$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断订单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';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据物流快递判断订单bc类型
|
||||
* @param $expressCode
|
||||
* @return string
|
||||
*/
|
||||
static public function getOrderTypeByExpressCode($expressCode)
|
||||
{
|
||||
$expressChooseConf = require(dirname(dirname(__FILE__)) . '/config/express_choose.php');
|
||||
$logisticsToC = collect($expressChooseConf['logistics']['toC'])->pluck('code')->toArray();
|
||||
if (in_array($expressCode, $logisticsToC)) {
|
||||
return 'toC';
|
||||
}
|
||||
$logisticsToB = collect($expressChooseConf['logistics']['toB'])->pluck('code')->toArray();
|
||||
if (in_array($expressCode, $logisticsToB)) {
|
||||
return 'toB';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据物流码获取物流名称
|
||||
*/
|
||||
static public function getExpressNameByExpressCode($expressCode)
|
||||
{
|
||||
$expressChooseConf = require(dirname(dirname(__FILE__)) . '/config/express_choose.php');
|
||||
$logistics = collect([$expressChooseConf['logistics']['toC'], $expressChooseConf['logistics']['toB']])
|
||||
->collapse()
|
||||
->keyBy('code')
|
||||
->all();
|
||||
$expressName = $logistics[$expressCode] ? $logistics[$expressCode]['name'] : '';
|
||||
return $expressName;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user