...
|
...
|
@@ -9,6 +9,7 @@ const addressModel = require('../../serverAPI/user/address'); |
|
|
const orderModel = require('../models/order');
|
|
|
const crypto = global.yoho.crypto;
|
|
|
const authcode = require(global.utils + '/authcode');
|
|
|
const logger = global.yoho.logger;
|
|
|
|
|
|
// cookie 参数
|
|
|
const actCkOpthn = {
|
...
|
...
|
@@ -31,6 +32,7 @@ exports.orderEnsure = (req, res, next) => { |
|
|
try {
|
|
|
orderInfo = JSON.parse(req.cookies['order-info']);
|
|
|
} catch (e) {
|
|
|
logger.info(`orderEnsure: get orderInfo from cookie error:${JSON.stringify(e)}`);
|
|
|
orderInfo = {};
|
|
|
res.cookie('order-info', null, actCkOpthn);
|
|
|
}
|
...
|
...
|
@@ -68,11 +70,13 @@ exports.orderEnsure = (req, res, next) => { |
|
|
let userProfile = result[1];
|
|
|
let address = result[2];
|
|
|
|
|
|
if (order.cartUrl) { // TODO? 普通或者预售商品为空时, BUT WHEN AJAX?
|
|
|
if (order.cartUrl) {
|
|
|
logger.info(`orderEnsure: order cartUrl has value:${order.cartUrl}, order data is null`);
|
|
|
return res.redirect(order.cartUrl);
|
|
|
}
|
|
|
|
|
|
if (req.xhr) {
|
|
|
logger.info(`orderEnsure: ajax request, return json:${JSON.stringify(order)}`);
|
|
|
return res.json(order);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -183,7 +187,6 @@ exports.orderSub = (req, res, next) => { |
|
|
let userAgent = null;
|
|
|
let unionKey = '';
|
|
|
let unionInfo = {};
|
|
|
let testQyhUnion = {};
|
|
|
|
|
|
if (req.cookies.mkt_code || req.cookies._QYH_UNION) {
|
|
|
/*
|
...
|
...
|
@@ -198,8 +201,10 @@ exports.orderSub = (req, res, next) => { |
|
|
|
|
|
if (!unionKey) {
|
|
|
let encryData = crypto.decrypt('', decodeURIComponent(req.cookies._QYH_UNION));
|
|
|
|
|
|
encryData = encryData.substr(0, encryData.lastIndexOf('}') + 1);
|
|
|
let testQyhUnion = JSON.parse(encryData);
|
|
|
|
|
|
unionKey = testQyhUnion.client_id ? encryData : '';
|
|
|
}
|
|
|
} else {
|
...
|
...
|
@@ -232,6 +237,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)}`);
|
|
|
}
|
|
|
|
|
|
// 提交成功清除Cookie
|
...
|
...
|
|