Explorar o código

Merge branch 'iteration-20241126'

lex-xin hai 3 meses
pai
achega
8d2a14f7e4

+ 1 - 2
src/student/discount-card/index.tsx

@@ -82,7 +82,6 @@ export default defineComponent({
             data: { goodType: 'DISCOUNT' }
           }
         )
-        console.log(resPadding, 'resPadding')
         if (resPadding?.data?.id) {
           state.orderVisible = true
           state.orderDetail = resPadding.data || {}
@@ -121,7 +120,7 @@ export default defineComponent({
             salePrice: state.discountDetail.salePrice,
             period: state.discountDetail.period,
             price: state.discountDetail.salePrice,
-            startTime: dayjs(startTime).format('YYYY-MM-DD'),
+            startTime: userInfo.value.discountCardFlag ? dayjs(startTime).add(1, 'day').format('YYYY-MM-DD') : dayjs(startTime).format('YYYY-MM-DD'),
             endTime: dayjs(endTime).format('YYYY-MM-DD')
           }
         ]

+ 2 - 1
src/student/teacher-dependent/teacher-style/index.module.less

@@ -99,7 +99,7 @@
 
     .teUserName {
       padding-right: 6px;
-      margin-right: 6px;
+      // margin-right: 6px;
       max-width: 65px;
       // &::after {
       //   content: '|';
@@ -108,6 +108,7 @@
     }
   }
   .teUserNum {
+    font-size: 12px;
     color: #999999;
   }
 }

+ 1 - 1
src/student/trade/tradeOrder.ts

@@ -225,7 +225,7 @@ export const formatOrderDetail = async (item: any, amount?: IAmount) => {
     case 'DISCOUNT':
       {
         const users = state.user.data || {}
-        const endTime = users.discountCardFlag ? dayjs(users.discountEndTime || new Date()).add(1, 'day').toDate() : new Date()
+        const endTime = users.discountCardFlag ? dayjs(users.discountEndTime || new Date()).toDate() : new Date()
         tempList = {
           orderType: item.goodType,
           goodName: item.goodName,

+ 3 - 2
src/tenant/trade/index.tsx

@@ -82,7 +82,7 @@ export default defineComponent({
           result.rows?.forEach((item: any) => {
             const orderDetails = item.orderDetailList || []
             orderDetails.forEach((item: any) => {
-              const bizContent = item.bizContent
+              const bizContent = item.goodType === 'DISCOUNT' ?  item.bizContent :  item.bizContent
                 ? JSON.parse(item.bizContent)
                 : {}
               if (bizContent && bizContent.purchaseType) {
@@ -110,7 +110,8 @@ export default defineComponent({
           state.params.page = result.pageNo + 1
           state.dataShow = state.list.length > 0
         }
-      } catch {
+      } catch(e) {
+        console.log(e, 'e')
         state.dataShow = false
         state.finished = true
       }

+ 1 - 0
src/tenant/trade/tradeOrder.ts

@@ -256,6 +256,7 @@ export const getTenantAlbumDetail = async (id: any) => {
     const res = await request.post(
       `${apiSuffix}/userTenantAlbumRecord/detail`,
       {
+        requestType: 'form',
         data: { albumId: id }
       }
     )

+ 33 - 8
src/views/order-detail/index.tsx

@@ -35,7 +35,7 @@ import { moneyFormat } from '@/helpers/utils'
 import OrderPinao from './order-pinao'
 import { getMusicDetail } from '@/student/trade/tradeOrder'
 import OrderActive from './order-active'
-import UseCoupon from './use-coupons'
+import UseCoupon, { couponToOrderTypeEnum } from './use-coupons'
 import OrderAlbum from './order-album'
 import { useRect } from '@vant/use'
 import QrcodePayment from './qrcode-payment'
@@ -454,15 +454,39 @@ export default defineComponent({
     },
     onCouponSelect(item: any) {
       let discountCount = 0
-      ;(item || []).forEach((item: any) => {
-        discountCount += Number(item.discountPrice)
+      let universalCount = 0
+      const tempPrice: any = {}
+      this.orderGoodsType.forEach((type: any) => {
+        tempPrice[type.orderType] = type.price
+      })
+      ;(item || []).forEach((child: any) => {
+        if(child.couponCategory === 'UNIVERSAL') {
+          universalCount += Number(child.discountPrice)
+        } else {
+          const tempCoupon = couponToOrderTypeEnum[child.couponCategory]
+          let price =  tempPrice[tempCoupon] - Number(child.discountPrice)
+          // 折扣金额
+          if(price >= 0) {
+            discountCount += Number(child.discountPrice)
+          } else {
+            discountCount += Number(tempPrice[tempCoupon])
+          }
+          tempPrice[tempCoupon] = price >= 0 ? price : 0
+        }
       })
 
+      // 获取金额
+      let tempAllAmount = 0
+      for(let i in tempPrice) {
+        tempAllAmount += tempPrice[i]
+      }
+      // 判断 通用券的金额是否大于订单的金额 
+      if(universalCount >= tempAllAmount) {
+        universalCount = tempAllAmount
+      }
+
       const lastAmount = Number(
-        numberToTwoUp(
-          Number(this.orderAmount) -
-            orderStatus.orderObject.discountCardPrice -
-            Number(discountCount)
+        numberToTwoUp(tempAllAmount - Number(universalCount)
         )
       )
       this.orderPrice = lastAmount >= 0 ? lastAmount : 0
@@ -471,7 +495,8 @@ export default defineComponent({
         return item.couponIssueId
       })
       orderStatus.orderObject.couponId = couponIds.join(',') || ''
-      orderStatus.orderObject.couponDiscountPrice = discountCount
+      orderStatus.orderObject.couponDiscountPrice = discountCount + universalCount
+
     },
     onConfirm(val: any) {
       // debugger

+ 21 - 0
src/views/order-detail/use-coupons/index.tsx

@@ -23,6 +23,27 @@ export const couponEnum = {
   ALBUM: 'ALBUM'
 }
 
+
+/*
+ * 优惠券类型对应订单类型
+ */
+export const couponToOrderTypeEnum = {
+  UNIVERSAL: 'UNIVERSAL',
+  VIP: 'VIP',
+  SVIP: 'SVIP',
+  PIANO: 'PIANO_ROOM',
+  MALL: 'GOODS',
+  MUSIC: 'MUSIC',
+  VIP_COURSE: 'VIP_COURSE',
+  DISCOUNT: 'DISCOUNT',
+  PRACTICE: 'SPARRING',
+  LIVE: 'LIVE',
+  VIDEO: 'VIDEO',
+  ALBUM: 'ALBUM'
+}
+
+
+
 export default defineComponent({
   name: 'use-conpon',
   props: {