Pārlūkot izejas kodu

Merge pull request #173 from John-Hong/John/release-2.11.0/KIP-10731

fix(KIP-10731): 【DE】【C端】【沈阳】。用户可以使用抵扣时长超过7小时
Tron 2 gadi atpakaļ
vecāks
revīzija
493267e6a4

+ 97 - 0
src/api/mockData/checkout.sy5.response.json

@@ -0,0 +1,97 @@
+{
+  "parkingRecord": {
+    "vehicleNo": "鲁A10001", 
+    "enterTime": "2023-06-13 10:50:08", 
+    "serviceMin": 8929, 
+    "totalFee": 34000, 
+    "actualPayFee": 270, 
+    "thirdPartyId": "_1_29bcc3e1_1687160372539", 
+    "thirdParkOrderNo": "29bcc3e1b5b64aec9ad0213e7dd0fd65", 
+    "createdByQrCode": false, 
+    "totalFeeInYuan": 340
+  }, 
+  "discountInfo": {
+    "usingTotalDiscount": 70, 
+    "memberLevelDiscount": true, 
+    "memberGrade": [
+      {
+        "defaultSelected": true, 
+        "memberGrade": "3", 
+        "memberGradeText": "铂金卡", 
+        "discountTime": 4, 
+        "discountFee": 40
+      }
+    ], 
+    "consume": [
+      {
+        "defaultSelected": true, 
+        "maxDiscountTime": 6, 
+        "defaultDiscountTime": 2, 
+        "discountFee": 20, 
+        "redeemSalesAmount": 800
+      }
+    ], 
+    "coupons": [
+      {
+        "code": "v3yvvas1v1o_t", 
+        "couponId": "69ba37c806b640d1a27ae73e2bf6a7ad", 
+        "status": "available", 
+        "name": "停车券(不可叠加券)", 
+        "expirationDate": "2023-06-24 23:59:59", 
+        "discountFee": 10, 
+        "defaultSelected": true, 
+        "superposition": "1", 
+        "limitCountPerOrder": 7
+      }, 
+      {
+        "code": "7xmwnx7ax4b_t", 
+        "couponId": "69ba37c806b640d1a27ae73e2bf6a7ad", 
+        "status": "available", 
+        "name": "停车券(不可叠加券)", 
+        "expirationDate": "2023-06-24 23:59:59", 
+        "discountFee": 10, 
+        "defaultSelected": false, 
+        "superposition": "1", 
+        "limitCountPerOrder": 7
+      }, 
+      {
+        "code": "51742ekp00r_t", 
+        "couponId": "69ba37c806b640d1a27ae73e2bf6a7ad", 
+        "status": "available", 
+        "name": "停车券(不可叠加券)", 
+        "expirationDate": "2023-06-24 23:59:59", 
+        "discountFee": 10, 
+        "defaultSelected": false, 
+        "superposition": "1", 
+        "limitCountPerOrder": 7
+      }
+    ], 
+    "paperCoupons": [
+      {
+        "description": "请扫描纸质停车优惠券二维码,获取停车优惠"
+      }
+    ]
+  }, 
+  "parkingRule": {
+    "enableNewMemberPoints": false, 
+    "enablePoints": false, 
+    "unLimitWeekendPoints": false, 
+    "enableCoupon": true, 
+    "maxOneDayCoupons": 5, 
+    "remainCoupons": 5, 
+    "enablePaperCoupons": true, 
+    "enableConsume": true, 
+    "enableConsumeNonSplit": true, 
+    "maxConsumeTime": 6, 
+    "remainConsumeTime": 6, 
+    "hourPrice": 10, 
+    "oneTimeLimitation": false, 
+    "oneDayLimitation": false
+  }, 
+  "parkInfo": {
+    "parkName": "杭州嘉里中心", 
+    "description": "基础计费规则:10元/小时\n会员权益减免:铂金卡4小时,金卡2小时,臻选银卡1小时,每日限享优惠权益1次,不可拆分使用,可与消费抵免叠加使用。\n会员消费减免:消费200元可减免2小时,消费400元可减免4小时,消费800元及以上可减免6小时,当日有效,单次获得的减免不可拆分使用,当日最多可享受消费减免6小时。", 
+    "parkMallCode": 2, 
+    "buildingId": "HKC-P1"
+  }
+}

+ 10 - 8
src/pages/parkingFee/mixins/parkingFeeCoupon.js

@@ -42,7 +42,7 @@ export default {
   },
 
   mounted() {
-    console.log('parkingFeeCoupon.js');
+    // console.log('parkingFeeCoupon.js');
     setTimeout(() => {
       uni.setNavigationBarTitle({
         title: '优惠券',
@@ -84,6 +84,7 @@ export default {
         this.remainPrice = this.remainPrice - this.orderDetail?.discountInfo?.points[0]?.discountFee
       }
       this.newAvailableDiscountFee = this.availableDiscountFee
+      // console.log(878787, this.newAvailableDiscountFee);
       if (this.couponList.length) {
         this.couponList = this.couponList.map((elm, index) => {
           elm.disabled = true;
@@ -169,10 +170,11 @@ export default {
       if ( oneDayLimitation  && parkMallCode !== 5) {
         const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
         const remainConsumeTimeFee = remainConsumeTime * hourPrice
+        
         // 计算单日剩余 remainConsumeTime
         // 当前使用优惠 state.usingTotalDiscount
         // 判断符合上限
-        if ( this.remainPrice >= maxOneTimeDiscountFee ) {
+        if ( this.remainPrice >= maxOneTimeDiscountFee) {
           this.couponList = this.couponList.map((elm,iemi) => {
             if ( !elm.disabled && this.checkedCouponList.indexOf(`coupon${iemi}`) < 0) {
               elm.disabled = true
@@ -222,7 +224,7 @@ export default {
       if ( this.checkedCouponList.length >= this.remainCoupons && this.parkMallCode === 2 ) {
         return
       }
-      console.log(292,this.couponList);
+      // console.log(292,this.couponList);
       const index = this.item2Number(this.checkedCouponList[0])
       const item = this.couponList[index];
       const { superposition, limitCountPerOrder = 0, name } = item;
@@ -328,7 +330,7 @@ export default {
       }
 
       // 单日上限
-      if ( oneDayLimitation && parkMallCode !== 5 && this.remainPrice >= maxOneDayDiscountFee) {
+      if (oneDayLimitation && this.remainPrice >= this.availableDiscountFee) {
         if ( showMsg ) return true
         return Toast({
           message: `每日最高可抵扣${maxOneDayDiscountFee}元`,
@@ -444,18 +446,18 @@ export default {
     },
     // H5 跳转到小程序
     launchFn({ appId, extInfo }) {
-      console.log(584, JSON.stringify({ appId, extInfo }));
+      // console.log(584, JSON.stringify({ appId, extInfo }));
       this.$store.commit('cachedViews/DEL_CACHED_VIEW', {
         name: 'parkingFeeDetail',
       });
       this.$router.go(-2);
-      console.log('H5 跳转到 嘉里中心小程序: success');
+      // console.log('H5 跳转到 嘉里中心小程序: success');
     },
     launchErrorFn({ errMsg, appId, extInfo }) {
-      console.log('H5 跳转到 嘉里中心小程序: fail', JSON.stringify({ errMsg, appId, extInfo }));
+      // console.log('H5 跳转到 嘉里中心小程序: fail', JSON.stringify({ errMsg, appId, extInfo }));
     },
     onLaunchReady() {
-      console.log('H5 跳转到 嘉里中心小程序 的标签 渲染了');
+      // console.log('H5 跳转到 嘉里中心小程序 的标签 渲染了');
     },
   },
 };

+ 81 - 40
src/pages/parkingFee/mixins/parkingFeeDiscounts.js

@@ -47,6 +47,7 @@ export default {
       parkMallCode: (state) => state.order.parkMallCode,
       paperDiscountTime: (state) => state.order.paperDiscountTime,
       paperDiscountFee: (state) => state.order.paperDiscountTime,
+      availableDiscountFee: (state) => state.order.availableDiscountFee,
     }),
     enableConsumeNonSplit() {
       return this.orderDetail.parkingRule.enableConsumeNonSplit
@@ -57,19 +58,23 @@ export default {
         return this.reduceHours || 0
       }
       // 如果不存消费减免,默认展示0
-      if(JSON.stringify(this.consume) === '{}') {
+      if (JSON.stringify(this.consume) === '{}') {
         return 0
       }
       // 如果存在消费减免并且是可拆分的,则设置最低拆分单位是 1
       return 1
     },
     stepperMax() {
+      if (this.parkMallCode === 4) {
+        // 如果存在消费减免并且是可拆分的,则设置最低拆分单位是 1
+        return this.maxReduceDiscount
+      }
       // 如果是合集车场,不存在拆分,默认返回用户可使用的消费抵扣时间
       if (this.parkMallCode === 7 || this.enableConsumeNonSplit) {
         return this.reduceHours || 0
       }
       // 如果不存消费减免,默认展示0
-      if(JSON.stringify(this.consume) === '{}') {
+      if (JSON.stringify(this.consume) === '{}') {
         return 0
       }
       // 如果存在消费减免并且是可拆分的,则设置最低拆分单位是 1
@@ -102,17 +107,17 @@ export default {
     //   return remainPrice
     // }
     // 消费减免(拆分部分)提示文本
-		reduceSplitMessage() {
-      console.log(106, this.reduceHours);
-			if (!this.enableConsumeNonSplit) {
-				return `选择${this.reduceHours}小时,`;
-			}
-			return '';
-		},
+    reduceSplitMessage() {
+      // console.log(106, this.reduceHours);
+      if (!this.enableConsumeNonSplit) {
+        return `选择${this.reduceHours}小时,`;
+      }
+      return '';
+    },
     // 消费减免金额
-		reducesDiscountFee() {
-			return this.reduceHours * this.orderDetail.parkingRule.hourPrice;
-		},
+    reducesDiscountFee() {
+      return this.reduceHours * this.orderDetail.parkingRule.hourPrice;
+    },
     // 消费减免说明文案
     todayReduceDiscountMessage() {
       // 静安浦东没有内容
@@ -120,22 +125,22 @@ export default {
         return ''
       }
       // 消费减免余额为 0 时
-      if(!this.orderDetail.parkingRule.remainConsumeTime) {
+      if (!this.orderDetail.parkingRule.remainConsumeTime) {
         return `您今日消费减免已达${this.orderDetail.parkingRule.maxConsumeTime}小时上限`
       }
       // 消费减免不存在时
-      if(JSON.stringify(this.consume) === '{}') {
+      if (JSON.stringify(this.consume) === '{}') {
         return '消费金额未达到最低优惠要求'
       }
-      
+
       // 静安存在消费减免时
       if (this.parkMallCode === 0) {
         return `今日可减免${this.consume.defaultDiscountTime}小时`;
       }
-      
+
       // 沈阳提示信息
       if (this.parkMallCode === 4 || this.parkMallCode === 6) {
-        return `未达上限时今日可减免${this.consume.defaultDiscountTime}小时`;
+        return `未达上限时今日可减免${this.stepperMax}小时`;
       }
       if (this.consume.defaultDiscountTime > this.orderDetail.parkingRule.remainConsumeTime) {
         return `消费已满${this.consume.redeemSalesAmount}元,减免${this.consume.defaultDiscountTime}小时。超出优惠上限,可减免${this.maxReduceDiscount}小时,${this.reduceSplitMessage}可优惠${this.reducesDiscountFee}元`
@@ -147,13 +152,13 @@ export default {
     try {
       this.isCheck(() => this.pageInit()); // 验证是否可选
     } catch (err) {
-      console.log(err);
+      // console.log(err);
       this.$router.back();
     }
   },
   watch: {
     remainPrice() {
-      const { maxOneDayCoupons, maxonedaydiscountFee, maxOneTimeDiscountTime, remainConsumeTime, hourPrice, availableDiscountFee, oneTimeLimitation, oneDayLimitation, maxOneDayDiscountFee } = this.orderDetail.parkingRule;
+      const { maxOneDayCoupons, maxonedaydiscountFee, maxOneTimeDiscountTime, remainConsumeTime, hourPrice, oneTimeLimitation, oneDayLimitation, maxOneDayDiscountFee } = this.orderDetail.parkingRule;
       const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice;
       // console.log('hourPrice + this.remainPrice',this.remainPrice)
       // 单日上限
@@ -172,7 +177,7 @@ export default {
           }
           if (this.isReduces) {
             this.isReduces = false;
-            console.log(109);
+            // console.log(109);
           }
         } else {
           this.isMember = this.checkedList.indexOf('member') < 0;
@@ -191,13 +196,16 @@ export default {
   },
   methods: {
     pageInit() {
-      this.remainPrice = this.usingTotalDiscount;
       if (this.orderDetail?.parkingRule?.enableConsumeSplit) {
         this.enableConsumeSplit = this.orderDetail.parkingRule.enableConsumeSplit;
       }
       this.checkedList = [];
-      const { memberGrade = [{}], consume = [], memberLevelDiscount } = this.orderDetail.discountInfo;
-      const { maxConsumeTime,remainConsumeTime } = this.orderDetail.parkingRule;
+      const { memberGrade = [{}], consume = [], memberLevelDiscount, points=[{}] } = this.orderDetail.discountInfo;
+      const { maxConsumeTime, remainConsumeTime, hourPrice } = this.orderDetail.parkingRule;
+      // 如果积分存在的话,则移除积分的优惠
+      if(JSON.stringify(points) !== {}) {
+        this.remainPrice = this.usingTotalDiscount - points[0].discountFee;
+      }      
       this.memberGrade = { ...memberGrade[0] };
       this.consume = { ...consume[0] };
       if (JSON.stringify(this.memberGrade) !== '{}' && this.memberGrade && this.memberGrade.hasOwnProperty('selected') ? this.memberGrade.selected : this.memberGrade.defaultSelected) {
@@ -214,8 +222,15 @@ export default {
       }
       this.isReduces = this.consume.hasOwnProperty('selected') || this.consume.hasOwnProperty('defaultSelected') ? false : true;
       this.reduceHours = this.consume.hasOwnProperty('discountFee') ? this.consume.discountFee / this.orderDetail.parkingRule.hourPrice : this.consume.defaultDiscountTime;
-      if (this.consume?.defaultDiscountTime) {
-        this.maxReduceDiscount = this.consume.defaultDiscountTime;
+      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) {
+          const remainingLimitToIncrease = Math.abs(this.remainPrice - this.availableDiscountFee) / hourPrice
+          const maxReduceDiscount = this.consume.discountFee / hourPrice + remainingLimitToIncrease
+          this.maxReduceDiscount = maxReduceDiscount < remainConsumeTime ? maxReduceDiscount : remainConsumeTime
+        }
       }
       this.oldCheckedList = [...this.checkedList];
       // 如果是杭州、沈阳可以选择
@@ -228,16 +243,15 @@ export default {
     setIsMemberDiscountDisabled() {
       this.todayReduceDiscountMessage = '当日';
     },
-    checkboxChange() {},
+    checkboxChange() { },
     onReduceHoursChange(type) {
       if (this.checkedList.indexOf('reduces') < 0) {
         return;
       }
       const { maxOneDayCoupons, maxonedaydiscountFee, maxOneTimeDiscountTime, remainConsumeTime, hourPrice, availableDiscountFee, oneTimeLimitation, oneDayLimitation, maxOneDayDiscountFee } = this.orderDetail.parkingRule;
       // console.log(133,this.reduceHours)
-      console.log(166, this.maxReduceDiscount);
-      if (type === 'plus' && this.reduceHours < this.maxReduceDiscount) {
-        
+      // console.log(166, this.maxReduceDiscount);
+      if (type === 'plus' && (this.reduceHours < this.maxReduceDiscount || this.parkMallCode === 4)) {
         const [isCrossMessage = false, maxReduceDiscount = this.maxReduceDiscount] = this.crossMessage();
         if (isCrossMessage) {
           // this.remainPrice = this.remainPrice - hourPrice;
@@ -255,37 +269,64 @@ export default {
       }
     },
     memberClick() {
-      const { maxConsumeTime, remainConsumeTime } = this.orderDetail.parkingRule;
+      // debugger
+      const { maxConsumeTime, remainConsumeTime, availableDiscountFee, hourPrice } = this.orderDetail.parkingRule;
       if (this.checkedList.indexOf('member') > -1) {
         this.remainPrice = this.memberGrade.discountFee + this.remainPrice;
+        if (this.parkMallCode === 4) {
+          this.remainPrice = this.remainPrice - this.reduceHours * hourPrice;
+          this.$nextTick(() => {
+            this.maxReduceDiscount = Math.abs(availableDiscountFee - this.remainPrice) / hourPrice
+            this.reduceHours = this.maxReduceDiscount
+            this.consume.discountFee = this.reduceHours * hourPrice
+            this.remainPrice = this.remainPrice + this.reduceHours * hourPrice;
+          })
+        }
       } else if (!this.isMember) {
         this.remainPrice = this.remainPrice - this.memberGrade.discountFee;
         // 如果不是沈阳,重新计算优惠
-        if(this.parkMallCode !== 4 ) {
+        if (this.parkMallCode !== 4) {
           this.maxReduceDiscount = remainConsumeTime;
         }
+        // 如果不是沈阳,重新计算优惠
+        if (this.parkMallCode === 4) {
+          const remainingLimitToIncrease = Math.abs(this.remainPrice - this.availableDiscountFee) / hourPrice
+          const maxReduceDiscount = this.consume.discountFee / hourPrice + remainingLimitToIncrease
+          this.maxReduceDiscount = maxReduceDiscount < remainConsumeTime ? maxReduceDiscount : remainConsumeTime
+          // 如果 用户选择的金额与消费减免的上限不一致,则不进行计算
+          /* if(this.reduceHours === this.maxReduceDiscount) {
+            this.reduceHours = this.maxReduceDiscount
+            this.consume.discountFee = this.reduceHours * hourPrice
+            this.remainPrice = this.remainPrice + remainingLimitToIncrease * hourPrice
+          } */
+          this.reduceHours = this.maxReduceDiscount
+          this.consume.discountFee = this.reduceHours * hourPrice
+          this.remainPrice = this.remainPrice + remainingLimitToIncrease * hourPrice
+
+        }
       }
-      const [isCrossMessage = false, maxReduceDiscount = this.maxReduceDiscount] = this.crossMessage();
-      if (isCrossMessage) {
-        this.checkedList = this.checkedList.filter((elm) => elm !== 'member');
-        this.remainPrice = this.remainPrice - this.memberGrade.discountFee;
-        this.isMember = false;
-      }
+
+      /*  const [isCrossMessage = false, maxReduceDiscount = this.maxReduceDiscount] = this.crossMessage();
+       if (isCrossMessage) {
+         this.checkedList = this.checkedList.filter((elm) => elm !== 'member');
+         this.remainPrice = this.remainPrice - this.memberGrade.discountFee;
+         this.isMember = false;
+       } */
     },
     reducesClick() {
-      const { maxOneTimeDiscountTime, hourPrice, oneTimeLimitation, maxConsumeTime,remainConsumeTime, oneDayLimitation, maxOneDayDiscountFee } = this.orderDetail.parkingRule;
+      const { maxOneTimeDiscountTime, hourPrice, oneTimeLimitation, maxConsumeTime, remainConsumeTime, oneDayLimitation, maxOneDayDiscountFee } = this.orderDetail.parkingRule;
       const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice;
       const reduceHours = (maxOneTimeDiscountFee - this.remainPrice) / hourPrice;
       if (this.checkedList.indexOf('reduces') > -1) {
         this.remainPrice = hourPrice + this.remainPrice;
         // 如果不是沈阳,重新计算计算最大上限
-        if(this.parkMallCode !== 4 ) {
+        if (this.parkMallCode !== 4) {
           this.maxReduceDiscount = remainConsumeTime > maxOneTimeDiscountFee / hourPrice ? maxOneTimeDiscountFee / hourPrice : remainConsumeTime;
         }
       } else {
         this.remainPrice = this.remainPrice - hourPrice;
         // 如果不是沈阳,重新计算计算最大上限
-        if(this.parkMallCode !== 4 ) {
+        if (this.parkMallCode !== 4) {
           this.maxReduceDiscount = remainConsumeTime > maxOneTimeDiscountFee / hourPrice ? maxOneTimeDiscountFee / hourPrice : remainConsumeTime;
         }
       }

+ 1 - 1
src/store/order/index.js

@@ -1,4 +1,4 @@
-import checkOutQHResponse from "@/api/mockData/checkout.sy4.response.json";
+import checkOutQHResponse from "@/api/mockData/checkout.sy5.response.json";
 import { checkOut,calculateDiscount,ordersAndPrepay,currentUnlicensedPlate,unlicensedCarCheckIn,unlicensedCarCheckout } from '@/api/parking';
 import state from "@/store/order/state";
 import mutations from "@/store/order/mutations";