Jelajahi Sumber

Merge pull request #613 from John-Hong/release-3.19.0

fix(SCRM-7511): 积分兑换规则调整
John-Hong 9 bulan lalu
induk
melakukan
c4378ce59c
2 mengubah file dengan 20 tambahan dan 6 penghapusan
  1. 9 4
      src/pages/mixins/parkingFeeDetail.js
  2. 11 2
      src/store/order/points.js

+ 9 - 4
src/pages/mixins/parkingFeeDetail.js

@@ -335,12 +335,17 @@ export default {
         // 积分
         if (points?.length && points[0].discountFee > 0) {
           // 15 兑换 5元
-          const { pointsPerUnit, unitAmount, discountFee, available } = points[0]
-          
+          const { pointsPerUnit, unitAmount, discountFee } = points[0]
+          let pointsDiscountTime = discountFee / hourPrice * 60
+          let pointsDiscountPoints = discountFee / hourPrice * pointsPerUnit
+          if(isAmount) {
+            pointsDiscountTime = Math.floor( discountFee / unitAmount ) + 1
+            pointsDiscountPoints = pointsDiscountTime * pointsPerUnit
+          }
           params.discountInfo.points = {
-            "discountTime":   discountFee / (isAmount ? unitAmount : hourPrice) * 60,
+            "discountTime": pointsDiscountTime,
             "discountFee": discountFee,
-            "discountPoints": discountFee / (isAmount ? unitAmount : hourPrice) * pointsPerUnit
+            "discountPoints": pointsDiscountPoints
           }
           usingTotalDiscount = usingTotalDiscount + discountFee
         }

+ 11 - 2
src/store/order/points.js

@@ -225,6 +225,12 @@ export default {
       pointsTime = state.pointsTime + (isAmount ? state.unitAmount : state.unitHour);
       const available = state.available - state.pointsPerUnit;
       const usingTotalDiscount = state.usingTotalDiscount + (isAmount ? state.unitAmount : state.unitHour * hourPrice ); // 重新计算已经使用的优惠逻辑
+      if(isAmount && Math.min(points.remainDiscountFeePerDay, points.maxDiscountFee) - state.pointsTime < state.unitAmount) {
+        commit('setAvailable', available);
+        commit('setPointsTime', Math.min(points.remainDiscountFeePerDay, points.maxDiscountFee));
+        commit('setUsingTotalDiscount',state.usingTotalDiscount + (Math.min(points.remainDiscountFeePerDay, points.maxDiscountFee) - state.pointsTime));
+        return
+      }
       if ( available > -1 ) {
         // 如果是深圳车场
         commit('setAvailable',available);
@@ -234,10 +240,13 @@ export default {
     }
     if ( type === 'minus' && state.pointsTime > 0 ) {
       const pointsTime = state.pointsTime - (isAmount ? state.unitAmount : state.unitHour);
-      if(pointsTime < 0) {
+      const usingTotalDiscount = state.usingTotalDiscount - (isAmount ? state.unitAmount : state.unitHour * hourPrice); // 重新计算已经使用的优惠逻辑
+      if(isAmount && pointsTime < 0) {
+        commit('setAvailable', state.available + state.pointsPerUnit);
+        commit('setPointsTime',0);
+        commit('setUsingTotalDiscount',state.usingTotalDiscount - state.pointsTime);
         return
       }
-      const usingTotalDiscount = state.usingTotalDiscount - (isAmount ? state.unitAmount : state.unitHour * hourPrice); // 重新计算已经使用的优惠逻辑
       // 如果是深圳车场
       commit('setAvailable',state.available + state.pointsPerUnit);
       commit('setPointsTime',pointsTime);