...
|
...
|
@@ -21,47 +21,11 @@ const transPrice = (price, isSepcialZero) => { |
|
|
isSepcialZero = false;
|
|
|
}
|
|
|
|
|
|
if (price || isSepcialZero) {
|
|
|
price = price.toFixed(2);
|
|
|
}
|
|
|
|
|
|
return price;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
*有货币使用前端方案显示及是否可单击判断
|
|
|
*/
|
|
|
const _yohoCoinCompute = (orderCompute) => {
|
|
|
let yohoCoinData = {
|
|
|
totalYohoCoinNum: 0,
|
|
|
yohoCoin: 0,
|
|
|
useYohoCoin: 0,
|
|
|
yohoCoinClick: 0,
|
|
|
yohoCoinMsg: '',
|
|
|
yoho_coin_pay_rule: []
|
|
|
};
|
|
|
|
|
|
if (!orderCompute || !orderCompute.yoho_coin_pay_rule) {
|
|
|
return yohoCoinData;
|
|
|
}
|
|
|
|
|
|
_.assign(yohoCoinData, {
|
|
|
totalYohoCoinNum: orderCompute.total_yoho_coin_num ? parseInt(orderCompute.total_yoho_coin_num, 10) : 0,
|
|
|
yohoCoin: orderCompute.yoho_coin ? transPrice(orderCompute.yoho_coin) : 0,
|
|
|
useYohoCoin: orderCompute.use_yoho_coin ? transPrice(orderCompute.use_yoho_coin) : 0,
|
|
|
yoho_coin_pay_rule: orderCompute.yoho_coin_pay_rule
|
|
|
});
|
|
|
|
|
|
if (yohoCoinData.totalYohoCoinNum < 100) {
|
|
|
yohoCoinData.yohoCoinMsg = `共${yohoCoinData.totalYohoCoinNum}有货币,满${orderCompute.yoho_coin_pay_rule.num_limit}可用`;
|
|
|
} else if (yohoCoinData.useYohoCoin > 0 || yohoCoinData.yohoCoin > 0) {
|
|
|
yohoCoinData.yohoCoinMsg = '可抵¥' + (yohoCoinData.useYohoCoin > 0 ? yohoCoinData.useYohoCoin : yohoCoinData.yohoCoin);
|
|
|
yohoCoinData.yohoCoinClick = 1;
|
|
|
if ((price || isSepcialZero) && _.isNumber(price)) {
|
|
|
return price.toFixed(2);
|
|
|
} else {
|
|
|
yohoCoinData.yohoCoinMsg = '不满足有货币使用条件';
|
|
|
return price;
|
|
|
}
|
|
|
|
|
|
return yohoCoinData;
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -168,7 +132,7 @@ exports.orderCompute = (uid, cartType, deliveryWay, paymentType, couponCode, yoh |
|
|
return shoppingAPI.orderComputeAPI(uid, cartType, deliveryWay, paymentType, couponCode, yohoCoin, skuList, activityInfo).then(result => {
|
|
|
if (result && result.data) {
|
|
|
result.data.use_yoho_coin = transPrice(result.data.use_yoho_coin);
|
|
|
result.data.yohoCoinCompute = _yohoCoinCompute(result.data);
|
|
|
result.data.yohoCoinCompute = paymentProcess.yohoCoinCompute(result.data);
|
|
|
return result.data;
|
|
|
} else {
|
|
|
return {};
|
...
|
...
|
@@ -181,7 +145,7 @@ exports.ticketsOrderCompute = (uid, productSku, buyNumber, yohoCoin) => { |
|
|
return shoppingAPI.checkTickets(uid, productSku, buyNumber, yohoCoin).then(result => {
|
|
|
if (result && result.data) {
|
|
|
result.data.shopping_cart_data.use_yoho_coin = transPrice(result.data.shopping_cart_data.use_yoho_coin);
|
|
|
result.data.yohoCoinCompute = _.yohoCoinCompute(result.data.shopping_cart_data);
|
|
|
result.data.yohoCoinCompute = paymentProcess.yohoCoinCompute(result.data.shopping_cart_data);
|
|
|
|
|
|
return result.data;
|
|
|
} else {
|
...
|
...
|
|