Authored by 郝肖肖

Merge branch 'hotfix/goodsXml'

@@ -49,12 +49,15 @@ const demoXml = (req, res) => { @@ -49,12 +49,15 @@ const demoXml = (req, res) => {
49 }; 49 };
50 50
51 const siteMapXml = (req, res) => { 51 const siteMapXml = (req, res) => {
52 - let sitemap = new Array(26).fill().map((val, k) => { 52 + req.ctx(SeoIndexModel).getGoodsPage().then(result => {
  53 + let sitemap = new Array(result).fill().map((val, k) => {
53 return `http://spiderwebhook.yoho.cn/dist/goods-xml/goods-${k + 1}.xml`; 54 return `http://spiderwebhook.yoho.cn/dist/goods-xml/goods-${k + 1}.xml`;
54 }); 55 });
55 56
56 res.setHeader('Content-Type', 'text/xml; charset=utf-8'); 57 res.setHeader('Content-Type', 'text/xml; charset=utf-8');
57 - res.render('seo/site-map', {sitemap}); 58 + return res.render('seo/site-map', {sitemap});
  59 + });
  60 +
58 }; 61 };
59 62
60 module.exports = { 63 module.exports = {
  1 +'use strict';
  2 +
  3 +const baiduBrand = {
  4 + 1: {
  5 + yoho: '',
  6 + baidu: ''
  7 + },
  8 + 999: {
  9 + yoho: '',
  10 + baidu: ''
  11 + }
  12 +};
  13 +
  14 +module.exports = baiduBrand;
@@ -9,7 +9,7 @@ const helpers = global.yoho.helpers; @@ -9,7 +9,7 @@ const helpers = global.yoho.helpers;
9 const goodsHbs = require(`${ROOT_PATH}/hbs/partials/seo/index.hbs`); 9 const goodsHbs = require(`${ROOT_PATH}/hbs/partials/seo/index.hbs`);
10 const util = require(`${ROOT_PATH}/libs/util`); 10 const util = require(`${ROOT_PATH}/libs/util`);
11 const redis = require(`${ROOT_PATH}/libs/redis`); 11 const redis = require(`${ROOT_PATH}/libs/redis`);
12 -const SIZE = 3000; 12 +const SIZE = 2500;
13 const GOODS_URL = 'http://spiderwebhook.yoho.cn/dist/goods-xml'; 13 const GOODS_URL = 'http://spiderwebhook.yoho.cn/dist/goods-xml';
14 14
15 class SeoIndexModel extends global.yoho.BaseModel { 15 class SeoIndexModel extends global.yoho.BaseModel {
@@ -201,6 +201,14 @@ class SeoIndexModel extends global.yoho.BaseModel { @@ -201,6 +201,14 @@ class SeoIndexModel extends global.yoho.BaseModel {
201 return sData; 201 return sData;
202 }); 202 });
203 } 203 }
  204 +
  205 + getGoodsPage() {
  206 + return this.searchList({page: 1, limit: 1}).then(rdata => {
  207 + let total = _.get(rdata, 'data.total', 0);
  208 +
  209 + return Math.ceil(total / SIZE);
  210 + });
  211 + }
204 } 212 }
205 213
206 module.exports = SeoIndexModel; 214 module.exports = SeoIndexModel;