|
@@ -45,7 +45,7 @@ export default {
|
|
|
if ( parkMallCode === 5 ) {
|
|
|
pointsTime = discountFee || 0
|
|
|
} else {
|
|
|
- pointsTime = discountFee ? discountFee/ unitAmount: 0
|
|
|
+ pointsTime = discountFee ? discountFee / unitAmount: 0
|
|
|
}
|
|
|
commit('setPointsTime',pointsTime);
|
|
|
commit('setPointsPerUnit',pointsPerUnit);
|
|
@@ -140,10 +140,9 @@ export default {
|
|
|
const remainConsumeTimeFee = remainConsumeTime * hourPrice
|
|
|
// 计算单日剩余 remainConsumeTime
|
|
|
// 当前使用优惠 state.usingTotalDiscount
|
|
|
- // 判断符合上限
|
|
|
-
|
|
|
+ // 判断符合上限
|
|
|
// 浦东积分上限判断
|
|
|
- if ( parkMallCode === 1 && type === 'add' && state.usingTotalDiscount <= maxOneTimeDiscountFee ) {
|
|
|
+ if ( parkMallCode === 1 && type === 'add' && state.usingTotalDiscount >= maxOneTimeDiscountFee ) {
|
|
|
msg = `超出抵扣上限,每次最高可抵扣${ maxOneTimeDiscountTime }小时`
|
|
|
}
|
|
|
}
|
|
@@ -155,7 +154,7 @@ export default {
|
|
|
// 当前使用优惠 state.usingTotalDiscount
|
|
|
// 判断符合上限
|
|
|
// 浦东积分上限判断: 减去纸质优惠券的金额
|
|
|
- if ( parkMallCode === 1 && type === 'add' && state.usingTotalDiscount - state.paperDiscountFee <= maxOneTimeDiscountFee ) {
|
|
|
+ if ( parkMallCode === 1 && type === 'add' && state.usingTotalDiscount - state.paperDiscountFee >= maxOneTimeDiscountFee * hourPrice ) {
|
|
|
msg = `超出抵扣上限,每次最高可抵扣${ maxOneTimeDiscountTime }小时`
|
|
|
}
|
|
|
}
|
|
@@ -173,7 +172,7 @@ export default {
|
|
|
let pointsTime = 0;
|
|
|
pointsTime = state.pointsTime + (parkMallCode === 5 ? state.unitAmount : state.unitHour);
|
|
|
const available = state.available - state.pointsPerUnit;
|
|
|
- const usingTotalDiscount = state.usingTotalDiscount + state.unitAmount; // 重新计算已经使用的优惠逻辑
|
|
|
+ const usingTotalDiscount = state.usingTotalDiscount + (state?.unitHour ? state.unitHour * hourPrice : state.unitAmount); // 重新计算已经使用的优惠逻辑
|
|
|
if ( available > -1 ) {
|
|
|
// 如果是深圳车场
|
|
|
commit('setAvailable',available);
|
|
@@ -183,7 +182,7 @@ export default {
|
|
|
}
|
|
|
if ( type === 'minus' && state.pointsTime > 0 ) {
|
|
|
const pointsTime = state.pointsTime - (parkMallCode === 5 ? state.unitAmount : state.unitHour);
|
|
|
- const usingTotalDiscount = state.usingTotalDiscount - state.unitAmount; // 重新计算已经使用的优惠逻辑
|
|
|
+ const usingTotalDiscount = state.usingTotalDiscount - (state?.unitHour ? state.unitHour * hourPrice : state.unitAmount); // 重新计算已经使用的优惠逻辑
|
|
|
// 如果是深圳车场
|
|
|
commit('setAvailable',state.available + state.pointsPerUnit);
|
|
|
commit('setPointsTime',pointsTime);
|
|
@@ -193,14 +192,23 @@ export default {
|
|
|
cancelPointsMath( {commit,dispatch,state},callback ) {
|
|
|
const {
|
|
|
discountInfo: {points},
|
|
|
+ parkInfo: {parkMallCode},
|
|
|
parkingRule,
|
|
|
} = state.orderDetail;
|
|
|
+ const [{pointsPerHour,available,discountFee}] = points;
|
|
|
+ const {maxPointsTime,enablePoints,unitAmount} = parkingRule;
|
|
|
if ( !points ) {
|
|
|
callback && callback();
|
|
|
return
|
|
|
}
|
|
|
- const [{pointsPerHour,available,discountFee}] = points;
|
|
|
- const {maxPointsTime,enablePoints} = parkingRule;
|
|
|
+ let pointsTime = 0
|
|
|
+ // 深圳
|
|
|
+ if ( parkMallCode === 5 ) {
|
|
|
+ pointsTime = discountFee || 0
|
|
|
+ } else {
|
|
|
+ pointsTime = discountFee ? discountFee / unitAmount: 0
|
|
|
+ }
|
|
|
+
|
|
|
commit('setAvailable',available);
|
|
|
commit('setPointsTime',discountFee || 0);
|
|
|
callback && callback();
|
|
@@ -208,6 +216,10 @@ export default {
|
|
|
async savePointsMath( {commit,dispatch,state},callback ) {
|
|
|
try {
|
|
|
let orderDetail = {...state.orderDetail};
|
|
|
+
|
|
|
+ const {parkInfo,parkingRule} = state.orderDetail
|
|
|
+ const {maxOneTimeDiscountTime,oneTimeLimitation,oneDayLimitation,hourPrice,remainConsumeTime} = parkingRule
|
|
|
+ const {parkMallCode} = parkInfo
|
|
|
// 如果是重复提交,则不做重新计算
|
|
|
if ( orderDetail.discountInfo.points[0].available === state.available ) {
|
|
|
callback && callback();
|
|
@@ -217,7 +229,7 @@ export default {
|
|
|
setSelected(['memberGrade','consume','paperCoupons','coupons'],orderDetail)
|
|
|
// 计算积分修改之后的金额,返回给后端
|
|
|
// orderDetail.discountInfo.points[0].discountFee = state.pointsTime * orderDetail.discountInfo.points[0].unitAmount;
|
|
|
- orderDetail.discountInfo.points[0].discountFee = state.pointsTime;
|
|
|
+ orderDetail.discountInfo.points[0].discountFee = parkMallCode === 5 ? state.pointsTime : state.pointsTime * orderDetail.discountInfo.points[0].unitAmount;
|
|
|
orderDetail.discountInfo.points[0].available = state.available;
|
|
|
orderDetail.discountInfo.points[0].selected = true;
|
|
|
/* 其他优惠统计 */
|