tradeOrder.d6463377.js 3.4 KB

1
  1. import{m as h}from"./index.68f32c85.js";import{g as m,w as u,u as n}from"./index.e6d6174e.js";import{o as s}from"./orderStatus.fea01d83.js";const d=m.platformType==="STUDENT"?"/api-student":"/api-teacher",E=async(e,a)=>{const i=e.goodType;let o={};switch(i){case"LIVE":try{const r=await l(e.bizId),t=[];(r.planList||[]).forEach(c=>{const y=c.startTime||new Date,g=c.endTime||new Date;t.push({courseTime:`${n(y).format("YYYY-MM-DD")} ${n(y).format("HH:mm")}~${n(g).format("HH:mm")}`,coursePlan:c.plan,id:c.courseId})}),o={orderType:e.goodType,goodName:e.goodName,courseGroupId:r.courseGroupId,courseGroupName:r.courseGroupName,coursePrice:r.coursePrice,teacherName:r.userName||`\u6E38\u5BA2${r.teacherId||""}`,teacherId:r.teacherId,avatar:r.avatar,courseInfo:t}}catch(r){throw new Error(r.message)}break;case"PRACTICE":{o={...JSON.parse(e.bizContent),teacherName:e.username,starGrade:e.starGrade,avatar:e.avatar};break}case"VIDEO":{try{const r=await T(e.bizId),{lessonGroup:t,detailList:p}=r;o={orderType:e.goodType,goodName:e.goodName,courseGroupId:t.id,courseGroupName:t.lessonName,coursePrice:t.lessonPrice,teacherName:t.username,teacherId:t.teacherId,avatar:t.avatar,courseInfo:p}}catch(r){throw new Error(r.message)}break}case"VIP":try{const r=await D(e.id);o={orderType:e.goodType,goodName:e.goodName,id:e.id,title:h[r.period]||"",price:a!=null&&a.couponAmount?Number((r.salePrice-a.couponAmount+a.discountPrice).toFixed(2)):r.salePrice||e.actualPrice,startTime:n(r.startTime).format("YYYY-MM-DD"),endTime:n(r.endTime).format("YYYY-MM-DD")}}catch(r){throw new Error(r.message)}break;case"MUSIC":try{const r=await N(e.bizId);o={orderType:e.goodType,goodName:e.goodName,...r}}catch(r){throw new Error(r.message)}break;case"ALBUM":{console.log(e);try{const r=await I(e.bizId);o={orderType:e.goodType,goodName:e.goodName,...r}}catch(r){throw new Error(r.message)}}break;case"ACTI_REGIST":try{const r=await b(e.bizId);o={orderType:e.goodType,goodsName:r.activityName,activityId:r.id,actualPrice:r.registrationPrice}}catch(r){throw new Error(r.message)}break}o.orderType=i,o.goodName=e.goodName,s.orderObject.orderList.push(o)},T=async e=>{try{return(await u.get(`${d}/videoLesson/selectVideoLesson`,{params:{groupId:e}})).data}catch{throw new Error("\u83B7\u53D6\u89C6\u9891\u8BFE\u8BE6\u60C5\u5931\u8D25")}},l=async e=>{try{return(await u.get(`${d}/courseGroup/queryLiveCourseInfo`,{params:{groupId:e}})).data}catch{throw new Error("\u83B7\u53D6\u76F4\u64AD\u8BFE\u8BE6\u60C5\u5931\u8D25")}},D=async e=>{try{return(await u.get(`${d}/vipCardRecord/detail/`+e)).data||[]}catch{throw new Error("\u83B7\u53D6\u4F1A\u5458\u8BE6\u60C5\u5931\u8D25")}},N=async e=>{try{return(await u.get(`${d}/music/sheet/detail/${e}`)).data}catch{throw new Error("\u83B7\u53D6\u66F2\u76EE\u8BE6\u60C5\u5931\u8D25")}},b=async e=>{try{return(await u.post(`${d}/open/activity/info/${e}`)).data}catch{throw new Error("\u83B7\u53D6\u66F2\u76EE\u8BE6\u60C5\u5931\u8D25")}},I=async e=>{try{return(await u.post(`${d}/music/album/detail`,{data:{id:e}})).data}catch{throw new Error("\u83B7\u53D6\u4E13\u8F91\u8BE6\u60C5\u5931\u8D25")}},v=(e,a)=>{const{orderNo:i,actualPrice:o,orderDesc:r,orderName:t,orderType:p,orderDetailList:c,couponAmount:y,discountPrice:g}=e;s.orderObject.orderType=p,s.orderObject.orderName=t,s.orderObject.orderDesc=r,s.orderObject.actualPrice=o,s.orderObject.orderNo=i,s.orderObject.discountPrice=g,s.orderObject.orderList=[];try{c.forEach(async w=>{await E(w,{couponAmount:y,discountPrice:g})}),a&&a()}catch{}};export{N as g,v as t};