import{m as T}from"./index.68f32c85.js";import{g as l,w as u,u as n}from"./index.394decd7.js";import{o as s}from"./orderStatus.535346ee.js";const d=l.platformType==="STUDENT"?"/api-student":"/api-teacher",D=async(e,a)=>{const i=e.goodType;let o={};switch(i){case"LIVE":try{const r=await b(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 N(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 I(e.id);o={orderType:e.goodType,goodName:e.goodName,id:e.id,title:T[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 f(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 C(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 P(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)},N=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")}},b=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")}},I=async e=>{try{return(await u.get(`${d}/vipCardRecord/detail/`+e)).data||[]}catch{throw new Error("\u83B7\u53D6\u4F1A\u5458\u8BE6\u60C5\u5931\u8D25")}},f=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")}},P=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")}},C=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")}},O=(e,a)=>{const{orderNo:i,actualPrice:o,orderDesc:r,orderName:t,orderType:p,orderDetailList:c,couponAmount:y,discountPrice:g,paymentConfig:m,paymentVendor:w,paymentVersion:h}=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.paymentConfig={...m,paymentVendor:w,paymentVersion:h},s.orderObject.orderList=[];try{c.forEach(async E=>{await D(E,{couponAmount:y,discountPrice:g})}),a&&a()}catch{}};export{f as g,O as t};