|
@@ -1,19 +1,51 @@
|
|
|
+import request from '@/helpers/request'
|
|
|
import { orderStatus } from '@/views/order-detail/orderStatus'
|
|
|
+import dayjs from 'dayjs'
|
|
|
// LIVE: '直播课',
|
|
|
// PRACTICE: '陪练课',
|
|
|
// VIDEO: '视频课',
|
|
|
// VIP: '开通会员',
|
|
|
// MUSIC: '单曲点播'
|
|
|
-export const formatOrderDetail = (item: any) => {
|
|
|
+export const formatOrderDetail = async (item: any) => {
|
|
|
const type = item.goodType
|
|
|
- console.log(type)
|
|
|
let tempList: any = {}
|
|
|
+
|
|
|
switch (type) {
|
|
|
case 'LIVE':
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ const live = await getLiveDetail(item.bizId)
|
|
|
+ const courseInfo: any[] = []
|
|
|
+ const coursePlanList = live.planList || []
|
|
|
+ coursePlanList.forEach((item: any) => {
|
|
|
+ const startTime = item.startTime || new Date()
|
|
|
+ const endTime = item.endTime || new Date()
|
|
|
+ courseInfo.push({
|
|
|
+ courseTime: `${dayjs(startTime).format('YYYY-MM-DD')} ${dayjs(
|
|
|
+ startTime
|
|
|
+ ).format('HH:mm')}~${dayjs(endTime).format('HH:mm')}`,
|
|
|
+ coursePlan: item.plan,
|
|
|
+ id: item.courseId
|
|
|
+ })
|
|
|
+ })
|
|
|
+ tempList = {
|
|
|
+ orderType: item.goodType,
|
|
|
+ goodsName: item.goodName,
|
|
|
+ courseGroupId: live.courseGroupId,
|
|
|
+ courseGroupName: live.courseGroupName,
|
|
|
+ coursePrice: live.coursePrice,
|
|
|
+ teacherName: live.teacherName || `游客${live.teacherId || ''}`,
|
|
|
+ teacherId: live.teacherId,
|
|
|
+ avatar: live.avatar,
|
|
|
+ courseInfo
|
|
|
+ }
|
|
|
+ } catch (e: any) {
|
|
|
+ throw new Error(e.message)
|
|
|
+ }
|
|
|
+ }
|
|
|
break
|
|
|
case 'PRACTICE': {
|
|
|
const bizContent: any = JSON.parse(item.bizContent)
|
|
|
- console.log(bizContent)
|
|
|
tempList = {
|
|
|
...bizContent,
|
|
|
teacherName: item.username,
|
|
@@ -22,17 +54,122 @@ export const formatOrderDetail = (item: any) => {
|
|
|
}
|
|
|
break
|
|
|
}
|
|
|
- case 'VIDEO':
|
|
|
+ case 'VIDEO': {
|
|
|
+ try {
|
|
|
+ const res = await getVideoDetail(item.bizId)
|
|
|
+ const { lessonGroup, detailList } = res
|
|
|
+ tempList = {
|
|
|
+ orderType: item.goodType,
|
|
|
+ goodsName: item.goodName,
|
|
|
+ courseGroupId: lessonGroup.id,
|
|
|
+ courseGroupName: lessonGroup.lessonName,
|
|
|
+ coursePrice: lessonGroup.lessonPrice,
|
|
|
+ teacherName: lessonGroup.username,
|
|
|
+ teacherId: lessonGroup.teacherId,
|
|
|
+ avatar: lessonGroup.avatar,
|
|
|
+ courseInfo: detailList
|
|
|
+ }
|
|
|
+ } catch (e: any) {
|
|
|
+ throw new Error(e.message)
|
|
|
+ }
|
|
|
break
|
|
|
+ }
|
|
|
case 'VIP':
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ const res = await getVipDetail()
|
|
|
+ const buyObject = res.find((member: any) => member.id === item.bizId)
|
|
|
+ tempList = {
|
|
|
+ orderType: item.goodType,
|
|
|
+ goodsName: item.goodName,
|
|
|
+ id: buyObject.id,
|
|
|
+ title: buyObject.title,
|
|
|
+ price: buyObject.salePrice
|
|
|
+ // startTime: dayjs(startTime).format('YYYY-MM-DD'),
|
|
|
+ // endTime: dayjs(endTime).format('YYYY-MM-DD')
|
|
|
+ }
|
|
|
+ } catch (e: any) {
|
|
|
+ throw new Error(e.message)
|
|
|
+ }
|
|
|
+ }
|
|
|
break
|
|
|
case 'MUSIC':
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ const res = await getMusicDetail(item.bizId)
|
|
|
+ tempList = {
|
|
|
+ orderType: item.goodType,
|
|
|
+ goodsName: item.goodName,
|
|
|
+ ...res
|
|
|
+ }
|
|
|
+ } catch (e: any) {
|
|
|
+ throw new Error(e.message)
|
|
|
+ }
|
|
|
+ }
|
|
|
break
|
|
|
}
|
|
|
tempList.orderType = type
|
|
|
tempList.goodsName = item.goodsName
|
|
|
orderStatus.orderObject.orderList.push(tempList)
|
|
|
}
|
|
|
+// 获取视频课详情
|
|
|
+export const getVideoDetail = async (groupId: any) => {
|
|
|
+ try {
|
|
|
+ const res = await request.get(
|
|
|
+ '/api-student/videoLesson/selectVideoLesson',
|
|
|
+ {
|
|
|
+ params: {
|
|
|
+ groupId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ return res.data
|
|
|
+ } catch {
|
|
|
+ throw new Error('获取视频课详情失败')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 获取直播课详情
|
|
|
+export const getLiveDetail = async (groupId: any) => {
|
|
|
+ try {
|
|
|
+ const res = await request.get(
|
|
|
+ '/api-student/courseGroup/queryLiveCourseInfo',
|
|
|
+ {
|
|
|
+ params: {
|
|
|
+ groupId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ return res.data
|
|
|
+ } catch {
|
|
|
+ throw new Error('获取直播课详情失败')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 获取会员详情
|
|
|
+export const getVipDetail = async () => {
|
|
|
+ try {
|
|
|
+ const setting = await request.post(
|
|
|
+ '/api-student/memberPriceSettings/list',
|
|
|
+ {
|
|
|
+ data: {}
|
|
|
+ }
|
|
|
+ )
|
|
|
+ return setting.data || []
|
|
|
+ } catch {
|
|
|
+ throw new Error('获取会员详情失败')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 获取曲目详情
|
|
|
+export const getMusicDetail = async (id: any) => {
|
|
|
+ try {
|
|
|
+ const res = await request.get(`/api-student/music/sheet/detail/${id}`)
|
|
|
+ return res.data
|
|
|
+ } catch {
|
|
|
+ throw new Error('获取曲目详情失败')
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
export const tradeOrder = (result: any, callBack?: any) => {
|
|
|
const {
|
|
@@ -50,9 +187,13 @@ export const tradeOrder = (result: any, callBack?: any) => {
|
|
|
orderStatus.orderObject.orderNo = orderNo
|
|
|
orderStatus.orderObject.actualPrice = actualPrice
|
|
|
orderStatus.orderObject.orderList = []
|
|
|
- orderDetailList.forEach((item: any) => {
|
|
|
- formatOrderDetail(item)
|
|
|
- })
|
|
|
- console.log(orderStatus.orderObject)
|
|
|
- callBack && callBack()
|
|
|
+ try {
|
|
|
+ orderDetailList.forEach(async (item: any) => {
|
|
|
+ await formatOrderDetail(item)
|
|
|
+ })
|
|
|
+ // console.log(orderStatus.orderObject, 'orderStatus.orderObject')
|
|
|
+ callBack && callBack()
|
|
|
+ } catch {
|
|
|
+ //
|
|
|
+ }
|
|
|
}
|