...
|
...
|
@@ -8,29 +8,30 @@ const helpers = global.yoho.helpers; |
|
|
const _ = require('lodash');
|
|
|
const productProcess = require('./product-process');
|
|
|
|
|
|
const regPromoTitle = /^【[^】]+】(.*)/;
|
|
|
// const regPromoTitle = /^【[^】]+】(.*)/;
|
|
|
|
|
|
const transPrice = (price, isSepcialZero) => {
|
|
|
return (price > 0 || isSepcialZero) ? parseFloat(price).toFixed(2) : 0;
|
|
|
};
|
|
|
const formatPromotionTitle = (promo) => {
|
|
|
let title;
|
|
|
|
|
|
if (promo.status === 0) {
|
|
|
if (promo.condition_unit === 1) {
|
|
|
title = `再购${Math.abs(promo.condition_value)}件`;
|
|
|
} else if (promo.condition_unit === 2) {
|
|
|
title = `再购¥${transPrice(Math.abs(promo.condition_value))}`;
|
|
|
}
|
|
|
} else {
|
|
|
title = '已满足';
|
|
|
}
|
|
|
let match = regPromoTitle.exec(promo.promotion_title);
|
|
|
let promotionTitle = match !== null && match.length > 1 ? match[1] : promo.promotion_title;
|
|
|
|
|
|
promotionTitle = promotionTitle.replace(/¥/g, '¥');
|
|
|
return `${title}【${promotionTitle}】`;
|
|
|
};
|
|
|
// const formatPromotionTitle = (promo) => {
|
|
|
// let title;
|
|
|
|
|
|
// if (promo.status === 0) {
|
|
|
// if (promo.condition_unit === 1) {
|
|
|
// title = `再购${Math.abs(promo.condition_value)}件`;
|
|
|
// } else if (promo.condition_unit === 2) {
|
|
|
// title = `再购¥${transPrice(Math.abs(promo.condition_value))}`;
|
|
|
// }
|
|
|
// } else {
|
|
|
// title = '已满足';
|
|
|
// }
|
|
|
// let match = regPromoTitle.exec(promo.promotion_title);
|
|
|
// let promotionTitle = match !== null && match.length > 1 ? match[1] : promo.promotion_title;
|
|
|
|
|
|
// promotionTitle = promotionTitle.replace(/¥/g, '¥');
|
|
|
// return `${title}【${promotionTitle}】`;
|
|
|
// };
|
|
|
const formatPromotionOpt = (promo) => {
|
|
|
if (promo.status === 0) {
|
|
|
return '去凑单';
|
...
|
...
|
@@ -221,7 +222,7 @@ const formatPromotion = (promo) => { |
|
|
giftPrice: promo.gift_price,
|
|
|
promotionId: _.get(promo, 'ts_promotion_ids', 0),
|
|
|
promotionOriginTitle: promo.promotion_title,
|
|
|
promotionTitle: formatPromotionTitle(promo),
|
|
|
promotionTitle: _.get(promo, 'promotion_desc', ''),
|
|
|
promotionType: promo.promotion_type,
|
|
|
alreadyMatch: promo.alreadyMatch,
|
|
|
optTitle: formatPromotionOpt(promo),
|
...
|
...
|
|