...
|
...
|
@@ -372,21 +372,62 @@ function coupon(count, orderInfo, orderComputeData) { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处理礼品卡数据
|
|
|
* 选择礼品卡页面礼品卡数据处理
|
|
|
*/
|
|
|
function handleGiftCardsRender(giftCards, selectCards) {
|
|
|
let result = {
|
|
|
sureActice: false,
|
|
|
giftCards: giftCards
|
|
|
};
|
|
|
|
|
|
let selectCardsArray = selectCards && selectCards.split(',');
|
|
|
|
|
|
_.forEach(result.giftCards, perCard => {
|
|
|
let checked = _.find(selectCardsArray, per => {
|
|
|
return per === _.get(perCard, 'cardCode');
|
|
|
});
|
|
|
|
|
|
if (checked) {
|
|
|
result.sureActice = true;
|
|
|
}
|
|
|
|
|
|
_.assign(perCard, {
|
|
|
checked: checked
|
|
|
});
|
|
|
});
|
|
|
|
|
|
result.giftCards = giftCards;
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 结算页处理礼品卡数据
|
|
|
*/
|
|
|
function handleGiftCards(params) {
|
|
|
let info = '未使用'; // TODO
|
|
|
let count = params.validGiftCardCount; // 几张可用
|
|
|
let amount = _.get(params, 'orderCompute.gift_card.amount', 0); // 可抵用金额
|
|
|
let selectCount = _.get(params, 'orderCompute.gift_card.count', 0); // 用户选择了几张
|
|
|
let leftInfo = '';
|
|
|
let rightInfo = '未使用';
|
|
|
|
|
|
if (!count) {
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
let amount = _.get(params, 'orderCompute.gift_card.amount', 0);
|
|
|
if (selectCount) {
|
|
|
leftInfo = `已选${selectCount}张`;
|
|
|
} else if (count) {
|
|
|
leftInfo = `${count}张可用`;
|
|
|
}
|
|
|
|
|
|
if (amount) {
|
|
|
info = `可以抵用¥${amount.toFixed(2)}`;
|
|
|
if (selectCount && amount) {
|
|
|
rightInfo = `可以抵用¥${amount.toFixed(2)}`;
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
count: params.validGiftCardCount,
|
|
|
amount: amount,
|
|
|
selectCount: _.get(params, 'orderCompute.gift_card.count', 0),
|
|
|
info: info
|
|
|
leftInfo: leftInfo,
|
|
|
rightInfo: rightInfo
|
|
|
};
|
|
|
}
|
|
|
|
...
|
...
|
@@ -499,6 +540,7 @@ module.exports = { |
|
|
yohoCoinCompute,
|
|
|
coupon,
|
|
|
handleGiftCards,
|
|
|
handleGiftCardsRender,
|
|
|
transformJit,
|
|
|
unionInfoHandle
|
|
|
}; |
...
|
...
|
|