Procházet zdrojové kódy

Merge pull request #152 from John-Hong/John/relsead-2.11.0/KIP-10162

feat(KIP-10162): Temp parking | 杭州 CRM&Kerry+ 临停微服务改造 Frontend
Tron před 2 roky
rodič
revize
cbdee1701f

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "temporay-parking",
-  "version": "2.10.0",
+  "version": "2.11.0",
   "private": true,
   "scripts": {
     "serve": "cross-env NODE_ENV=dev vue-cli-service serve",

+ 170 - 0
src/api/mockData/checkout.hz1.response.json

@@ -0,0 +1,170 @@
+{
+  "parkingRecord": {
+    "vehicleNo": "浙A00001",
+    "enterTime": "2022-08-02 10:36:12",
+    "serviceMin": 436352,
+    "totalFee": 5000,
+    "actualPayFee": 20,
+    "thirdPartyId": "_5_b4aab994_1685588915925",
+    "thirdParkOrderNo": "b4aab9946f54436e9f5207a160645897",
+    "createdByQrCode": false,
+    "totalFeeInYuan": 50
+  },
+  "discountInfo": {
+    "usingTotalDiscount": 30,
+    "memberLevelDiscount": true,
+    "memberGrade": [
+      {
+        "defaultSelected": true,
+        "memberGrade": "4",
+        "memberGradeText": "臻选银卡",
+        "discountTime": 2,
+        "discountFee": 20
+      }
+    ],
+    "points": [
+      {
+        "available": 0,
+        "pointsPerUnit": 1000,
+        "unitAmount": 10,
+        "totalAvailable": 0,
+        "unitHour": 1,
+        "newMember": false,
+        "label": "0积分可减免"
+      }
+    ],
+    "coupons": [
+      {
+        "code": "wwmsrxvld9c_t",
+        "couponId": "4ed038d39fef486f853d53a8bc0b15e1",
+        "status": "available",
+        "name": "停车券-自动化",
+        "expirationDate": "2025-04-01 23:59:59",
+        "discountFee": 10,
+        "defaultSelected": true,
+        "superposition": "2",
+        "limitCountPerOrder": 100
+      },
+      {
+        "code": "j6x51ntawrn_t",
+        "couponId": "4ed038d39fef486f853d53a8bc0b15e1",
+        "status": "available",
+        "name": "停车券-自动化",
+        "expirationDate": "2025-04-01 23:59:59",
+        "discountFee": 10,
+        "defaultSelected": false,
+        "superposition": "2",
+        "limitCountPerOrder": 100
+      },
+      {
+        "code": "lljwkim3mjd_t1",
+        "couponId": "4ed038d39fef486f853d53a8bc0b15e1",
+        "status": "available",
+        "name": "停车券-自动化",
+        "expirationDate": "2025-04-01 23:59:59",
+        "discountFee": 10,
+        "defaultSelected": false,
+        "superposition": "2",
+        "limitCountPerOrder": 100
+      },
+      {
+        "code": "lljwkim3mjd_t2",
+        "couponId": "4ed038d39fef486f853d53a8bc0b15e1",
+        "status": "available",
+        "name": "停车券-自动化",
+        "expirationDate": "2025-04-01 23:59:59",
+        "discountFee": 10,
+        "defaultSelected": false,
+        "superposition": "2",
+        "limitCountPerOrder": 100
+      },
+      {
+        "code": "lljwkim3mjd_t3",
+        "couponId": "4ed038d39fef486f853d53a8bc0b15e1",
+        "status": "available",
+        "name": "停车券-自动化",
+        "expirationDate": "2025-04-01 23:59:59",
+        "discountFee": 10,
+        "defaultSelected": false,
+        "superposition": "2",
+        "limitCountPerOrder": 100
+      },
+      {
+        "code": "lljwkim3mjd_t4",
+        "couponId": "4ed038d39fef486f853d53a8bc0b15e1",
+        "status": "available",
+        "name": "停车券-自动化",
+        "expirationDate": "2025-04-01 23:59:59",
+        "discountFee": 10,
+        "defaultSelected": false,
+        "superposition": "2",
+        "limitCountPerOrder": 100
+      },
+      {
+        "code": "lljwkim3mjd_5t",
+        "couponId": "4ed038d39fef486f853d53a8bc0b15e1",
+        "status": "available",
+        "name": "停车券-自动化",
+        "expirationDate": "2025-04-01 23:59:59",
+        "discountFee": 10,
+        "defaultSelected": false,
+        "superposition": "2",
+        "limitCountPerOrder": 100
+      }
+    ],
+    "paperCoupons": [
+      {
+        "description": "请扫描纸质停车优惠券二维码,获取停车优惠"
+      },
+      {
+        "description": "131231"
+      },
+      {
+        "description": "请扫描纸质停车优惠券二维码,获取停车优惠"
+      },
+      {
+        "description": "请扫描纸质停车优惠券二维码,获取停车优惠"
+      },
+      {
+        "description": "131231"
+      },
+      {
+        "description": "请扫描纸质停车优惠券二维码,获取停车优惠"
+      },
+      {
+        "description": "请扫描纸质停车优惠券二维码,获取停车优惠"
+      },
+      {
+        "description": "131231"
+      },
+      {
+        "description": "131231"
+      },
+      {
+        "description": "131231"
+      }
+    ]
+  },
+  "parkingRule": {
+    "enableNewMemberPoints": false,
+    "enablePoints": true,
+    "unLimitWeekendPoints": false,
+    "enableCoupon": true,
+    "maxOneDayCoupons": 5,
+    "remainCoupons": 5,
+    "enablePaperCoupons": true,
+    "enableConsume": true,
+    "enableConsumeSplit": false,
+    "maxConsumeTime": 6,
+    "remainConsumeTime": 6,
+    "hourPrice": 10,
+    "oneTimeLimitation": false,
+    "oneDayLimitation": false
+  },
+  "parkInfo": {
+    "parkName": "杭州嘉里中心",
+    "description": "计费基础规则:10元每小时,上不封顶 ;\n线上缴费渠道:CRM小程序 (分会员通道及非会员通道);1\n会员等级减免:铂金卡当日可免费停车4小时,金卡当时可免费停车2小时,银卡无减免 (当日仅限使用1次,可与其它减免共享);\n积分抵扣:1000积分抵扣10元(手动输入抵扣积分);\n消费减免:消费200元可减免2小时,消费400元可减免4小时,消费800元可减免6小时 。仅限会员,当日有效,当日可多次享受该减免,当日最多可享受消费减免6小时。;\n        消费减免举例:;\n        (1) 某顾客第一次进场,消费230元  离场时可看到减免2小时的选项,默认为选中;\n        (2) 如果顾客未使用减免,顾客第二次进场,消费+270  离场时可看到减免金额提高到4小时;\n         如果顾客使用减免:顾客第二次进场,消费+270  离场时可看到还是只能减免2小时;\n        (3) CRM小程序缴费页面停留时长1分钟,1分钟后自动刷新获取最新缴费金额;\n纸质优惠券核销: 顾客在CRM小程序手动扫码获取优惠券金额;\n会员活动及积分兑换优惠 :通过CRM系统获取(详细情况由CRM另行描述)!",
+    "parkMallCode": 2,
+    "buildingId": "HKC-P1"
+  }
+}

+ 33 - 150
src/pages/parkingFee/mixins/parkingFeeCoupon.js

@@ -4,8 +4,8 @@ import uni from '@/utils/uniHooks';
 import { Toast } from 'vant';
 import { getPlatform, getAppIdByGroupIdAndMallId, isInWeixinH5 } from '@/utils';
 import { initWxJsSdkConfig } from '@/utils/login';
-import { compare } from '@/utils/location.js';
-import { isArray } from 'lodash';
+// import { compare } from '@/utils/location.js';
+// import { isArray } from 'lodash';
 // import { v4 as uuidv4 } from 'uuid';
 
 export default {
@@ -35,6 +35,9 @@ export default {
       unLimitWeekendPoints: (state) => state.order.unLimitWeekendPoints, // 新的积分上限, 默认为false(不开启), unLimitWeekendPoints: true # 开启无上限功能;   unLimitWeekendPoints: false # 关闭无上限功能;
       lbsId: (state) => state.lbsId, // 楼栋ID
       groupId: (state) => state.groupId, // 楼盘ID
+      remainCoupons: ( state ) => state.order.remainCoupons, // 仅限杭州当前剩余可选电子券上限
+      parkMallCode: ( state ) => state.order.parkMallCode, // 当前车场的数据
+      maxOneDayCoupons: ( state ) => state.order.maxOneDayCoupons,// 仅限杭州当日电子券可选上限
     }),
   },
 
@@ -139,7 +142,7 @@ export default {
         this.setAllDisabled()
         this.isDisabledByRule(coupon, index, 'showMsg');
       })
-      
+
     },
     // 针对达到优惠的上限制
     setAllDisabled() {
@@ -160,7 +163,6 @@ export default {
       if ( oneDayLimitation  && parkMallCode !== 5) {
         const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
         const remainConsumeTimeFee = remainConsumeTime * hourPrice
-        console.log(156, remainConsumeTimeFee)
         // 计算单日剩余 remainConsumeTime
         // 当前使用优惠 state.usingTotalDiscount
         // 判断符合上限
@@ -174,14 +176,12 @@ export default {
         }
       }
       // 单次上限限制
-      if ( oneTimeLimitation && parkMallCode !== 5) {
-        console.log(170)
+      if ( oneTimeLimitation && parkMallCode !== 5 ) {
         const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
-        const remainConsumeTimeFee = remainConsumeTime * hourPrice
+        // const remainConsumeTimeFee = remainConsumeTime * hourPrice
         // 计算单日剩余 remainConsumeTime
         // 当前使用优惠 state.usingTotalDiscount
         // 判断符合上限
-        console.log(177, remainConsumeTimeFee)
         if ( this.remainPrice >= maxOneTimeDiscountFee ) {
           this.couponList = this.couponList.map((elm,iemi) => {
             if ( !elm.disabled && this.checkedCouponList.indexOf(`coupon${iemi}`) < 0) {
@@ -191,81 +191,18 @@ export default {
           })
         }
       }
+      // 杭州电子券选择上限判断
+      if ( parkMallCode === 2 && this.checkedCouponList.length === this.remainCoupons ) {
+        this.couponList = this.couponList.map(( elm,iemi ) => {
+          if ( !elm.disabled && this.checkedCouponList.indexOf(`coupon${ iemi }`) < 0 ) {
+            elm.disabled = true
+          }
+          return elm
+        })
+      }
       return false
     },
     // 对不同类型的优惠券进行汇总统计
-    /*groupedCouponData() {
-      const groupedData = {}; // 所有的电子券按照批次分组;
-      let couponList = [...this.couponList]; // 获取目前用户的电子券
-      couponList.forEach((elm, index) => {
-        // 初始化数据
-        const elmName = `coupon${index}`;
-        const newElm = { ...elm };
-        if (!groupedData[elm.name] || !groupedData[elm.name].hasOwnProperty('noSelectedList')) {
-          groupedData[newElm.name] = {
-            noSelectedList: [], // 未选择的
-            selectedList: [], // 已选择的
-          }
-        }
-        newElm.index = index; // 记录每张电子券的顺序
-        // 所有的电子券按照 已选择 和 未选择的分组,存储到同批次下
-        if (this.checkedCouponList.indexOf(elmName) > -1) {
-          newElm.selected = true;
-          groupedData[newElm.name]['selectedList'].push(newElm)
-        } else {
-          newElm.selected = false;
-          groupedData[newElm.name]['noSelectedList'].push(newElm)
-        }
-      })
-      // 对分好组的优惠券进行不同规则处理
-      Object.keys(groupedData).forEach(key => {
-        const { selectedList, noSelectedList } = groupedData[key]; // 取出已选择的和未选择的
-        const { superposition, limitCountPerOrder = 0 } = selectedList.concat(noSelectedList)[0]; // 获取当前批次兑换的类型和可选上限
-        switch (superposition) {
-          case '1': // 不可叠加
-            couponList = couponList.map((item, index) => {
-              const elmName = `coupon${index}`;
-              // 如果是不可叠加的电子优惠券,设置未选中的为不可选择
-              if (item?.superposition === '1') {
-                if (selectedList.length) {// 如果存在已选择项,设置未选中的为不可选择
-                  item.disabled = this.checkedCouponList.indexOf(elmName) < 0;
-                  /!* 
-                  TODO: 如果不可叠加电子券的选择规则改变为,选中某一项不可叠加券,其他券不可选择,则打开此处注释
-                  if (item.superposition === '2') {
-                    item.disabled = selectedList.length > 0
-                  } *!/
-                } else {
-                  item.disabled = this.checkedCouponList.length > 0;
-                }
-              }
-              /!* 
-              // TODO: 如果不可叠加电子券的选择规则改变为,选中某一项不可叠加券,其他券不可选择,则打开此处注释
-              // 如果存在已选的电子优惠券,将其他类型的优惠券设置为不可选中
-              if ( item.superposition === '2' && selectedList.length) {
-                item.disabled = true
-              } *!/
-              return item
-            })
-            break
-          case '2':
-            // 统计未选择项是否需要禁用
-            noSelectedList.forEach(elm => {
-              const _elm = { ...couponList[elm.index] };
-              couponList = couponList.map((item, index) => {
-                if (index === elm.index && limitCountPerOrder > 0) {
-                  // elm.disabled = selectedList.length >= limitCountPerOrder;
-                  _elm.disabled = selectedList.length >= limitCountPerOrder;
-                  return _elm
-                }
-                return item
-              })
-            })
-            break
-        }
-      })
-      this.couponList = [...couponList];
-    },*/
-    // 对不同类型的优惠券进行汇总统计
     newGroupedCouponData() {
       let couponList = [...this.couponList]; // 获取目前用户的电子券
       if (!this.checkedCouponList.length) {
@@ -275,6 +212,11 @@ export default {
         })
         return
       }
+      // 如果杭州的使用券打到上限则不自动计算其余券是否可选
+      if ( this.checkedCouponList.length >= this.remainCoupons && this.parkMallCode === 2 ) {
+        return
+      }
+      console.log(292,this.couponList);
       const index = this.item2Number(this.checkedCouponList[0])
       const item = this.couponList[index];
       const { superposition, limitCountPerOrder = 0, name } = item;
@@ -286,7 +228,7 @@ export default {
           })
           break;
         case '2': // 同类型可叠加
-          // 找到
+                  // 找到
           couponList = couponList.map((elm, i) => {
             // 只有 status === 'available' 的才会赋值为 false
             elm.disabled = elm?.status !== 'available'; // 默认可选
@@ -323,31 +265,14 @@ export default {
           icon: 'none',
         });
       }
-      // 杭州电子券使用上限(单位: 张)
-      /*if (this.parkMallCode === 2) {
-       // 达到上限
-       if (
-       this.checkedCouponList.length ===
-       this.parkFee.parkInfoEntity.useTicketNum -
-       this.parkFee.parkInfoEntity.couponcodeNum
-       ) {
-       this.list.forEach((e, i) => {
-       if (this.checkedCouponList.findIndex((c) => c == i) === -1) {
-       e.disabled = true;
-       } else {
-       e.checked = true;
-       }
-       });
-       return uni.showToast({
-       title: `电子券每天最多可使用${this.parkFee.parkInfoEntity.useTicketNum}张`,
-       icon: "none",
-       });
-       } else {
-       this.list.forEach((e) => {
-       e.disabled = false;
-       });
-       }
-       }*/
+      if ( this.checkedCouponList.length >= this.remainCoupons && this.parkMallCode === 2 ) {
+        if ( showMsg ) return true
+        return Toast({
+          className: 'top300',
+          message: `电子券每天最多可使用${ this.maxOneDayCoupons }张`,
+          icon: 'none',
+        });
+      }
 
       // 浦东每次缴费超限控制、沈阳每日超限控制
       if ((parkMallCode === 1 || parkMallCode === 4 || parkMallCode === 5 || parkMallCode === 999 || parkMallCode === 6) && this.crossMessage(showMsg)) {
@@ -385,42 +310,8 @@ export default {
       if (parkMallCode === 5) {
         if (remainPrice - this.paperDiscountFee > actualPayFee) {
           remainPrice = actualPayFee;
-        }  
+        }
       }
-      
-      // let totalFee = this.parkDiscountTotal.feeCopy;
-      // totalFee += this.totalFee;
-      // 电子券优惠金额总计
-      // 浦东每次优惠上限
-      /*if (
-       parkMallCode === 1 &&
-       totalFee - this.paperCouponFee >= this.maxonetimediscountFee
-       ) {
-       //  uni.showToast({
-       //   title: `超出抵扣上限,每次最高可抵扣${this.parkFee.parkInfoEntity.maxonetimediscount}小时`,
-       //   icon: 'none',
-       // });
-       return Toast({
-       message: `超出抵扣上限,每次最高可抵扣${this.parkFee.parkInfoEntity.maxonetimediscount}小时`,
-       icon: 'none',
-       });
-       return;
-       }*/
-      // 沈阳超限处理(maxonedaydiscountFee 会员、消费、电子券减免)
-      /*if (
-       parkMallCode === 4 &&
-       totalFee - this.paperCouponFee - this.parkDiscountTotal.bonusfee >=
-       this.maxonedaydiscountFee
-       ) {
-       return Toast({
-       message: `(会员等级、消费、电子券)每日最高可抵扣${this.parkFee.parkInfoEntity.maxOneDayHour}小时`,
-       icon: 'none',
-       });
-       // return uni.showToast({
-       //   title: `(会员等级、消费、电子券)每日最高可抵扣${this.parkFee.parkInfoEntity.maxOneDayHour}小时`,
-       //   icon: 'none',
-       // });
-       }*/
       // 深圳超限处理
       if (parkMallCode === 5 && this.remainPrice  >= this.availableDiscountFee) {
         if ( showMsg ) return true
@@ -429,7 +320,7 @@ export default {
           icon: 'none',
         });
       }
-      
+
       // 单日上限
       if ( oneDayLimitation && parkMallCode !== 5 && this.remainPrice >= maxOneDayDiscountFee) {
         if ( showMsg ) return true
@@ -447,14 +338,6 @@ export default {
           icon: 'none',
         });
       }
-      // 浦东,单次上限提示, 后续 usingTotalDiscount 再减去 纸质优惠券的金额
-      /*if (parkMallCode === 1 && this.remainPrice - this.paperDiscountFee >= this.availableDiscountFee) {
-        if ( showMsg ) return true
-        return Toast({
-          message: `超出抵扣上限,每次最高可抵扣${maxOneTimeDiscountTime}小时`,
-          icon: 'none',
-        });
-      }*/
       return false
     },
     // 确认

+ 3 - 2
src/store/order/coupon.js

@@ -5,8 +5,9 @@ export default {
   // 电子优惠券
   couponRule( {commit,dispatch,state},checkOutResponse ) {
     commit('setEnableCoupon',checkOutResponse.parkingRule.enableCoupon);
-    if ( checkOutResponse.parkingRule.enableCoupon) {
-      commit('setMaxOneDayCoupons',checkOutResponse?.parkingRule?.maxOneDayCoupons || 0); // 仅在杭州使用
+    if ( checkOutResponse.parkingRule.enableCoupon ) {
+      commit('setMaxOneDayCoupons',checkOutResponse.parkingRule.maxOneDayCoupons); // 仅在杭州使用
+      commit('setRemainCoupons',checkOutResponse.parkingRule.remainCoupons); // 仅在杭州使用
       // 根据时间排序电子兑换券
       const couponSort = ( a,b ) => {
         let aTime = new Date(`${ a.expirationDate }`.replace(/-/g,'/'));

+ 4 - 0
src/store/order/mutations.js

@@ -32,6 +32,9 @@ export default {
   setMaxOneDayCoupons( state,payload ) {
     state.maxOneDayCoupons = payload;
   },
+  setRemainCoupons( state,payload ) {
+    state.remainCoupons = payload;
+  },
   setCoupons( state,payload ) {
     state.coupons = payload;
   },
@@ -131,6 +134,7 @@ export default {
     state.pointsPerHour = 0; // 每小时兑换积分
     state.enableCoupon = false; // 电子优惠券是否启用
     state.maxOneDayCoupons = 0; // 单日可选优惠券上限
+    state.remainCoupons = 0; // 单日剩余可选优惠券上限
     state.coupons = []; // 可选优惠券数量
     state.couponCount = 0; // 已选择优惠券
     state.couponDesc = ''; // 优惠券说明文案