Authored by 毕凯

Merge branch 'feature/cart' into 'release/5.4.1'

代码格式化,JSON字符串处理



See merge request !287
... ... @@ -131,13 +131,15 @@ exports.orderCompute = (req, res, next) => {
if (req.body.cartType === 'bundle') {
let activityInfo = JSON.parse(req.cookies['activity-info']);
cartModel.orderCompute(uid, cartType, deliveryId, paymentType, couponCode, yohoCoin, null, activityInfo).then(result => {
res.json(result);
}).catch(next);
cartModel.orderCompute(uid, cartType, deliveryId, paymentType,
couponCode, yohoCoin, null, activityInfo).then(result => {
res.json(result);
}).catch(next);
} else {
cartModel.orderCompute(uid, cartType, deliveryId, paymentType, couponCode, yohoCoin, skuList).then(result => {
res.json(result);
}).catch(next);
cartModel.orderCompute(uid, cartType, deliveryId, paymentType,
couponCode, yohoCoin, skuList).then(result => {
res.json(result);
}).catch(next);
}
} else {
cartModel.ticketsOrderCompute(uid, productSku, buyNumber, yohoCoin).then(result => {
... ... @@ -190,11 +192,6 @@ exports.orderSub = (req, res, next) => {
let unionInfo = {};
if (req.cookies.mkt_code || req.cookies._QYH_UNION) {
/*
*1、http://union.yohobuy.com/go?client_id=3415&aid=0118&channel=3415&cid=3601&wi=NDgwMDB8dGVzdA==&target=http://m.yohobuy.com/
*2、http://union.yoho.cn/union/jump?channel_id=51fanli&u_id=6&tracking_code=fanli123&target_url=http%3a%2f%2fm.yohobuy.com%3funion_type%3d3063%26utm_source%3dmfanli%26utm_medium%3dcps%26utm_campaign%3dmpfanli
*3、union.yohobuy.com/go/proxy?utm_medium=none&utm_campaign=none&client_id=991002&ads_code=&go_url=https%253A%252F%252Fm.yohobuy.com%252F%253Futm_source%253Dhyyx%2526utm_medium%253Dnone%2526utm_campaign%253Dnone%2526union_type%253D991002&channel_code=hyyx&append=&mbr_name=&u_id=&aid=&channel=cps&cid=&wi=
**/
/* tar modified 161108 添加新的联盟数据处理逻辑,兼容原有联盟数据处理,
区别是旧的北京写 cookie 加密过来,新的 node 写 cookie,没有加密 */
if (req.cookies._QYH_UNION) {
... ... @@ -239,7 +236,8 @@ exports.orderSub = (req, res, next) => {
if (unionInfo && result.data) {
result.data.unionCookie = unionInfo;
} else {
logger.info(`orderEnsure: unionInfo:${JSON.stringify(unionInfo)}, result data:${JSON.stringify(result.data)}`);
logger.info(`orderEnsure: unionInfo:${JSON.stringify(unionInfo)},
result data:${JSON.stringify(result.data)}`);
}
// 提交成功清除Cookie
... ... @@ -320,7 +318,9 @@ exports.selectAddress = (req, res, next) => {
let moreUrl = (req.get('Referer') && !/\/home\/addressAct/.test(req.get('Referer')) &&
!/selectAddress/.test(req.get('Referer'))) ?
req.get('Referer') : helpers.urlFormat('/cart/index/new/orderEnsure', {cartType: req.cookies._cartType}); // 取跳过来的url
req.get('Referer') : helpers.urlFormat('/cart/index/new/orderEnsure', {
cartType: req.cookies._cartType
}); // 取跳过来的url
address = address.data;
... ...
... ... @@ -133,15 +133,16 @@ exports.cartPay = (uid, cartType, orderInfo, limitProductCode, sku, skn, buyNumb
* @return array 接口返回的数据
*/
exports.orderCompute = (uid, cartType, deliveryWay, paymentType, couponCode, yohoCoin, skuList, activityInfo) => {
return shoppingAPI.orderComputeAPI(uid, cartType, deliveryWay, paymentType, couponCode, yohoCoin, skuList, activityInfo).then(result => {
if (result && result.data) {
result.data.use_yoho_coin = transPrice(result.data.use_yoho_coin);
result.data.yohoCoinCompute = paymentProcess.yohoCoinCompute(result.data);
return result.data;
} else {
return {};
}
});
return shoppingAPI.orderComputeAPI(uid, cartType, deliveryWay, paymentType,
couponCode, yohoCoin, skuList, activityInfo).then(result => {
if (result && result.data) {
result.data.use_yoho_coin = transPrice(result.data.use_yoho_coin);
result.data.yohoCoinCompute = paymentProcess.yohoCoinCompute(result.data);
return result.data;
} else {
return {};
}
});
};
... ...
... ... @@ -34,7 +34,7 @@ exports.cartPayAPI = (uid, cartType, isUseYohoCoin, skuList, activityInfo) => {
// 购买限购商品时需要传递product_sku_list参数
if (!_.isEmpty(skuList)) {
param.product_sku_list = skuList;
param.product_sku_list = JSON.stringify(skuList);
}
// 购买套装和量贩商品时数据处理
... ... @@ -86,7 +86,7 @@ exports.orderComputeAPI = (uid, cartType, deliveWay, paymentType, couponCode, yo
}
if (!_.isEmpty(skuList) && !activityInfo) {
param.product_sku_list = skuList;
param.product_sku_list = JSON.stringify(skuList);
}
// 购买套餐商品需要的数据
... ... @@ -213,13 +213,13 @@ exports.orderSub = (uid, addressId, cartType, deliveryTime,
// 购买限购商品时需要传递product_sku_list参数
if (skuList && !activityInfo) {
params.product_sku_list = skuList;
params.product_sku_list = JSON.stringify(skuList);
}
// 购买套餐商品需要的数据
if (activityInfo) {
params.activity_id = activityInfo.activity_id;
params.product_sku_list = JSON.stringify(activityInfo.product_sku_list);
params.product_sku_list = JSON.stringify(activityInfo.product_sku_list); // TODO 检查 JSON 是否正常
}
// 友盟有关信息的传递
... ...
... ... @@ -316,10 +316,9 @@ function submitOrder() {
op: 'YB_SC_TOPAY_CLICK',
param: JSON.stringify({
C_ID: window._ChannelVary[cookie.get('_Channel')],
ORDER_CODE: res.data.order_code,
ORDER_CODE: res.data.order_code + '',
PRD_NUM: $('#goods-num').val(),
ORDER_AMOUNT: res.data.order_amount,
UNIONCOOKIE: res.data.unionCookie || '',
ORDER_AMOUNT: res.data.order_amount
})
}, true);
}
... ... @@ -499,12 +498,6 @@ if (orderInfo('address') && orderInfo('address').is_support === 'N') {
// 电子票下单
function ticketsConfirm() {
if (!$ticketsMobile.val()) {
tip.show('手机号必填');
return;
}
var data = {
productSku: productSku,
buyNumber: buyNumber,
... ... @@ -512,6 +505,11 @@ function ticketsConfirm() {
useYohoCoin: orderInfo('yohoCoin')
};
if (!$ticketsMobile.val()) {
tip.show('手机号必填');
return;
}
$.ajax({
url: '/cart/index/submitTicket',
type: 'POST',
... ...