...
|
...
|
@@ -9,7 +9,10 @@ |
|
|
const _ = require('lodash');
|
|
|
const api = global.yoho.API;
|
|
|
const UfoApi = global.yoho.UfoAPI;
|
|
|
const StoreApi = global.yoho.StoreAPI;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const crypto = global.yoho.crypto;
|
|
|
const cache = global.yoho.cache.master;
|
|
|
const yasProcess = require('../../../utils/yas-process');
|
|
|
const moment = require('moment');
|
|
|
|
...
|
...
|
@@ -77,7 +80,8 @@ class featureModel extends global.yoho.BaseModel { |
|
|
product_price_plan_list: _.sortBy(val.product_price_plan_list, o => {
|
|
|
return +o.show_begin_time;
|
|
|
}),
|
|
|
stock_number: val.stock_number
|
|
|
stock_number: val.stock_number,
|
|
|
totalSalesNum: val.total_sales_num
|
|
|
};
|
|
|
|
|
|
if (val.shop_id) {
|
...
|
...
|
@@ -94,6 +98,7 @@ class featureModel extends global.yoho.BaseModel { |
|
|
let defaultPros = [];
|
|
|
|
|
|
let baseConf = {
|
|
|
ufoProduct: value.ufoProduct,
|
|
|
searchCondition: value.searchCondition,
|
|
|
lefTopImg: value.lefTopImg,
|
|
|
rigTopImg: value.rigTopImg,
|
...
|
...
|
@@ -113,7 +118,9 @@ class featureModel extends global.yoho.BaseModel { |
|
|
priceBgImage: value.priceBgImage,
|
|
|
shopBgImage: value.shopBgImage,
|
|
|
enterShopBgImage: value.enterShopBgImage,
|
|
|
brandColor: value.brandColor
|
|
|
brandColor: value.brandColor,
|
|
|
buyBtnImg: value.buyBtnImg,
|
|
|
showLastSoldTpl: value.showLastSoldTpl
|
|
|
};
|
|
|
|
|
|
value._defaultSkns && value._defaultSkns.forEach(val => {
|
...
|
...
|
@@ -139,7 +146,9 @@ class featureModel extends global.yoho.BaseModel { |
|
|
}
|
|
|
|
|
|
if (pro) {
|
|
|
defaultPros.push(Object.assign({conf: baseConf}, pro));
|
|
|
defaultPros.push(Object.assign({conf: baseConf}, pro, {
|
|
|
lastSoldText: (value.showLastSoldTpl && pro.totalSalesNum) ? value.showLastSoldTpl.replace('{{soldNum}}', pro.totalSalesNum) : ''
|
|
|
}));
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
@@ -285,7 +294,7 @@ class featureModel extends global.yoho.BaseModel { |
|
|
*/
|
|
|
_formatSeckillCouponTime(featureData = {}) {
|
|
|
const {floors = []} = featureData;
|
|
|
|
|
|
|
|
|
const seckillCouponFloor = floors.find(floor=> {
|
|
|
const {component} = floor;
|
|
|
const isSeckillCoupon = !!component.find(c => c.seckillCoupon === '1');
|
...
|
...
|
@@ -331,7 +340,7 @@ class featureModel extends global.yoho.BaseModel { |
|
|
const { hour, year, month, day } = tabInfo;
|
|
|
const nextTab = array[index + 1];
|
|
|
const tabTime = new Date(`${year}-${month}-${day} ${hour}:00:00`).getTime();
|
|
|
const nextTabTime = nextTab ?
|
|
|
const nextTabTime = nextTab ?
|
|
|
new Date(`${nextTab.year}-${nextTab.month}-${nextTab.day} ${nextTab.hour}:00:00`).getTime() :
|
|
|
0;
|
|
|
|
...
|
...
|
@@ -366,24 +375,28 @@ class featureModel extends global.yoho.BaseModel { |
|
|
for(const floor of floors) {
|
|
|
const {component, tabname, tableComp = '{}'} = floor;
|
|
|
const colNum = +JSON.parse(tableComp).col || 1;
|
|
|
|
|
|
|
|
|
|
|
|
if(tabname) {
|
|
|
const tabInfo = tabList.find(tab=> tab.link === tabname);
|
|
|
|
|
|
|
|
|
if(tabInfo) {
|
|
|
let statusImgOnce = false;
|
|
|
const {startTime,status} = tabInfo;
|
|
|
|
|
|
floor.component = component.map(c=> {
|
|
|
if(c.type === 'coupon' && colNum === 1) {
|
|
|
|
|
|
return {...c, startTime, endOfDayTime, currentTime, status, statusImg: seckillCouponStatusInfo};
|
|
|
if(c.type === 'coupon') {
|
|
|
let statusImg = statusImgOnce ? '' : seckillCouponStatusInfo;
|
|
|
|
|
|
statusImgOnce = true;
|
|
|
|
|
|
return {...c, startTime, endOfDayTime, currentTime, status, statusImg};
|
|
|
}else {
|
|
|
return c;
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -461,31 +474,49 @@ class featureModel extends global.yoho.BaseModel { |
|
|
f.component[0].isStyle2 = _.get(f, 'component[0].newStyle') === '2' && _.get(f, 'component[0].numOfOneRow') === '2';// eslint-disable-line
|
|
|
}
|
|
|
|
|
|
if (f.component && f.component[0] &&
|
|
|
f.component[0].type === 'productGroup' && f.component[0].defaultSkns) {
|
|
|
if (componentType === 'productGroup') {
|
|
|
if (f.component[0].defaultSkns) {
|
|
|
componentArr.push(f.component[0]);
|
|
|
|
|
|
componentArr.push(f.component[0]);
|
|
|
|
|
|
f.component[0].newStyle = _.get(f, 'component[0].newStyle');
|
|
|
}
|
|
|
|
|
|
if (f.component && f.component[0] &&
|
|
|
f.component[0].type === 'productGroup' && f.component[0].favourite_prds_enable === '1') {
|
|
|
f.component[0].searchCondition = Object.assign({
|
|
|
maybeLike: '1',
|
|
|
limit: '60'
|
|
|
}, f.component[0].searchCondition || {});
|
|
|
f.component[0].newStyle = _.get(f, 'component[0].newStyle');
|
|
|
}
|
|
|
|
|
|
f.component[0].newStyle = _.get(f, 'component[0].newStyle');
|
|
|
if (f.component[0].favourite_prds_enable === '1') {
|
|
|
f.component[0].searchCondition = Object.assign({
|
|
|
maybeLike: '1',
|
|
|
limit: '60'
|
|
|
}, f.component[0].searchCondition || {});
|
|
|
|
|
|
}
|
|
|
f.component[0].newStyle = _.get(f, 'component[0].newStyle');
|
|
|
}
|
|
|
|
|
|
// 对背景图做特殊处理
|
|
|
if (f.component && f.component[0] && f.component[0].type === 'productGroup') {
|
|
|
if (f.param.bgimg) { // 对背景图做特殊处理
|
|
|
// 对背景图做特殊处理
|
|
|
if (f.param.bgimg) {
|
|
|
f.param._bgimgFill = f.param.bgimg;
|
|
|
f.param.bgimg = '';
|
|
|
}
|
|
|
|
|
|
// 默认为非ufo商品
|
|
|
f.component[0].ufoProduct = f.component[0].ufoProduct || '0';
|
|
|
|
|
|
// 一行一个商品或UFO商品展示销售数量
|
|
|
if (_.get(f, 'component[0].ufoProduct') === '1' || _.get(f, 'component[0].numOfOneRow') === '1') {
|
|
|
let showLastSoldTpl = '';
|
|
|
|
|
|
if (_.get(f, 'component[0].ufoProduct') === '1') {
|
|
|
showLastSoldTpl = '{{soldNum}}人付款';
|
|
|
} else {
|
|
|
showLastSoldTpl = '累积销售{{soldNum}}件';
|
|
|
}
|
|
|
|
|
|
f.component[0].showLastSoldTpl = showLastSoldTpl;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (componentType === 'tab') {
|
|
|
let {num} = f.component[0] || {};
|
|
|
|
|
|
f.component[0].containerWidth = +num > 5 ? `${Math.round(100 / 5 * num)}%` : '100%';
|
|
|
}
|
|
|
|
|
|
// 新增店铺组
|
...
|
...
|
@@ -581,7 +612,7 @@ class featureModel extends global.yoho.BaseModel { |
|
|
|
|
|
let set = new Set();
|
|
|
|
|
|
_.forEach(f.component, component => {
|
|
|
_.forEach(f.component, (component, cIndex) => {
|
|
|
if (component.url && component.url.indexOf('go.productDetail') !== -1) {
|
|
|
|
|
|
component.url = yasProcess.addParamsToGoodsHref({
|
...
|
...
|
@@ -599,6 +630,14 @@ class featureModel extends global.yoho.BaseModel { |
|
|
componentArr.push(component);
|
|
|
}
|
|
|
|
|
|
if (component.type === 'coupon') { // 优惠券
|
|
|
// 门店体验券
|
|
|
if (+component.storeTrialCoupon > 0) {
|
|
|
component.tokenType = 'storeTrial';
|
|
|
component.token = encodeURIComponent(crypto.encryption('yoho9646__coupon', `${params.code}::${f.id}_${cIndex}::${component.token}`));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
component.type && set.add(component.type);
|
|
|
});
|
|
|
|
...
|
...
|
@@ -628,7 +667,7 @@ class featureModel extends global.yoho.BaseModel { |
|
|
if (likeArr.length) {
|
|
|
yield self._getLikedFloorDataMulti(likeArr);
|
|
|
}
|
|
|
|
|
|
|
|
|
// 限时抢券时间转换
|
|
|
self._formatSeckillCouponTime(data);
|
|
|
|
...
|
...
|
@@ -692,6 +731,72 @@ class featureModel extends global.yoho.BaseModel { |
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 线下门店体验券
|
|
|
* @param uid
|
|
|
* @param token
|
|
|
*/
|
|
|
async couponSendStoreTrial(uid, token) {
|
|
|
let code;
|
|
|
|
|
|
try {
|
|
|
code = crypto.decrypt('yoho9646__coupon', decodeURIComponent(token));
|
|
|
code = _.trim(code).split('::');
|
|
|
} catch (e) {}// eslint-disable-line
|
|
|
|
|
|
if (!code || !code[2]) {
|
|
|
return {
|
|
|
code: 400,
|
|
|
message: '获取优惠券信息失败,请稍后重试'
|
|
|
};
|
|
|
}
|
|
|
|
|
|
let key = `activityStoreTrialCoupon:${code[0]}:${uid}:${code[1]}`;
|
|
|
|
|
|
const getStatus = await cache.getAsync(key);
|
|
|
|
|
|
if (getStatus) {
|
|
|
return {
|
|
|
code: 400,
|
|
|
message: '您已领过该优惠券'
|
|
|
};
|
|
|
}
|
|
|
|
|
|
let apis = [];
|
|
|
|
|
|
code[2].split(',').forEach(id => {
|
|
|
apis.push(this.get({
|
|
|
url: 'coupon/sendCouponForMars.do',
|
|
|
data: {
|
|
|
uid,
|
|
|
couponId: id
|
|
|
},
|
|
|
api: StoreApi
|
|
|
}));
|
|
|
});
|
|
|
|
|
|
let res = await Promise.all(apis);
|
|
|
let pass = false;
|
|
|
let errMsg = '领取失败';
|
|
|
|
|
|
res.forEach(r => {
|
|
|
if (r.code === 200) {
|
|
|
pass = true;
|
|
|
} else {
|
|
|
r.message && (errMsg = r.message);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
cache.setAsync(key, JSON.stringify({
|
|
|
time: Date.parse(new Date())
|
|
|
}), 30 * 12 * 60 * 60);
|
|
|
|
|
|
return {
|
|
|
code: pass ? 200 : 400,
|
|
|
message: pass ? '领取成功' : errMsg
|
|
|
};
|
|
|
}
|
|
|
|
|
|
getProductBySkns(skns) {
|
|
|
let obj = {defaultSkns: skns};
|
|
|
|
...
|
...
|
|