Просмотр исходного кода

Merge pull request #592 from John-Hong/John/release-3.17.0/KIP-19153

feat(KIP-19153): 山姆优惠选项
Tron 9 месяцев назад
Родитель
Сommit
295344b2a1

+ 7 - 4
src/pages/parkingFeeV2/mixins/parkingFeeDetail.js

@@ -169,6 +169,12 @@ export default {
       // 当存在待支付金额 或者 用户登陆
       return !this.orderDetail?.parkingRecord?.totalFee || (JSON.stringify(this.member) !== '{}' && !this.orderDetail.parkInfo);
     },
+    parkDiscountDesc() {
+      if(this.orderDetail.parkingRecord.hasOwnProperty('parkDiscount')) {
+        return this.orderDetail.parkingRecord.parkDiscount ? `已抵扣${this.orderDetail.parkingRecord.parkDiscount}元` : '暂无优惠'
+      }
+      return ''
+    }
     // integralDesc() {
     //   if (this.pointsTime > 0) {
     //     // 深圳特殊处理(单位:金额)
@@ -266,10 +272,7 @@ export default {
           // points
           payChannel: isAlipay() ? 'MINI_PROGRAM' : 'OFFICIAL_ACCOUNT',
           payOption: isAlipay() ? 'ALIPAY' : 'WECHATPAY',
-          parkingRecord: {
-            ...parkingRecord,
-            actualPayFee: this.actualPayFee, //应付金额
-          },
+          parkingRecord: {...parkingRecord},
           discountInfo: {
             usingTotalDiscount: discountInfo?.usingTotalDiscount || 0, //优惠金额"
             actualUsedDiscount: discountInfo?.usingTotalDiscount || 0, //实际优惠金额

+ 6 - 0
src/pages/parkingFeeV2/mixins/parkingFeeDetailSuccess.js

@@ -31,6 +31,12 @@ export default {
       // mobile: (state) => state.mobile,
       // projectId: (state) => state.projectId,
     }),
+    parkDiscountDesc() {
+      if(this.detail.discountInfo.hasOwnProperty('parkDiscount')) {
+        return this.detail.discountInfo.parkDiscount
+      }
+      return 'hide'
+    }
   },
   methods: {
     async getData() {

+ 5 - 0
src/pages/parkingFeeV2/parkingFeeDetail.vue

@@ -28,6 +28,11 @@
         </div>
       </div>
       <div class="info-box mb--30">
+        <div class="info-item-box" v-if="parkDiscountDesc">
+          <div class="label">山姆优惠</div>
+          <div :class="['value',parkDiscountDesc === '暂无优惠' ?  '' : 'text-red']">{{ parkDiscountDesc }}
+          </div>
+        </div>
         <div class="info-item-box" v-if="enableConsume || memberLevelDiscount">
           <div class="label">停车优惠</div>
           <div @click="discounts" :class="['value',discountDesc === '暂无可用优惠' ?  '' : 'text-red']">{{ discountDesc }}

+ 4 - 0
src/pages/parkingFeeV2/parkingFeeDetailSuccess.vue

@@ -62,6 +62,10 @@
               $currency(detail.firstParkFee / 100)
             }}</span>
           </div>
+          <div class="parking-info-item" v-if="parkDiscountDesc !== 'hide'">
+            <span class="info-key">山姆优惠</span>
+            <span class="info-value ">{{ detail.discountInfo && detail.discountInfo.parkDiscount | currency }}</span>
+          </div>
           <div class="parking-info-item">
             <span class="info-key">会员等级减免</span>
             <span class="info-value ">{{ detail.discountInfo && $currency(detail.discountInfo.memberLevelDiscount) }}</span>

+ 23 - 0
src/store/order/common.js

@@ -0,0 +1,23 @@
+export default {
+    commonRule({commit,dispatch,state},checkOutResponse) {
+        let usingTotalDiscount = checkOutResponse?.discountInfo?.usingTotalDiscount || 0
+        let actualPayFee = 0
+        let isDiscount = false
+        if ( checkOutResponse?.parkingRecord?.hasOwnProperty('actualPayFee') ) {
+            actualPayFee = checkOutResponse.parkingRecord?.actualPayFee
+            isDiscount = true
+        } else {
+            actualPayFee = checkOutResponse.parkingRecord?.totalFee
+        }
+        if(checkOutResponse.parkingRecord.hasOwnProperty('parkDiscount'))  {
+            const {parkDiscount} = checkOutResponse.parkingRecord
+            usingTotalDiscount += parkDiscount
+            if (isDiscount) {
+                actualPayFee = actualPayFee > parkDiscount ? actualPayFee  - parkDiscount : 0;
+            }
+        }
+        // 其他数据收集
+        commit('setUsingTotalDiscount', usingTotalDiscount);
+        commit('setActualPayFee', actualPayFee);
+    }
+}

+ 6 - 8
src/store/order/index.js

@@ -2,6 +2,7 @@
 import { checkOut,calculateDiscount,ordersAndPrepay,currentUnlicensedPlate,unlicensedCarCheckIn,unlicensedCarCheckout } from '@/api/parking';
 import state from "@/store/order/state";
 import mutations from "@/store/order/mutations";
+import common from "@/store/order/common";
 import memberLevel from "@/store/order/memberLevel";
 import points from "@/store/order/points";
 import coupon from "@/store/order/coupon";
@@ -93,13 +94,8 @@ export default {
         // 电子优惠券:是否启用
         // 处理电子优惠券相关逻辑
         dispatch('couponRule',checkOutResponse);
-      }
-      // 其他数据收集
-      commit('setUsingTotalDiscount',checkOutResponse?.discountInfo?.usingTotalDiscount || 0);
-      if ( checkOutResponse?.parkingRecord?.hasOwnProperty('actualPayFee') ) {
-        commit('setActualPayFee',checkOutResponse.parkingRecord?.actualPayFee);
-      } else {
-        commit('setActualPayFee',checkOutResponse.parkingRecord?.totalFee);
+        // 通用逻辑
+        dispatch('commonRule',checkOutResponse);
       }
     },
     // 会员等级
@@ -113,6 +109,8 @@ export default {
     // 无牌车
     ...unlicensed,
     // 纸质优惠券
-    ...paperCoupon
+    ...paperCoupon,
+    // 通用功能
+    ...common
   },
 };