Authored by 郭成尧

logger-data-verify

@@ -156,7 +156,8 @@ const add = (req, res, next) => { @@ -156,7 +156,8 @@ const add = (req, res, next) => {
156 return indexModel.addToCart(productSku, buyNumber, goodsType, isEdit, promotionId, uid, shoppingKey).then(data => { 156 return indexModel.addToCart(productSku, buyNumber, goodsType, isEdit, promotionId, uid, shoppingKey).then(data => {
157 if (!shoppingKey && _.has(data, 'data.shopping_key')) { 157 if (!shoppingKey && _.has(data, 'data.shopping_key')) {
158 res.cookie('_SPK', data.data.shopping_key, { 158 res.cookie('_SPK', data.data.shopping_key, {
159 - expires: new Date(Date.now() + 86400 * 360) 159 + expires: new Date(Date.now() + 86400 * 360),
  160 + domain: '.m.yohobuy.com'
160 }); 161 });
161 } 162 }
162 data ? res.json(data) : res.status(400).json({ 163 data ? res.json(data) : res.status(400).json({
@@ -3,12 +3,27 @@ @@ -3,12 +3,27 @@
3 const api = global.yoho.API; 3 const api = global.yoho.API;
4 4
5 const cartCount = (uid, shoppingKey) => { 5 const cartCount = (uid, shoppingKey) => {
  6 + let params = {
  7 + method: 'app.Shopping.count'
  8 + };
6 9
7 - return api.get('', {  
8 - method: 'app.Shopping.count',  
9 - uid: uid,  
10 - shopping_key: shoppingKey  
11 - }).then((result) => { 10 + if (!uid && !shoppingKey) {
  11 + return Promise.resolve({});
  12 + }
  13 +
  14 + if (uid) {
  15 + Object.assign(params, {
  16 + uid: uid
  17 + });
  18 + }
  19 +
  20 + if (shoppingKey) {
  21 + Object.assign(params, {
  22 + shopping_key: shoppingKey
  23 + });
  24 + }
  25 +
  26 + return api.get('', params).then((result) => {
12 return result; 27 return result;
13 }); 28 });
14 }; 29 };
@@ -28,7 +28,7 @@ const _userData = (params) => { @@ -28,7 +28,7 @@ const _userData = (params) => {
28 code: 200 28 code: 200
29 }); 29 });
30 } else { 30 } else {
31 - return false; 31 + return Promise.resolve({});
32 } 32 }
33 }; 33 };
34 34
@@ -82,12 +82,19 @@ exports.getShopCategory = (shopId, channel) => { @@ -82,12 +82,19 @@ exports.getShopCategory = (shopId, channel) => {
82 * 店铺收藏数量 82 * 店铺收藏数量
83 */ 83 */
84 exports.favCount = (shopId, uid, channel, udid) => { 84 exports.favCount = (shopId, uid, channel, udid) => {
85 - return singleAPI.get('favorite', { 85 + let finalParams = {
86 method: 'app.favorite.queryFavoriteCountByShopIds', 86 method: 'app.favorite.queryFavoriteCountByShopIds',
87 favIds: shopId, 87 favIds: shopId,
88 type: 'shop', 88 type: 'shop',
89 udid: udid, 89 udid: udid,
90 - uid: uid,  
91 physical_channel: yhChannel[channel], 90 physical_channel: yhChannel[channel],
92 - }); 91 + };
  92 +
  93 + if (uid) {
  94 + Object.assign(finalParams, {
  95 + uid: uid
  96 + });
  97 + }
  98 +
  99 + return singleAPI.get('favorite', finalParams);
93 }; 100 };
@@ -51,6 +51,8 @@ exports.serverError = () => { @@ -51,6 +51,8 @@ exports.serverError = () => {
51 forceNoCache(res); 51 forceNoCache(res);
52 52
53 if (err && err.code === 401) { 53 if (err && err.code === 401) {
  54 + 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
  55 +
54 if (req.xhr) { 56 if (req.xhr) {
55 return res.status(401).json(err); 57 return res.status(401).json(err);
56 } else if (req.yoho.isApp) { 58 } else if (req.yoho.isApp) {