Merge remote-tracking branch 'origin/master' into hotfix/limit
Showing
6 changed files
with
25 additions
and
8 deletions
@@ -7,9 +7,14 @@ const simpleHeaderModel = require('../../../doraemon/models/simple-header'); | @@ -7,9 +7,14 @@ const simpleHeaderModel = require('../../../doraemon/models/simple-header'); | ||
7 | const logger = global.yoho.logger; | 7 | const logger = global.yoho.logger; |
8 | 8 | ||
9 | const index = (req, res) => { | 9 | const index = (req, res) => { |
10 | + let remoteIp = req.yoho.clientIp || ''; | ||
11 | + | ||
12 | + logger.info(`limit remote ip: ${remoteIp}; ua: ${req.header('User-Agent')}; uid: ${req.user.uid}; reqId: ${req.reqID}`); // eslint-disable-line | ||
13 | + | ||
10 | return res.render('robot-check', { | 14 | return res.render('robot-check', { |
11 | module: '3party', | 15 | module: '3party', |
12 | page: 'robot-check', | 16 | page: 'robot-check', |
17 | + reqId: req.reqID, | ||
13 | simpleHeader: simpleHeaderModel.setSimpleHeaderData() | 18 | simpleHeader: simpleHeaderModel.setSimpleHeaderData() |
14 | }); | 19 | }); |
15 | }; | 20 | }; |
1 | -<div class="robot-check-page yoho-page"> | 1 | +<div class="robot-check-page yoho-page" data-reqid="{{reqId}}"> |
2 | <div class="captcha"> | 2 | <div class="captcha"> |
3 | <div class="title">您的操作太频繁了~请完成以下操作后继续</div> | 3 | <div class="title">您的操作太频繁了~请完成以下操作后继续</div> |
4 | <div class="captcha-wrap"> </div> | 4 | <div class="captcha-wrap"> </div> |
@@ -88,7 +88,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -88,7 +88,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
88 | ensureHandleModel.handleViewPrice(result.data.promotion_formula_list); | 88 | ensureHandleModel.handleViewPrice(result.data.promotion_formula_list); |
89 | } | 89 | } |
90 | 90 | ||
91 | - result.data = Object.assign(result.data, ensureHandleModel.handleUseYohoCoin(result.data)); | 91 | + result.data = Object.assign(result.data || {}, ensureHandleModel.handleUseYohoCoin(result.data)); |
92 | } | 92 | } |
93 | 93 | ||
94 | return result; | 94 | return result; |
@@ -217,13 +217,25 @@ module.exports = class favorite extends global.yoho.BaseModel { | @@ -217,13 +217,25 @@ module.exports = class favorite extends global.yoho.BaseModel { | ||
217 | } | 217 | } |
218 | 218 | ||
219 | result.brands = _.get(brand, 'data.brand_list', []).map((item) => { | 219 | result.brands = _.get(brand, 'data.brand_list', []).map((item) => { |
220 | + let url = ''; | ||
221 | + | ||
222 | + switch (item.brandOrShopType) { | ||
223 | + case 'shop': | ||
224 | + url = helpers.urlFormat(`/shop/${item.brand_domain}-${item.shop_id}.html`, null); | ||
225 | + break; | ||
226 | + case 'brand': | ||
227 | + url = helpers.urlFormat('/search/', {brand: item.brand_id}); | ||
228 | + break; | ||
229 | + default: | ||
230 | + break; | ||
231 | + } | ||
232 | + | ||
220 | return { | 233 | return { |
221 | id: item.brand_id, | 234 | id: item.brand_id, |
222 | brandOrShopType: item.brandOrShopType || '', | 235 | brandOrShopType: item.brandOrShopType || '', |
223 | shop_id: item.shop_id || '', | 236 | shop_id: item.shop_id || '', |
224 | img: helpers.image(item.brand_ico, 100, 100), | 237 | img: helpers.image(item.brand_ico, 100, 100), |
225 | - | ||
226 | - url: helpers.urlFormat(`/shop/${item.brand_domain}-${item.shop_id}.html`, null), | 238 | + url: url, |
227 | name: item.brand_name, | 239 | name: item.brand_name, |
228 | naCount: item.new_product_num, | 240 | naCount: item.new_product_num, |
229 | colCount: item.brand_favorite_num | 241 | colCount: item.brand_favorite_num |
@@ -406,17 +406,19 @@ function getSaleDiscountData(params, channel) { | @@ -406,17 +406,19 @@ function getSaleDiscountData(params, channel) { | ||
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
409 | + let productPool = _.get(result, '[1].data[0].product_pool'); | ||
410 | + | ||
409 | // 这里把 channel 全都处理掉,因为根据channel查小分类,而传入商品池时,不需要 | 411 | // 这里把 channel 全都处理掉,因为根据channel查小分类,而传入商品池时,不需要 |
410 | return Promise.all([ | 412 | return Promise.all([ |
411 | this.saleApi.getSaleGoodsList({ | 413 | this.saleApi.getSaleGoodsList({ |
412 | channel: null, | 414 | channel: null, |
413 | saleType: '3', | 415 | saleType: '3', |
414 | limit: '1', | 416 | limit: '1', |
415 | - productPool: result[1].data[0].product_pool | 417 | + productPool: productPool |
416 | }), | 418 | }), |
417 | this.saleApi.getSaleGoodsList(Object.assign({}, params, { | 419 | this.saleApi.getSaleGoodsList(Object.assign({}, params, { |
418 | channel: null, | 420 | channel: null, |
419 | - productPool: result[1].data[0].product_pool | 421 | + productPool: productPool |
420 | })) | 422 | })) |
421 | ]).then(subResult => { | 423 | ]).then(subResult => { |
422 | // 删除无用参数 | 424 | // 删除无用参数 |
@@ -91,8 +91,6 @@ module.exports = (req, res, next) => { | @@ -91,8 +91,6 @@ module.exports = (req, res, next) => { | ||
91 | if (exclusion) { | 91 | if (exclusion) { |
92 | return next(); | 92 | return next(); |
93 | } else if (!allPass && policy) { | 93 | } else if (!allPass && policy) { |
94 | - logger.info(`limit remote ip: ${remoteIp}; ua: ${req.header('User-Agent')}; uid: ${req.user.uid}`); | ||
95 | - | ||
96 | policy(req, res, next); | 94 | policy(req, res, next); |
97 | } else { | 95 | } else { |
98 | return next(); | 96 | return next(); |
-
Please register or login to post a comment