修改销售单发货逻辑

This commit is contained in:
ZweiCD 2020-08-27 17:34:42 +08:00
parent 5ec1668057
commit ce1efee9b1

View File

@ -20,13 +20,25 @@ class WmsStrategy
} }
public function saleOrderCreate($params) { public function saleOrderCreate($params) {
//计算商品重量 $orderLogisticsType = '';
$skuTotalWeight = $this->getSkuTotalWeight($params['order_goods']); if ($params['delivery_type'] == 1) {
$logistics = $this->chooseLogisticsCompany($params['order_address']['receive_province'], $skuTotalWeight); $orderLogisticsType = 'toC';
$params['order_sender_info']['logistics_code'] = $logistics['code']; } else if ($params['delivery_type'] == 2) {
$params['order_sender_info']['logistics_name'] = $logistics['name']; $orderLogisticsType = 'toB';
}
if ($logistics['type'] == 'toC') { 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'];
} else {
$params['order_sender_info']['logistics_code'] = $params['express_code'];
$params['order_sender_info']['logistics_name'] = self::getExpressNameByExpressCode($params['express_code']);
}
if ($orderLogisticsType == 'toC') {
// 2C订单发货 // 2C订单发货
$res = $this->deliveryOrderCreate($params); $res = $this->deliveryOrderCreate($params);
$type = 1; $type = 1;
@ -175,4 +187,18 @@ class WmsStrategy
} }
return ''; 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;
}
} }