Authored by htoooth

Merge branch 'hotfix/fix-reqid' of http://git.yoho.cn/fe/yohobuy-node into release/6.3

@@ -61,6 +61,11 @@ app.enable('trust proxy'); @@ -61,6 +61,11 @@ app.enable('trust proxy');
61 61
62 app.set('subdomain offset', 2); 62 app.set('subdomain offset', 2);
63 63
  64 +app.use((req, res, next) => {
  65 + req.isApmReport = _.get(req.app.locals, 'pc.open.bughd', false);
  66 + next();
  67 +});
  68 +
64 // 添加请求上下文 69 // 添加请求上下文
65 app.use(global.yoho.httpCtx()); 70 app.use(global.yoho.httpCtx());
66 71
@@ -86,7 +91,6 @@ require('./doraemon/middleware/yoho-session')(app); @@ -86,7 +91,6 @@ require('./doraemon/middleware/yoho-session')(app);
86 app.use((req, res, next) => { 91 app.use((req, res, next) => {
87 req.user = {}; // 全局的用户数据 92 req.user = {}; // 全局的用户数据
88 req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等 93 req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等
89 - req.isApmReport = _.get(req.app.locals, 'pc.open.bughd', false);  
90 94
91 if (!req.session) { 95 if (!req.session) {
92 req.session = {}; 96 req.session = {};
@@ -241,7 +241,9 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys @@ -241,7 +241,9 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys
241 * 购物车统计 241 * 购物车统计
242 */ 242 */
243 const formatShoppingCartData = (sc) => { 243 const formatShoppingCartData = (sc) => {
244 - 244 + if (!sc) {
  245 + return {};
  246 + }
245 return { 247 return {
246 discountAmount: sc.discount_amount, // 活动价 248 discountAmount: sc.discount_amount, // 活动价
247 fastShoppingCost: sc.fast_shopping_cost, 249 fastShoppingCost: sc.fast_shopping_cost,
@@ -33,7 +33,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -33,7 +33,7 @@ module.exports = class extends global.yoho.BaseModel {
33 33
34 if (info) { 34 if (info) {
35 Object.assign(resData, { 35 Object.assign(resData, {
36 - yoho_coin: info.yoho_coin.toFixed(2), 36 + yoho_coin: info.yoho_coin ? info.yoho_coin.toFixed(2) : 0,
37 use_yoho_coin: info.use_yoho_coin, 37 use_yoho_coin: info.use_yoho_coin,
38 total_yoho_coin_num: info.total_yoho_coin_num, 38 total_yoho_coin_num: info.total_yoho_coin_num,
39 yoho_coin_pay_rule: info.yoho_coin_pay_rule, 39 yoho_coin_pay_rule: info.yoho_coin_pay_rule,
@@ -190,7 +190,7 @@ module.exports = class favorite extends global.yoho.BaseModel { @@ -190,7 +190,7 @@ module.exports = class favorite extends global.yoho.BaseModel {
190 page = page > pageTotal ? pageTotal : page; 190 page = page > pageTotal ? pageTotal : page;
191 191
192 result.goods = that.getGoodsInfo(productList, page, limit); 192 result.goods = that.getGoodsInfo(productList, page, limit);
193 - result.pager = pager(total, Object.assign(query, {hasCheckAll: true})); 193 + result.pager = pager(total, Object.assign({}, query, {hasCheckAll: true}));
194 194
195 return result; 195 return result;
196 })(); 196 })();
@@ -311,7 +311,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -311,7 +311,7 @@ module.exports = class extends global.yoho.BaseModel {
311 ], 311 ],
312 certifiedName: +isStudent ? '学生身份已验证' : '身份验证', 312 certifiedName: +isStudent ? '学生身份已验证' : '身份验证',
313 certifiedUrl: helpers.urlFormat('/product/students/'), 313 certifiedUrl: helpers.urlFormat('/product/students/'),
314 - latestOrders: Object.assign(indexData.recentOrder, {cancelReason: indexData.reason}) 314 + latestOrders: Object.assign({}, indexData.recentOrder, {cancelReason: indexData.reason})
315 }, 315 },
316 banner: indexData.footerBanner 316 banner: indexData.footerBanner
317 } 317 }
@@ -822,7 +822,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -822,7 +822,7 @@ module.exports = class extends global.yoho.BaseModel {
822 detail.orderInfo = { 822 detail.orderInfo = {
823 receiver: orderDetail.user_name, 823 receiver: orderDetail.user_name,
824 address: orderDetail.area + orderDetail.address, 824 address: orderDetail.area + orderDetail.address,
825 - phone: _.fill(orderDetail.mobile.split(''), '*', 3, 4).join('') + 825 + phone: _.fill((orderDetail.mobile ? orderDetail.mobile.split('') : ''), '*', 3, 4).join('') +
826 (orderDetail.phone ? ',' + _.fill(orderDetail.phone.split(''), '*', 3, 5).join('') : '') 826 (orderDetail.phone ? ',' + _.fill(orderDetail.phone.split(''), '*', 3, 5).join('') : '')
827 }; 827 };
828 828
@@ -1007,7 +1007,7 @@ function _getCoupon(coupons) { @@ -1007,7 +1007,7 @@ function _getCoupon(coupons) {
1007 1007
1008 let pickProp = Fn.pick(['couponName', 'amount', 'couponId', 'acquireStatus', 'rule4ShortName']); 1008 let pickProp = Fn.pick(['couponName', 'amount', 'couponId', 'acquireStatus', 'rule4ShortName']);
1009 let encodeId = Fn.update('couponId', (cid) => crypto.encryption(null, cid + '')); 1009 let encodeId = Fn.update('couponId', (cid) => crypto.encryption(null, cid + ''));
1010 - let replace = Fn.update('rule4ShortName', (r) => r.replace(/¥/g, ')); 1010 + let replace = Fn.update('rule4ShortName', (r) => (r ? r.replace(/¥/g, '¥') : ''));
1011 1011
1012 return Fn.map(Fn.pipe(pickProp, encodeId, replace))(couponList); 1012 return Fn.map(Fn.pipe(pickProp, encodeId, replace))(couponList);
1013 } 1013 }
@@ -212,7 +212,7 @@ class FilterTools { @@ -212,7 +212,7 @@ class FilterTools {
212 const condition = {}; 212 const condition = {};
213 213
214 if (k === 'price') { 214 if (k === 'price') {
215 - if (filter.priceRange[params.price]) { 215 + if (filter.priceRange && filter.priceRange[params.price]) {
216 condition.name = filter.priceRange[params.price].replace('¥', '¥'); 216 condition.name = filter.priceRange[params.price].replace('¥', '¥');
217 } else { 217 } else {
218 const prices = _.split(params.price, ','); 218 const prices = _.split(params.price, ',');
@@ -57,7 +57,7 @@ @@ -57,7 +57,7 @@
57 "urlencode": "^1.1.0", 57 "urlencode": "^1.1.0",
58 "uuid": "^2.0.2", 58 "uuid": "^2.0.2",
59 "yoho-express-session": "^2.0.0", 59 "yoho-express-session": "^2.0.0",
60 - "yoho-node-lib": "=0.5.29", 60 + "yoho-node-lib": "=0.5.30",
61 "yoho-zookeeper": "^1.0.8" 61 "yoho-zookeeper": "^1.0.8"
62 }, 62 },
63 "devDependencies": { 63 "devDependencies": {