Authored by htoooth

add find by skn

'use strict';
const helpers = global.yoho.helpers;
const mRoot = '../models';
const service = require(`${mRoot}/erp2goods-service`);
const findBySkn = (req, res, next) => {
let skn = req.query.skn || '';
service.findBySkn(skn).then((result) => {
if (result.url) {
return res.redirect(helpers.urlFormat(result.url, null, 'item'));
}
}).catch(next);
};
module.exports = {
findBySkn
};
... ...
/**
* Created by TaoHuang on 2016/11/14.
*/
'use strict';
const api = global.yoho.API;
const config = global.yoho.config;
/**
* 获得产品信息
* @param pid
* @returns {Promise.<type>}
*/
const getProductAsync = (skn) => {
let params = {
method: 'app.product.data',
product_skn: skn
};
return api.get('', params, config.apiCache);
};
module.exports = {
getProductAsync
};
... ...
/**
* Created by TaoHuang on 2016/11/14.
*/
'use strict';
const api = require('./erp2goods-api');
const _ = require('lodash');
const url = require('url');
const findBySkn = (skn) => {
return api.getProductAsync(skn).then((result) => {
return {
url: url.parse(_.get(result, 'data.product_url', '')).path
};
});
};
module.exports = {
findBySkn
};
... ...
... ... @@ -14,9 +14,12 @@ var multipartMiddleware = multipart();
const rvCtrl = require(`${cRoot}/recent-view`);
const uploadCtrl = require(`${cRoot}/upload`);
const erp2goods = require(`${cRoot}/erp2goods`);
router.get('/recentReview', rvCtrl.index); // 最近浏览
router.post('/upload/image', multipartMiddleware, uploadCtrl.uploadImg);
router.get('/erp2goods', erp2goods.findBySkn);
module.exports = router;
... ...
... ... @@ -17,11 +17,11 @@ module.exports = {
cookieDomain: '.yohobuy.com',
domains: {
favApi: 'http://192.168.102.31:8092/brower',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
//api: 'http://api-test3.yohops.com:9999/',
//service: 'http://service-test3.yohops.com:9999/',
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
// api: 'http://dev-api.yohops.com:9999/',
// service: 'http://dev-service.yohops.com:9999/',
... ...