|
@@ -286,7 +286,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
maxReduceDiscountInit() {
|
|
|
- const {maxDiscountTime} = this.consume
|
|
|
+ const {maxDiscountTime, couponCodes} = this.consume
|
|
|
if(JSON.stringify(this.consume) === '{}' || !this.consume.hasOwnProperty('redeemSalesAmount')) {
|
|
|
return
|
|
|
}
|
|
@@ -295,24 +295,48 @@ export default {
|
|
|
const remainingLimitToIncrease = Math.abs(this.remainPrice - this.availableDiscountFee || 0) / hourPrice;
|
|
|
// 如果是浦东的话, 重新计算优惠
|
|
|
if (this.parkMallCode === 1) {
|
|
|
- // 如果超过限制就置灰
|
|
|
- const maxOneTimeDiscountTimeFee = maxOneTimeDiscountTime * hourPrice
|
|
|
+ /*
|
|
|
+ * 消费减免真实可用优惠的计算逻辑
|
|
|
+ * 消费减免可能选择的情况: X
|
|
|
+ * 其余已使用的优惠:W
|
|
|
+ * 当前可使用优惠的上限:B
|
|
|
+ * 当前消费减免最高可用优惠:D = B - ( W - X )
|
|
|
+ * 当前消费减免用户可用优惠上限:Z
|
|
|
+ * 消费减免真实可用优惠: D > Z ? Z : D
|
|
|
+ * */
|
|
|
const isSelected = this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected;
|
|
|
- const isCheckedListSelected = this.checkedList.indexOf('consume') > -1;
|
|
|
- if(maxOneTimeDiscountTimeFee > this.remainPrice) {
|
|
|
- // 优惠计算公式: 剩余可用优惠 + 已经选择的优惠 = 总的消费减免的优惠(小时)
|
|
|
- const maxReduceDiscount = (maxOneTimeDiscountTimeFee - this.remainPrice) / hourPrice + (isSelected ? this.reduceHours : 0)
|
|
|
- this.maxReduceDiscount = maxReduceDiscount > maxOneTimeDiscountTime ? maxOneTimeDiscountTime: maxReduceDiscount
|
|
|
- !isSelected && (this.reduceHours = this.maxReduceDiscount)
|
|
|
- return
|
|
|
- }
|
|
|
- if(maxOneTimeDiscountTimeFee == this.remainPrice && !isSelected && isCheckedListSelected) {
|
|
|
- this.maxReduceDiscount = 0
|
|
|
- this.reduceHours = this.maxReduceDiscount
|
|
|
- return
|
|
|
- } else {
|
|
|
- this.maxReduceDiscount = this.reduceHours
|
|
|
- }
|
|
|
+ const reduceHours = isSelected ? this.reduceHours : 0
|
|
|
+ const otherFee = remainConsumeTime - this.remainPrice - reduceHours
|
|
|
+ // 当前订单的总可用余额: remainConsumeTime
|
|
|
+ const couponCodesLength = couponCodes?.split('#')?.length || 0; // 上限
|
|
|
+ // 实际上限
|
|
|
+ // remainConsumeTime - this.reduceHours 剩余优惠
|
|
|
+ // couponCodesLength - this.reduceHours 剩余上限
|
|
|
+ // 实际上限 = 剩余优惠 <= 剩余上限
|
|
|
+ // this.maxReduceDiscount = remainConsumeTime - this.reduceHours <= couponCodesLength - this.reduceHours
|
|
|
+ // 转化公式之后
|
|
|
+ // this.maxReduceDiscount = remainConsumeTime > couponCodesLength ? couponCodesLength : remainConsumeTime
|
|
|
+ this.maxReduceDiscount = otherFee > couponCodesLength ? couponCodesLength : otherFee
|
|
|
+ this.reduceHours = this.maxReduceDiscount
|
|
|
+ return
|
|
|
+ // 如果超过限制就置灰
|
|
|
+ // const maxOneTimeDiscountTimeFee = (couponCodes.split('#').length) * hourPrice
|
|
|
+ // const isSelected = this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected;
|
|
|
+ // const isCheckedListSelected = this.checkedList.indexOf('consume') > -1;
|
|
|
+ // if(maxOneTimeDiscountTimeFee > this.remainPrice) {
|
|
|
+ // // 优惠计算公式: 剩余可用优惠 + 已经选择的优惠 = 总的消费减免的优惠(小时)
|
|
|
+ // const maxReduceDiscount = (maxOneTimeDiscountTimeFee - this.remainPrice) / hourPrice + (isSelected ? this.reduceHours : 0)
|
|
|
+ // this.maxReduceDiscount = maxReduceDiscount > maxOneTimeDiscountTime ? maxOneTimeDiscountTime: maxReduceDiscount
|
|
|
+ // !isSelected && (this.reduceHours = this.maxReduceDiscount)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // if(maxOneTimeDiscountTimeFee == this.remainPrice && !isSelected && isCheckedListSelected) {
|
|
|
+ // this.maxReduceDiscount = 0
|
|
|
+ // this.reduceHours = this.maxReduceDiscount
|
|
|
+ // return
|
|
|
+ // } else {
|
|
|
+ // this.maxReduceDiscount = this.reduceHours
|
|
|
+ // }
|
|
|
return
|
|
|
}
|
|
|
if (!remainingLimitToIncrease) {
|
|
@@ -422,6 +446,10 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
reducesClick() {
|
|
|
+ // 浦东
|
|
|
+ if(this.parkMallCode === 1 && (this.isReduces || !this.maxReduceDiscount) ) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
const { maxOneTimeDiscountTime, hourPrice, oneTimeLimitation, maxConsumeTime, remainConsumeTime, oneDayLimitation, maxOneDayDiscountFee, availableDiscountFee } = this.orderDetail.parkingRule;
|
|
|
const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice;
|
|
|
if (this.checkedList.indexOf('reduces') > -1) {
|