浏览代码

fix(SCRM-4776): [DE][C端]临时停车,PD,用户只有一个小时消费减免,还有电子券或者积分的情况,当用户取消掉积分或者电子券优惠,再点击停车优惠,用户的消费减免就会变成2小时

Tron 1 年之前
父节点
当前提交
8a95db4b48

+ 2 - 2
src/api/mockData/checkout.pd14.response.json

@@ -10,7 +10,7 @@
     "totalFeeInYuan": 20
   },
   "discountInfo": {
-    "usingTotalDiscount": 24,
+    "usingTotalDiscount": 12,
     "memberLevelDiscount": false,
     "consume": [
       {
@@ -28,7 +28,7 @@
         "unitHour": 1,
         "newMember": false,
         "label": "已选择兑换2小时",
-        "discountFee": 24
+        "discountFee": 12
       }
     ],
     "paperCoupons": [

+ 66 - 0
src/api/mockData/checkout.pd16.response.json

@@ -0,0 +1,66 @@
+{
+  "parkingRecord": {
+    "vehicleNo": "沪A00001",
+    "enterTime": "2023-10-11 10:54:00",
+    "serviceMin": 10136,
+    "totalFee": 64200,
+    "actualPayFee": 630,
+    "thirdParkOrderNo": "s202310181152590aaf1aaf94",
+    "createdByQrCode": false,
+    "getTime": "2023-10-18 11:52:59",
+    "totalFeeInYuan": 642
+  },
+  "discountInfo": {
+    "usingTotalDiscount": 12,
+    "memberLevelDiscount": false,
+    "consume": [
+      {
+        "defaultSelected": true,
+        "selected": true,
+        "defaultDiscountTime": 1,
+        "discountFee": 12,
+        "redeemSalesAmount": 300,
+        "couponCodes": "l55nmr898ee_t"
+      }
+    ],
+    "points": [
+      {
+        "available": 4000,
+        "selected": true,
+        "pointsPerUnit": 1000,
+        "unitAmount": 12,
+        "totalAvailable": 4000,
+        "unitHour": 1,
+        "newMember": false,
+        "label": "已选择兑换1小时",
+        "discountFee": 0
+      }
+    ],
+    "paperCoupons": [
+      {
+        "description": "纸质优惠券不限制会员使用。",
+        "selected": false
+      }
+    ]
+  },
+  "parkingRule": {
+    "maxOneTimeDiscountTime": 2,
+    "enableNewMemberPoints": false,
+    "enablePoints": true,
+    "unLimitWeekendPoints": false,
+    "enableCoupon": true,
+    "enablePaperCoupons": true,
+    "enableConsume": true,
+    "enableConsumeNonSplit": false,
+    "remainConsumeTime": 1,
+    "hourPrice": 12,
+    "oneTimeLimitation": true,
+    "oneDayLimitation": false
+  },
+  "parkInfo": {
+    "parkName": "PD",
+    "description": "12元/小时。8-24小时封顶96元。纸质优惠券不限制使用数量。每次最多优惠2小时。积分兑换停车费用1200积分=1小时。积分商城售卖停车电子券的使用类型。单日累计消费满300元赠送1张消费600元赠2张1小时的停车券,不重复发券,消费跨天不累计,",
+    "parkMallCode": 1,
+    "buildingId": "184-100035"
+  }
+}

+ 1 - 1
src/api/request.js

@@ -110,7 +110,7 @@ function XUser(config) {
     delete params.userId
     delete params.phoneNumber
   }
-  if (params.isLogin && (!params.vipCode || !params.userId) && config.url.indexOf('/parking-lots/') < -1) {
+  if (params.isLogin && (!params.vipCode || !params.userId) && config.url.indexOf('/parking-lots/') < -1 || !params.sourceId) {
     throw {
       response: {
         data: {

+ 8 - 1
src/main.js

@@ -5,7 +5,14 @@ import VConsole from 'vconsole';
 
 // 或者使用配置参数来初始化,详情见文档
 // 开发环境和qa环境 打开debug
-const debug = /dev-t?-?|qa-t?-?|sl-t?-?|2486/.test(window.location.href);
+// const debug = /dev-t?-?|qa-t?-?|sl-t?-?|2486/.test(window.location.origin);
+let debug = false;
+const keys = ['https://dev-','https://qa-','https://lt-','https://sl-','http://127.0.0.1'];
+keys.forEach(key => {
+  if(!debug && window.location.origin.indexOf(key) > -1) {
+    debug = true
+  }
+})
 if (debug) {
   window.vConsole = new VConsole(
     // { theme: 'dark' }

+ 46 - 18
src/pages/parkingFeeV2/mixins/parkingFeeDiscounts.js

@@ -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) {

+ 7 - 1
src/store/index.js

@@ -351,12 +351,18 @@ const store = new Vuex.Store({
         }
         if(isLogin) {
           commit('SET_IS_LOGIN', isLogin);
+        }
+        if(isLogin === 'haveLoggedIn') {
           dispatch('memberInit', {
-            openid: openId,
+            openid: openId || uni.getStorageSync('openid'),
             unionId,
             isError: true
           });
         }
+        dispatch('updateUnionIdActive', {
+          unionId: unionId,
+          openId: openId || uni.getStorageSync('openid')
+        })
         callback && callback();
         return
         /* {

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

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

+ 5 - 5
src/utils/index.js

@@ -180,9 +180,9 @@ export function wxToLoginCallback( path,callback ) {
 }
 
 export function initEnv() {
-  const href = window.location.href;
-  console.log('当前页面的url地址  ',href);
-  if ( /dev-|2486/.test(href) ) {
+  const origin = window.location.origin;
+  console.log('当前页面的url地址  ',origin);
+  if ( origin.indexOf('https://dev-') > -1  || origin.indexOf('http://127.0.0.1') > -1) {
     window.env = 'qa';
     window.profileApi = 'https://qa-apim.kerryplus.com/c/api';
     window.cmrApi = 'https://qa-crm.kerryplus.com/xcrm-api/api';
@@ -198,7 +198,7 @@ export function initEnv() {
     window.wechatOfficialAccountId = 'wxb81a622ed6d60adf'
     return;
   }
-  if ( /qa-/.test(href) ) {
+  if ( origin.indexOf('https://qa-') > -1 ) {
     window.env = 'qa';
     window.api = 'qaApi';
     window.profileApi = 'https://qa-apim.kerryplus.com/c/api';
@@ -206,7 +206,7 @@ export function initEnv() {
     window.wechatOfficialAccountId = 'wxb81a622ed6d60adf'
     return;
   }
-  if ( /sl-/.test(href) ) {
+  if ( origin.indexOf('https://sl-') > -1 ) {
     window.env = 'prod';
     window.profileApi = 'https://sl-apim.kerryplus.com/c/api';
     window.cmrApi = 'https://sl-crm.kerryplus.com/xcrm-api/api';