Authored by 毕凯

Merge branch 'hotfix/dataverify' into 'master'

Hotfix/dataverify



See merge request !525
... ... @@ -156,7 +156,8 @@ const add = (req, res, next) => {
return indexModel.addToCart(productSku, buyNumber, goodsType, isEdit, promotionId, uid, shoppingKey).then(data => {
if (!shoppingKey && _.has(data, 'data.shopping_key')) {
res.cookie('_SPK', data.data.shopping_key, {
expires: new Date(Date.now() + 86400 * 360)
expires: new Date(Date.now() + 86400 * 360),
domain: '.m.yohobuy.com'
});
}
data ? res.json(data) : res.status(400).json({
... ...
... ... @@ -3,12 +3,27 @@
const api = global.yoho.API;
const cartCount = (uid, shoppingKey) => {
let params = {
method: 'app.Shopping.count'
};
return api.get('', {
method: 'app.Shopping.count',
uid: uid,
shopping_key: shoppingKey
}).then((result) => {
if (!uid && !shoppingKey) {
return Promise.resolve({});
}
if (uid) {
Object.assign(params, {
uid: uid
});
}
if (shoppingKey) {
Object.assign(params, {
shopping_key: shoppingKey
});
}
return api.get('', params).then((result) => {
return result;
});
};
... ...
... ... @@ -145,8 +145,7 @@ const addressModify = (req, res, next) => {
addressModel.getAddressData({uid: uid}).then(result => {
let userAddressList = result;
let addressData = addressProcess.getAddressByAreaCode(areaCode,
_.get(userAddressList, 'data', [])) || {};
let addressData = addressProcess.getAddressByAreaCode(areaCode, _.get(userAddressList, 'data', [])) || {};
Object.assign(addressData, {
orderCode: orderCode,
... ... @@ -154,7 +153,7 @@ const addressModify = (req, res, next) => {
if (provinceAreaCode) {
// 不允许修改省份,字符串拆分
let areaArray = addressData.area.split(' ');
let areaArray = addressData.area ? addressData.area.split(' ') : [];
let area = _.slice(areaArray, 1);
Object.assign(addressData, {
... ...
... ... @@ -28,7 +28,7 @@ const _userData = (params) => {
code: 200
});
} else {
return false;
return Promise.resolve({});
}
};
... ...
... ... @@ -82,12 +82,19 @@ exports.getShopCategory = (shopId, channel) => {
* 店铺收藏数量
*/
exports.favCount = (shopId, uid, channel, udid) => {
return singleAPI.get('favorite', {
let finalParams = {
method: 'app.favorite.queryFavoriteCountByShopIds',
favIds: shopId,
type: 'shop',
udid: udid,
uid: uid,
physical_channel: yhChannel[channel],
});
};
if (uid) {
Object.assign(finalParams, {
uid: uid
});
}
return singleAPI.get('favorite', finalParams);
};
... ...
... ... @@ -51,6 +51,8 @@ exports.serverError = () => {
forceNoCache(res);
if (err && err.code === 401) {
logger.error(`401 error info:client_type=${req.query.client_type},req.user=${JSON.stringify(req.user)},req.query=${JSON.stringify(req.query)},cookies=${JSON.stringify(req.cookies)}`); // eslint-disable-line
if (req.xhr) {
return res.status(401).json(err);
} else if (req.yoho.isApp) {
... ...