var E=Object.defineProperty,N=Object.defineProperties;var l=Object.getOwnPropertyDescriptors;var g=Object.getOwnPropertySymbols;var b=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var w=(e,a,o)=>a in e?E(e,a,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[a]=o,h=(e,a)=>{for(var o in a||(a={}))b.call(a,o)&&w(e,o,a[o]);if(g)for(var o of g(a))I.call(a,o)&&w(e,o,a[o]);return e},T=(e,a)=>N(e,l(a));import{m as f}from"./index.ebee95a8.js";import{s as P,r as u}from"./index.1e7db38c.js";import{o as c}from"./orderStatus.793062a7.js";import{h as n}from"./vendor.2bcdc9cf.js";const i=P.platformType==="STUDENT"?"/api-student":"/api-teacher",v=async(e,a)=>{const o=e.goodType;let t={};switch(o){case"LIVE":try{const r=await j(e.bizId),s=[];(r.planList||[]).forEach(d=>{const y=d.startTime||new Date,m=d.endTime||new Date;s.push({courseTime:`${n(y).format("YYYY-MM-DD")} ${n(y).format("HH:mm")}~${n(m).format("HH:mm")}`,coursePlan:d.plan,id:d.courseId})}),t={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:s}}catch(r){throw new Error(r.message)}break;case"PRACTICE":{const r=JSON.parse(e.bizContent);t=T(h({},r),{teacherName:e.username,starGrade:e.starGrade,avatar:e.avatar});break}case"VIDEO":{try{const r=await C(e.bizId),{lessonGroup:s,detailList:p}=r;t={orderType:e.goodType,goodName:e.goodName,courseGroupId:s.id,courseGroupName:s.lessonName,coursePrice:s.lessonPrice,teacherName:s.username,teacherId:s.teacherId,avatar:s.avatar,courseInfo:p}}catch(r){throw new Error(r.message)}break}case"VIP":try{const r=await L(e.id);t={orderType:e.goodType,goodName:e.goodName,id:e.id,title:f[r.period]||"",price:(a==null?void 0: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 B(e.bizId);t=h({orderType:e.goodType,goodName:e.goodName},r)}catch(r){throw new Error(r.message)}break;case"ACTI_REGIST":try{const r=await O(e.bizId);t={orderType:e.goodType,goodsName:r.activityName,activityId:r.id,actualPrice:r.registrationPrice}}catch(r){throw new Error(r.message)}break}t.orderType=o,t.goodName=e.goodName,c.orderObject.orderList.push(t)},C=async e=>{try{return(await u.get(`${i}/videoLesson/selectVideoLesson`,{params:{groupId:e}})).data}catch{throw new Error("\u83B7\u53D6\u89C6\u9891\u8BFE\u8BE6\u60C5\u5931\u8D25")}},j=async e=>{try{return(await u.get(`${i}/courseGroup/queryLiveCourseInfo`,{params:{groupId:e}})).data}catch{throw new Error("\u83B7\u53D6\u76F4\u64AD\u8BFE\u8BE6\u60C5\u5931\u8D25")}},L=async e=>{try{return(await u.get(`${i}/vipCardRecord/detail/`+e)).data||[]}catch{throw new Error("\u83B7\u53D6\u4F1A\u5458\u8BE6\u60C5\u5931\u8D25")}},B=async e=>{try{return(await u.get(`${i}/music/sheet/detail/${e}`)).data}catch{throw new Error("\u83B7\u53D6\u66F2\u76EE\u8BE6\u60C5\u5931\u8D25")}},O=async e=>{try{return(await u.post(`${i}/open/activity/info/${e}`)).data}catch{throw new Error("\u83B7\u53D6\u66F2\u76EE\u8BE6\u60C5\u5931\u8D25")}},F=(e,a)=>{const{orderNo:o,actualPrice:t,orderDesc:r,orderName:s,orderType:p,orderDetailList:d,couponAmount:y,discountPrice:m}=e;c.orderObject.orderType=p,c.orderObject.orderName=s,c.orderObject.orderDesc=r,c.orderObject.actualPrice=t,c.orderObject.orderNo=o,c.orderObject.discountPrice=m,c.orderObject.orderList=[];try{d.forEach(async D=>{await v(D,{couponAmount:y,discountPrice:m})}),a&&a()}catch{}};export{B as g,F as t};
