Эх сурвалжийг харах

Merge pull request #115 from John-Hong/release-2.8.0

fix(SCRM-3796): [DE][C端]临时停车,当天设置60元,用户缴费使用优惠40.再重新缴费,应该只可以使用20元优惠
Tron 2 жил өмнө
parent
commit
9dfd304c2b

+ 29 - 6
src/pages/parkingFee/mixins/parkingFeeCoupon.js

@@ -18,6 +18,7 @@ export default {
       platform: getPlatform(),
       maxCouponFee: 0, // 计算优惠券已选的总金额
       remainPrice: 0, // 剩余可用优惠额度
+      newAvailableDiscountFee: 0, // 可使用的电子券的优惠金额上限
       extraData: {}
     };
   },
@@ -69,7 +70,9 @@ export default {
        * */
       this.couponList = [...this.coupons];
       this.remainPrice = this.usingTotalDiscount;
+      this.newAvailableDiscountFee = this.availableDiscountFee
       if (this.couponList.length) {
+        if ( this.setAllDisabled() ) return
         this.couponList = this.couponList.map((elm, index) => {
           elm.disabled = true;
           const selected = elm.hasOwnProperty('selected') ? elm.selected : elm.defaultSelected;
@@ -104,12 +107,12 @@ export default {
         }, 100)
         return;
       }
-      
       // 取消勾选时
       if (this.checkedCouponList.indexOf(name) > -1) {
         this.checkedCouponList = this.checkedCouponList.filter((i) => i !== name);
         setTimeout(() => {
           this.remainPrice = this.remainPrice - this.couponList[index].discountFee
+          this.newAvailableDiscountFee = this.newAvailableDiscountFee + this.couponList[index].discountFee
           this.newGroupedCouponData()
         }, 100)
         return;
@@ -117,10 +120,30 @@ export default {
       // 如果有选中项
       const item = this.couponList[index];
       this.remainPrice = this.remainPrice + this.couponList[index].discountFee
+      this.newAvailableDiscountFee = this.newAvailableDiscountFee - this.couponList[index].discountFee
       if (!item.disabled) {
         this.checkedCouponList.push(`coupon${index}`);
       }
-      this.newGroupedCouponData()
+      this.$nextTick(() => {
+        if ( this.setAllDisabled() ) return
+        this.newGroupedCouponData()  
+      })
+      
+    },
+    // 针对达到优惠的上限制
+    setAllDisabled() {
+      const { parkMallCode } = this.orderDetail.parkInfo;
+      // 设置深圳的达到优惠金额的上限,置灰剩下未选择的金额
+      if ( parkMallCode === 5 && this.remainPrice - this.paperDiscountFee >= this.newAvailableDiscountFee ) {
+        this.couponList = this.couponList.map((elm,iemi) => {
+          if ( !elm.disabled && this.checkedCouponList.indexOf(`coupon${iemi}`) < 0) {
+            elm.disabled = true
+          }
+          return elm
+        })
+        return true
+      }
+      return false
     },
     // 对不同类型的优惠券进行汇总统计
     /*groupedCouponData() {
@@ -300,7 +323,7 @@ export default {
       // 剩余可使用的优惠金额,支持动态计算; 优惠时长,不可能全部使用,不能超过车费减去优惠的金额;不能超过单次的应付金额
       let remainPrice = remainConsumeTime * hourPrice;
       if (parkMallCode === 5) {
-        if (remainPrice > actualPayFee) {
+        if (remainPrice - this.paperDiscountFee > actualPayFee) {
           remainPrice = actualPayFee;
         }  
       }
@@ -339,14 +362,14 @@ export default {
        // });
        }*/
       // 深圳超限处理
-      if (parkMallCode === 5 && this.remainPrice  >= this.actualPayFee) {
+      if (parkMallCode === 5 && this.remainPrice  >= this.availableDiscountFee) {
         return Toast({
-          message: `每日最高可抵扣${this.actualPayFee}元`,
+          message: `每日最高可抵扣${this.maxOneDayDiscountFee}元`,
           icon: 'none',
         });
       }
       // 浦东,单次上限提示, 后续 usingTotalDiscount 再减去 纸质优惠券的金额
-      if (parkMallCode === 1 && usingTotalDiscount- this.paperDiscountFee >= maxOneTimeDiscountTime) {
+      if (parkMallCode === 1 && this.remainPrice - this.paperDiscountFee >= this.availableDiscountFee) {
         return Toast({
           message: `超出抵扣上限,每次最高可抵扣${maxOneTimeDiscountTime}小时`,
           icon: 'none',

+ 3 - 4
src/store/order/points.js

@@ -120,12 +120,11 @@ export default {
     if ( maxPointsTime > state.availableDiscountFee ) {
       maxPointsTime = state.availableDiscountFee
     }
-    console.log(392,state.pointsTime,maxPointsTime,parkMallCode);
     if ( parkMallCode === 5 && state.unlimitUsePoints === 'LIMIT' ) {
-      if ( type === 'add' && state.pointsTime >= maxPointsTime ) {
+      if ( type === 'add' && (state.pointsTime >= maxPointsTime || state.usingTotalDiscount >= state.availableDiscountFee) ) {
         // 以下是深圳积分上限规则
         // 超出抵扣上限,每日最高可抵扣${this.parkFee.parkInfoEntity.maxOneDayHour}元 '优惠金额' >= '每日最高可抵扣'
-        if ( state.usingTotalDiscount - state.paperDiscountFee >= state.maxOneDayDiscountFee && !msg ) {
+        if ( state.usingTotalDiscount - state.paperDiscountFee >= state.availableDiscountFee && !msg ) {
           msg = `超出抵扣上限,每日最高可抵扣${ state.maxOneDayDiscountFee }元`
         }
         // 超出抵扣上限,每次最高可抵扣${this.integralMaxMoney}元 '积分兑换时长' >= '深圳前海停车积分上限'q
@@ -165,7 +164,7 @@ export default {
       return
     }
     // 计算浦东的上限
-    if ( type === 'add' && state.usingTotalDiscount >= state.maxOneDayDiscountFee && parkMallCode === 5 && state.unlimitUsePoints === 'LIMIT') {
+    if ( type === 'add' && state.usingTotalDiscount >= state.availableDiscountFee && parkMallCode === 5 && state.unlimitUsePoints === 'LIMIT') {
       return;
     }
     if ( type === 'add' ) {