Authored by 毕凯

Merge branch 'hotfix/apple' into 'release/5.9'

促销标签



See merge request !702
... ... @@ -154,8 +154,9 @@ class BuyNowController {
* @param {*} next
*/
orderSub(req, res, next) {
let uid = req.user.uid;
let params = {
uid: req.user.uid,
uid: uid,
product_sku: req.body.product_sku,
sku_type: req.body.sku_type,
buy_number: req.body.buy_number,
... ... @@ -170,7 +171,8 @@ class BuyNowController {
product_sku_list: req.body.product_sku_list,
is_print_price: req.body.is_print_price,
remark: req.body.remark,
activity_id: req.body.activity_id
activity_id: req.body.activity_id,
ip: req.yoho.clientIp
};
// 是否开发票
... ... @@ -186,6 +188,13 @@ class BuyNowController {
}
}
if (req.cookies.mkt_code || req.cookies._QYH_UNION) {
let unionInfo = paymentProcess.unionInfoHandle(req.cookies, uid);
params.qhy_union = _.get(unionInfo, 'unionKey', false);
params.userAgent = _.get(unionInfo, 'userAgent', '');
}
co(function * () {
let result = yield req.ctx(BuyNowModel).submit(params);
... ...
... ... @@ -231,7 +231,7 @@ exports.orderSub = (req, res, next) => {
unionKey: unionInfo.unionKey, // 友盟数据
userAgent: unionInfo.userAgent,
isWechat: req.yoho.isWechat,
ip: req.ip || '',
ip: req.yoho.clientIp,
udid: req.cookies._yasvd || 'yoho'
};
... ...
... ... @@ -159,7 +159,16 @@ class BuyNowModel extends global.yoho.BaseModel {
finalParams.promotion_code = params.promotion_code;
}
return api.post('', finalParams, {cache: false});
if (params.qhy_union) {
finalParams.qhy_union = params.qhy_union;
}
return api.post('', finalParams, {
headers: {
'X-Forwarded-For': params.ip || '',
'User-Agent': params.userAgent
}
});
}
/**
... ...
... ... @@ -304,11 +304,47 @@ const keyword = (req, res, next) => {
}).catch(next);
};
// 关键词页with id
const keyId = (req, res, next) => {
let params = {
isSearch: true, // 搜索列表将最新改成默认的标识
cartUrl: helpers.urlFormat('/cart/index/index')
};
params.isApp = req.yoho.isApp;
params.physical_channel = req.yoho.channel && searchProcess.getChannelType(req.yoho.channel);
return searchModel.getSearchKeywordDataById(req.params.id, params, req.user.uid).then(result => {
let queryKey = result.queryKey;
// 唤起 APP 的路径
res.locals.appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.list","params":${JSON.stringify(params)}}`;
res.render('search/list', {
_noLazy: true,
module: 'product',
page: 'search-list',
pageHeader: headerModel.setNav({
navTitle: queryKey
}),
goodList: params,
firstPageGoods: result || [],
fuzzyWord: result.fuzzyWord,
title: `${queryKey}价格_图片_品牌_怎么样-YOHO!BUY有货`,
keywords: `${queryKey},${queryKey}价格,${queryKey}图片,${queryKey}怎么样,${queryKey}品牌,YOHO!BUY有货`,
description: `YOHO!BUY有货网yohobuy.com是国内专业的${queryKey}网上潮流购物商城,为您找到${_.get(result,
'total', 0)}${queryKey}、产品的详细参数,实时报价,价格行情,图片、评价、品牌等信息。买${queryKey},就上YOHO!BUY有货`,
pageFooter: true
});
}).catch(next);
};
module.exports = {
list,
filter,
search,
index,
fuzzyDatas,
keyword
keyword,
keyId
};
... ...
... ... @@ -13,6 +13,7 @@ const logger = global.yoho.logger;
const api = global.yoho.API;
const cache = require('memory-cache');
const helpers = global.yoho.helpers;
const redis = global.yoho.redis;
/**
* 封面图
... ... @@ -539,6 +540,41 @@ const getSearchKeywordData = (params, uid) => {
});
};
const getSearchKeywordDataById = (id, params, uid) => {
return redis.all([
['get', `golobal:yoho:seo:keywords:id:${id}`]
]).then(redisData => {
if (!redisData[0]) {
return Promise.reject('get redis canpin keywords by id error!' +
`key: golobal:yoho:seo:keywords:id:${id} value: ${redisData[0]}`);
}
redisData = JSON.parse(redisData[0]);
params.query = redisData.name;
return getSearchKeywordData(params, uid).then(result => {
result.queryKey = params.query;
if (!_.isEmpty(redisData.data)) {
_.forEach(redisData.data, value => {
if (!value) {
return;
}
Object.assign(value, {
name: value.keyword,
link: helpers.urlFormat(`/chanpin/${value.id}.html`, null)
});
});
_.set(result, 'fuzzyWord', redisData.data);
}
return result;
});
});
};
module.exports = {
getSearchData,
getFilterData,
... ... @@ -549,5 +585,6 @@ module.exports = {
getFuzzyDatas,
searchKeyActivity,
getBrandDomain,
getSearchKeywordData
getSearchKeywordData,
getSearchKeywordDataById
};
... ...
... ... @@ -134,8 +134,9 @@ router.get('/seckill/get-product-list', seckill.getProductList); // 秒杀列表
// 搜索主页
router.get('/search/index', search.index);
// 搜索落地页
router.get('/search/keyword/:query', rewrite.sortParams, search.keyword);
// 推广落地页
router.get('/search/so/:query.html', rewrite.sortParams, search.keyword);
router.get('/search/chanpin/:id.html', rewrite.sortParams, search.keyId);
// 搜索落地页
router.get('/search/list', rewrite.sortParams, search.list);
... ...
... ... @@ -104,7 +104,8 @@ const cachePage = {
'/activity/shopNav': 30 * SECOND,
// 关键词页面
'/product/search/keyword/:query': 7 * DAY
'/product/search/so/:query.html': 7 * DAY,
'/product/search/chanpin/:id.html': 7 * DAY
};
... ...
const _ = require('lodash');
const redis = require('redis');
const bluebird = require('bluebird');
const config = require('../../config/common');
... ... @@ -9,6 +11,18 @@ try {
bluebird.promisifyAll(redis.RedisClient.prototype);
bluebird.promisifyAll(redis.Multi.prototype);
client.all = args => {
if (!client.ready) {
if (Array.isArray(args)) {
return Promise.resolve(_.fill(args, false));
} else {
return Promise.resolve(false);
}
}
return client.multi.call(client, args).execAsync();
};
client.on('error', function() {
global.yoho.redis = '';
});
... ...
... ... @@ -84,14 +84,8 @@ module.exports = () => {
}
break;
}
} else {
let soReg = /\/so\/(.*).html/;
if (soReg.test(req.path)) {
soReg.exec(req.url);
req.url = `/product/search/keyword/${RegExp.$1}`;
}
}
next();
};
};
... ...
... ... @@ -61,6 +61,11 @@ module.exports = () => {
req.url = '/activity/couponSend';
}
if (/\/chanpin\/(.*).html/.test(req.url) || /\/so\/(.*).html/.test(req.url)) {
// 获取seo兼容
req.url = `/product/search${req.path}`;
}
next();
};
};
... ...
... ... @@ -3,10 +3,10 @@
<div class="goods-discount" id="goodsDiscount">
{{#each promotion}}
{{#if @first}}
<h1 class="first-item short-text tap-hightlight">{{promotionTitle}}<span class="icon-down iconfont dropdown">&#xe609;</span></h1>
<h1 class="first-item short-text tap-hightlight"><span class="promotion-icon"></span>{{promotionTitle}}<span class="icon-down iconfont dropdown">&#xe609;</span></h1>
{{else}}
<div class="discount-folder">
<h1 class="folder-item tap-hightlight">{{promotionTitle}}</h1>
<h1 class="folder-item tap-hightlight"><span class="promotion-icon"></span>{{promotionTitle}}</h1>
</div>
{{/if}}
{{/each}}
... ...
... ... @@ -11,7 +11,7 @@ let $ = require('yoho-jquery'),
require('./detail/page-render')(function() {
let $discountFolder = $('.goods-discount .discount-folder'),
$discountArrow = $('.goods-discount .first-item span');
$discountArrow = $('.goods-discount .first-item .iconfont');
let goodsDiscountEl = document.getElementById('goodsDiscount'),
goodsDiscountHammer = goodsDiscountEl && new Hammer(goodsDiscountEl),
... ...
... ... @@ -304,7 +304,7 @@ setTimeout(() => {
let $goodsDiscount = $('#goodsDiscount');
let $discountFirstItem = $goodsDiscount.find('.first-item');
let $discountFolder = $goodsDiscount.find('.discount-folder');
let $discountArrow = $goodsDiscount.find('.first-item span');
let $discountArrow = $goodsDiscount.find('.first-item .iconfont');
// 初始化goods-discount
if ($discountFolder.children().length === 0) {
... ...
... ... @@ -711,6 +711,17 @@ $basicBtnC: #eb0313;
line-height: 36px;
}
.first-item > .promotion-icon,
.folder-item > .promotion-icon {
background-color: #d0021b;
color: #fff;
padding: 0 4px;
border-radius: 4px;
margin-right: 10px;
font-size: 22px;
float: left;
}
.short-text {
overflow: hidden;
text-overflow: ellipsis;
... ...
... ... @@ -336,10 +336,10 @@ function coupon(count, orderInfo, orderComputeData) {
count: count
};
if (
orderComputeData.coupon_amount ||
(orderComputeData.coupon_amount === 0 && orderComputeData.shipping_cost === 0)
) {
let couponAmount = _.get(orderComputeData, 'coupon_amount', false);
let shippingCost = _.get(orderComputeData, 'shipping_cost', false); // shipping_cost 是普通运费
if (couponAmount || (couponAmount === 0 && shippingCost === 0)) {
coupons.couponName = orderInfo.couponName;
}
... ... @@ -443,8 +443,10 @@ function unionInfoHandle(cookies, uid) {
}
/* 模拟APP的User-Agent */
userAgent = clientId ? 'YOHO!Buy/3.8.2.259(Model/PC;Channel/' +
clientId + ';uid/' + uid + ')' : null;
let clientIdSub = _.split(clientId, ',')[0];
userAgent = clientIdSub ? 'YOHO!Buy/3.8.2.259(Model/H5;Channel/' +
clientIdSub + ';uid/' + uid + ')' : null;
return {
unionKey: unionKey,
... ...