...
|
...
|
@@ -13,11 +13,13 @@ const _ = require('lodash'); |
|
|
function tranformPayment(data, orderInfo) {
|
|
|
orderInfo = orderInfo || {};
|
|
|
let result = {};
|
|
|
let isSunfengSupport;
|
|
|
|
|
|
// delivery_address 中 提取信息
|
|
|
if (data.hasOwnProperty('delivery_address') && !_.isEmpty(data.delivery_address)) {
|
|
|
let cookieAddress = orderInfo.address;
|
|
|
let addressData = data.delivery_address;
|
|
|
let isSupport = cookieAddress ? cookieAddress.is_support : addressData.is_support;
|
|
|
|
|
|
result.name = cookieAddress ? cookieAddress.consignee : addressData.consignee;
|
|
|
result.phoneNum = cookieAddress ? cookieAddress.mobile : addressData.mobile;
|
...
|
...
|
@@ -25,18 +27,23 @@ function tranformPayment(data, orderInfo) { |
|
|
result.addressInfo = cookieAddress ? cookieAddress.address_info : [addressData.area, addressData.address].join(' ');
|
|
|
|
|
|
result.addressId = crypto.encryption(null, result.addressId + '');
|
|
|
isSunfengSupport = isSupport === 'Y';
|
|
|
|
|
|
}
|
|
|
|
|
|
// delivery_way 配送信息
|
|
|
if (data.delivery_way) {
|
|
|
let arr = [];
|
|
|
let cookieWayId = orderInfo.deliveryId;
|
|
|
let deliveryWay = data.delivery_way;
|
|
|
let isDeliveryId = true;
|
|
|
let defaultKey = 0;
|
|
|
|
|
|
deliveryWay = deliveryWay
|
|
|
.filter(obj => obj.is_support === 'Y')
|
|
|
.map((way, index) => {
|
|
|
deliveryWay.forEach((way, index) => {
|
|
|
if (way.delivery_way_name === '顺丰速运' && !isSunfengSupport) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let obj = {};
|
|
|
|
|
|
(way.default === 'Y') && (defaultKey = index);
|
...
|
...
|
@@ -46,18 +53,20 @@ function tranformPayment(data, orderInfo) { |
|
|
isDeliveryId = false;
|
|
|
}
|
|
|
|
|
|
return Object.assign({
|
|
|
id: way.delivery_way_id,
|
|
|
name: way.delivery_way_name,
|
|
|
cost: way.delivery_way_cost,
|
|
|
}, obj);
|
|
|
arr.push(
|
|
|
Object.assign({
|
|
|
id: way.delivery_way_id,
|
|
|
name: way.delivery_way_name,
|
|
|
cost: way.delivery_way_cost,
|
|
|
}, obj)
|
|
|
);
|
|
|
});
|
|
|
|
|
|
if (isDeliveryId) {
|
|
|
deliveryWay[defaultKey].isSelected = true;
|
|
|
arr[defaultKey].isSelected = true;
|
|
|
}
|
|
|
|
|
|
result.dispatchMode = deliveryWay;
|
|
|
result.dispatchMode = arr;
|
|
|
}
|
|
|
|
|
|
// delivery_time 配送时间
|
...
|
...
|
|