Browse Source

fix(KIP-10731): 【DE】【C端】【沈阳】。用户可以使用抵扣时长超过7小时

john 2 năm trước cách đây
mục cha
commit
d7e070c702
1 tập tin đã thay đổi với 17 bổ sung10 xóa
  1. 17 10
      src/pages/parkingFee/mixins/parkingFeeDiscounts.js

+ 17 - 10
src/pages/parkingFee/mixins/parkingFeeDiscounts.js

@@ -126,7 +126,7 @@ export default {
         return ''
       }
       // 消费减免余额为 0 时
-      if (!this.orderDetail.parkingRule.remainConsumeTime) {
+      if (!this.orderDetail.parkingRule.remainConsumeTime || !this.consume.hasOwnProperty('redeemSalesAmount')) {
         return `您暂无可用的消费减免`
         // return `您今日消费减免已达${this.orderDetail.parkingRule.maxConsumeTime}小时上限`
       }
@@ -255,10 +255,11 @@ export default {
       if (JSON.stringify(this.consume) !== '{}') {
         const isSelected = this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected;
         this.maxReduceDiscount = this.consume.hasOwnProperty('discountFee') ? this.consume.discountFee / hourPrice : this.consume.defaultDiscountTime;
-        const remainingLimitToIncrease = Math.abs(this.remainPrice - this.availableDiscountFee) / hourPrice
-        if (remainingLimitToIncrease && isSelected) {
-          this.maxReduceDiscountInit();
-        }
+        // const remainingLimitToIncrease = Math.abs(this.remainPrice - this.availableDiscountFee) / hourPrice
+        // if (remainingLimitToIncrease) {
+        //   this.maxReduceDiscountInit();
+        // }
+        this.maxReduceDiscountInit();
       }
       this.oldCheckedList = [...this.checkedList];
       // 如果是杭州、沈阳可以选择
@@ -272,19 +273,23 @@ export default {
       }, 300)
     },
     maxReduceDiscountInit() {
+      if(JSON.stringify(this.consume) === '{}' || !this.consume.hasOwnProperty('redeemSalesAmount')) {
+        return
+      }
       const { maxConsumeTime, remainConsumeTime, hourPrice } = this.orderDetail.parkingRule;
       const remainingLimitToIncrease = Math.abs(this.remainPrice - this.availableDiscountFee) / hourPrice
       if (!remainingLimitToIncrease) return
-      if (this.remainPrice > this.availableDiscountFee) {
+      if (this.remainPrice >= this.availableDiscountFee) {
         // console.log('过大', this.maxReduceDiscount, remainingLimitToIncrease);
         this.maxReduceDiscount = this.maxReduceDiscount - remainingLimitToIncrease
         this.consume.discountFee = this.consume.discountFee - (remainingLimitToIncrease * hourPrice)
         this.remainPrice = this.remainPrice - (remainingLimitToIncrease * hourPrice);
         this.reduceHours = this.maxReduceDiscount
       } else {
-        // console.log('过小');
+        // console.log('过小?', this.consume.discountFee, remainingLimitToIncrease);
         const maxReduceDiscount = this.consume.discountFee / hourPrice + remainingLimitToIncrease
-        this.maxReduceDiscount = maxReduceDiscount < remainConsumeTime ? maxReduceDiscount : remainConsumeTime
+        // console.log('过小', maxReduceDiscount);
+        this.maxReduceDiscount = maxReduceDiscount <= remainConsumeTime ? maxReduceDiscount : remainConsumeTime
       }
     },
     setIsMemberDiscountDisabled() {
@@ -351,15 +356,17 @@ export default {
       const { maxOneTimeDiscountTime, hourPrice, oneTimeLimitation, maxConsumeTime, remainConsumeTime, oneDayLimitation, maxOneDayDiscountFee, availableDiscountFee } = this.orderDetail.parkingRule;
       const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice;
       if (this.checkedList.indexOf('reduces') > -1) {
-        this.remainPrice = hourPrice + this.remainPrice;
+        // this.remainPrice = hourPrice + this.remainPrice;
         // 如果不是沈阳,重新计算计算最大上限
         if (this.parkMallCode !== 4) {
+          this.remainPrice = hourPrice + this.remainPrice;
           this.maxReduceDiscount = remainConsumeTime > maxOneTimeDiscountFee / hourPrice ? maxOneTimeDiscountFee / hourPrice : remainConsumeTime;
         }
       } else {
-        this.remainPrice = this.remainPrice - hourPrice;
+        // this.remainPrice = this.remainPrice - hourPrice;
         // 如果不是沈阳,重新计算计算最大上限
         if (this.parkMallCode !== 4) {
+          this.remainPrice = this.remainPrice - hourPrice;
           this.maxReduceDiscount = remainConsumeTime > maxOneTimeDiscountFee / hourPrice ? maxOneTimeDiscountFee / hourPrice : remainConsumeTime;
         }
       }