|
|
'use strict';
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
let _getProduct = function(o) {
|
|
|
return {
|
|
|
let plan = o.product_price_plan_list;
|
|
|
let res = {
|
|
|
small_sort_id: o.small_sort_id,
|
|
|
middle_sort_id: o.middle_sort_id,
|
|
|
max_sort_id: o.max_sort_id,
|
...
|
...
|
@@ -21,6 +23,29 @@ let _getProduct = function(o) { |
|
|
default_images: o.default_images,
|
|
|
goods_id: Array.isArray(o.goods_list) && o.goods_list.length ? o.goods_list[0].goods_id : void 0
|
|
|
};
|
|
|
|
|
|
plan = _.sortBy(plan, item => {
|
|
|
return +item.show_begin_time;
|
|
|
});
|
|
|
|
|
|
if (plan.length) {
|
|
|
let time = Math.round(new Date() / 1000);
|
|
|
let effectPlan = [];
|
|
|
|
|
|
plan.forEach(planItem => {
|
|
|
if (planItem.effect_time > time) {
|
|
|
effectPlan.push(planItem);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (effectPlan.length && time > effectPlan[0].show_begin_time && effectPlan[0].show_status === '1') { // eslint-disable-line
|
|
|
o.curPlanPrice = effectPlan[0].current_saleprice;
|
|
|
|
|
|
_.assign({curPlanPrice: effectPlan[0].current_saleprice}, res);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
const gender = {
|
...
|
...
|
|