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

feat(payment): 优化多端支付流程及积分抵扣展示

- 统一处理微信小程序和H5端的支付逻辑,支持积分支付和非积分支付
- 添加支付结果轮询,提升用户支付体验
- 修正退款详情页逻辑,调整退款类型判断条件
- 优化订单页积分折扣和实际支付金额显示,避免计算误差
- 增加会员订单优惠描述和金额的条件渲染
- 更新视频权益支付页积分抵扣金额显示及支付按钮文本
- 调整接口请求域名配置注释,切换开发环境URL
zouzexu 19 часов назад
Родитель
Сommit
748357fa8f

+ 2 - 2
src/config/index.ts

@@ -8,10 +8,10 @@ const mapEnvVersion = {
   // develop: 'http://192.168.1.253:8080',
   // develop: 'http://192.168.0.19:8080', // 邓
   // develop: 'http://192.168.1.20:8080', // 黄
-  // develop: 'http://192.168.0.11:8081', // 王
+  develop: 'http://192.168.0.11:8081', // 王
   // develop: 'http://192.168.1.21:8080', // 田
   // develop: 'http://74949mkfh190.vicp.fun', // 付
-  develop: 'http://47.109.84.152:8081', // 测试代理
+  // develop: 'http://47.109.84.152:8081', // 测试代理
   // develop: 'https://5ed0f7cc.r9.vip.cpolar.cn',
   // develop: 'https://25740642.r3.cpolar.top',
   // develop: 'https://smqjh.api.zswlgz.com',

+ 1 - 1
src/subPack-common/afterSalesDetail/index.vue

@@ -133,7 +133,7 @@ async function handleSubmitLogistics() {
         </view>
       </view> -->
     </view>
-    <view v-if="refundOrderInfo.refundType === 2 && (isLogisticsSubmitted || refundOrderInfo.returnMoneySts === refundStatus.PendingReturn)" class="mt20rpx rounded-16rpx bg-white p24rpx">
+    <view v-if="refundOrderInfo.applyType === 2 && (isLogisticsSubmitted || refundOrderInfo.returnMoneySts === refundStatus.PendingReturn)" class="mt20rpx rounded-16rpx bg-white p24rpx">
       <template v-if="isLogisticsSubmitted">
         <view>
           <view class="mt-20rpx text-28rpx font-semibold">

+ 56 - 27
src/subPack-film/submit-order/index.vue

@@ -87,37 +87,61 @@ function next() {
   showProtocol.value = false
 }
 
+async function handleH5PayResult(orderNumber: string) {
+  const isPaySuccess = await useUserStore().pollOrderPaySuccess(orderNumber)
+  if (isPaySuccess) {
+    await useUserStore().paySuccess('film-order', 'subPack-film/index/index')
+    return
+  }
+  useGlobalToast().show({ msg: '暂未查询到支付成功,请稍后在订单列表查看' })
+}
+
 async function pay() {
   loading.value = true
-  console.log(info.value.chooseSeatList)
-  query.value.fastTicket = isWithin45Minutes(new Date(), info.value.showTime)
-  query.value.movieOrderItems = info.value.chooseSeatList.map((item: any) => {
-    if (isWithin45Minutes(new Date(), info.value.showTime)) { // 如果在45分钟内,快速出票
-      return {
-        name: item.seatName,
-        price: item.fastPrice,
+  try {
+    query.value.fastTicket = isWithin45Minutes(new Date(), info.value.showTime)
+    query.value.movieOrderItems = info.value.chooseSeatList.map((item: any) => {
+      if (isWithin45Minutes(new Date(), info.value.showTime)) { // 如果在45分钟内,快速出票
+        return {
+          name: item.seatName,
+          price: item.fastPrice,
+        }
+      }
+      else {
+        return {
+          name: item.seatName,
+          price: item.ticketPrice,
+        }
+      }
+    })
+    const { data: orderNumber } = await Apis.film.addFilmOrder({ data: query.value })
+    const payMent = await useUserStore().getPayMent(orderNumber)
+    if (payMent.payType !== 'point') {
+      try {
+        // #ifdef MP-WEIXIN
+        const res = await useUserStore().handleCommonPayMent(orderNumber)
+        await useUserStore().getWxCommonPayment(res)
+        await useUserStore().paySuccess('film-order', 'subPack-film/index/index')
+        // #endif
+        // #ifdef H5
+        useUserStore().handleCommonWechatPay(orderNumber)
+        await handleH5PayResult(orderNumber)
+        // #endif
+      }
+      catch {
+        await useUserStore().payError('film-order', 'subPack-film/index/index')
       }
     }
     else {
-      return {
-        name: item.seatName,
-        price: item.ticketPrice,
-      }
+      await useUserStore().handleCommonPayMent(orderNumber)
+      await useUserStore().paySuccess('film-order', 'subPack-film/index/index')
     }
-  })
-  const { data: orderNumber } = await Apis.film.addFilmOrder({ data: query.value })
-  const res = await useUserStore().handleCommonPayMent(orderNumber)
-  loading.value = false
-  if (res.payType !== 1) {
-    // await getWxCommonPayment(res)
-    uni.showToast({
-      title: '当前只支持积分支付',
-      icon: 'none',
-      duration: 2000,
-    })
   }
-  else {
-    await useUserStore().paySuccess('film-order', 'subPack-film/index/index')
+  catch (error) {
+    console.error('支付失败:', error)
+  }
+  finally {
+    loading.value = false
   }
 }
 
@@ -139,9 +163,14 @@ async function getPoints() {
 getPoints()
 
 function usePoints() {
-  return (totalPrice.value * 100) >= info.value.points ? info.value.points : ((totalPrice.value * 10000) / 100)
+  return Math.round(totalPrice.value * 100) >= info.value.points ? info.value.points : Math.round(totalPrice.value * 100)
 }
 
+const actualPayPrice = computed(() => {
+  const result = (Math.round(totalPrice.value * 100) - usePoints()) / 100
+  return Math.max(0, Number(result.toFixed(2)))
+})
+
 onLoad((options) => {
   query.value = JSON.parse(options?.query)
   info.value = uni.getStorageSync('film-info')
@@ -255,7 +284,7 @@ onLoad((options) => {
           总计
         </view>
         <view class="total">
-          ¥{{ (totalPrice * 100 - usePoints()) / 100 }}
+          ¥{{ actualPayPrice }}
         </view>
       </view>
     </view>
@@ -294,7 +323,7 @@ onLoad((options) => {
     <view class="footer-box">
       <view class="price-box">
         <view class="total">
-          ¥{{ (totalPrice * 100 - usePoints()) / 100 }}
+          ¥{{ actualPayPrice }}
         </view>
         <view class="reduce">
           共减¥{{ usePoints() / 100 }}

+ 11 - 4
src/subPack-smqjh/components/film-orderList/film-orderList.vue

@@ -10,12 +10,19 @@ const _emit = defineEmits<{
 }>()
 
 async function handlePay(orderNumber: string) {
-  const res = await useUserStore().handleCommonPayMent(orderNumber)
-  if (res.payType !== 1) {
-    // await useUserStore().getWxCommonPayment(res, 1)
-    useGlobalToast().show('当前只支持积分支付')
+  const payMent = await useUserStore().getPayMent(orderNumber)
+  if (payMent?.payType !== 'point' && payMent) {
+    // #ifdef MP-WEIXIN
+    const res = await useUserStore().handleCommonPayMent(orderNumber)
+    await useUserStore().getWxCommonPayment(res)
+    _emit('refresh')
+    // #endif
+    // #ifdef H5
+    useUserStore().handleCommonWechatPay(orderNumber)
+    // #endif
   }
   else {
+    await useUserStore().handleCommonPayMent(orderNumber)
     _emit('refresh')
   }
 }

+ 46 - 13
src/subPack-videoRights/videoRightsSubmitOrder/videoRightsSubmitOrder.vue

@@ -1,7 +1,6 @@
 <script setup lang="ts">
 import { InputFormatUtil } from '../../utils/index'
 import { StaticUrl } from '@/config'
-import router from '@/router'
 
 definePage({
   name: 'video-rights-submit-order',
@@ -65,6 +64,15 @@ function validateRechargeAccount(formData: Api.videoRightsubmitOrder): {
   }
 }
 
+async function handleH5PayResult(orderNumber: string) {
+  const isPaySuccess = await useUserStore().pollOrderPaySuccess(orderNumber)
+  if (isPaySuccess) {
+    await useUserStore().paySuccess('video-rights-order-info', 'subPack-videoRights/commonTab/index')
+    return
+  }
+  useGlobalToast().show({ msg: '暂未查询到支付成功,请稍后在订单列表查看' })
+}
+
 function submitPay() {
   const validation = validateRechargeAccount(submitFrom.value)
   if (!validation.isValid) {
@@ -79,7 +87,28 @@ function submitPay() {
       useGlobalLoading().loading({ msg: '提交中...' })
       const res = await Apis.videoRight.orderCreate({ data: submitFrom.value })
       useGlobalLoading().close()
-      router.push({ name: 'video-rights-order-info', params: { orderNo: res.data, topUp: 'true' } })
+      const orderNumber = res.data?.orderNo as string
+      const payMent = await useUserStore().getPayMent(orderNumber)
+      if (payMent.payType !== 'point') {
+        try {
+          // #ifdef MP-WEIXIN
+          const payRes = await useUserStore().handleCommonPayMent(orderNumber)
+          await useUserStore().getWxCommonPayment(payRes)
+          await useUserStore().paySuccess('video-rights-order-info', 'subPack-videoRights/commonTab/index')
+          // #endif
+          // #ifdef H5
+          useUserStore().handleCommonWechatPay(orderNumber)
+          await handleH5PayResult(orderNumber)
+          // #endif
+        }
+        catch {
+          await useUserStore().payError('video-rights-order-info', 'subPack-videoRights/commonTab/index')
+        }
+      }
+      else {
+        await useUserStore().handleCommonPayMent(orderNumber)
+        await useUserStore().paySuccess('video-rights-order-info', 'subPack-videoRights/commonTab/index')
+      }
     },
   })
 }
@@ -174,20 +203,24 @@ function submitPay() {
           <view class="text-24rpx text-#AAA">
             共1件
           </view>
-          <view class="text-24rpx">
-            合计
-          </view>
-          <view class="text-#FF4D3A">
-            <text class="text-22rpx font-500">
-              ¥
-            </text>
-            <text class="text-32rpx font-bold">
-              {{ previewGoods?. price }}
-            </text>
+          <view>
+            <view class="text-#FF4D3A">
+              <text class="text-22rpx font-500">
+                ¥
+              </text>
+              <text class="text-32rpx font-bold">
+                {{ Math.max(0, Number(((previewGoods?.price * 100 - previewGoods?.availablePointsMoney * 100) / 100).toFixed(2))) }}
+              </text>
+            </view>
+            <view class="text-24rpx">
+              <text>积分抵扣</text> <text class="text-#FF4D3A">
+                -{{ previewGoods?.availablePointsMoney.toFixed(2) }}
+              </text>
+            </view>
           </view>
         </view>
         <wd-button @click="submitPay">
-          立即充值
+          立即支付
         </wd-button>
       </view>
     </view>

+ 1 - 1
src/subPack-xsb/confirmOrder/index.vue

@@ -454,7 +454,7 @@ async function handlePay() {
           ¥{{ orderInfo?.transfee }}
         </view>
       </view>
-      <view v-if="!isMemberGiftOrder && userMemberInfo.active" class="mb28rpx flex items-center justify-between text-28rpx">
+      <view v-if="!isMemberGiftOrder && userMemberInfo.active && orderInfo?.memberBenefitDesc && orderInfo?.memberDiscountAmount" class="mb28rpx flex items-center justify-between text-28rpx">
         <view>{{ orderInfo?.memberBenefitDesc }}</view>
         <view class="text-#FF4D3A font-semibold">
           -¥{{ orderInfo?.memberDiscountAmount }}