1 |
- import{g as p,y as l,w as s}from"./ResizeObserver.es.b7226882.js";import{o as d}from"./orderStatus.1ca966f0.js";const N=p.platformType==="STUDENT"?"/api-student":"/api-teacher",b=(e,o,c)=>{const t=e||new Date;let r=s(new Date).format("YYYY-MM-DD");return o==="MONTH"?r=s(t).add(1,"month").format("YYYY-MM-DD"):o==="QUARTERLY"?r=s(t).add(3,"month").format("YYYY-MM-DD"):o==="YEAR_HALF"?r=s(t).add(6,"month").format("YYYY-MM-DD"):o==="YEAR"&&(r=s(t).add(1,"year").format("YYYY-MM-DD")),{startTime:c?s(t).add(1,"day").format("YYYY-MM-DD"):s(t).format("YYYY-MM-DD"),endTime:r}},I=async(e,o)=>{const c=e.goodType;let t={};switch(c){case"LIVE":case"GROUP":try{const r=await v(e.bizId),a=[];(r.planList||[]).forEach(u=>{const i=u.startTime||new Date,y=u.endTime||new Date;a.push({courseTime:`${s(i).format("YYYY-MM-DD")} ${s(i).format("HH:mm")}~${s(y).format("HH:mm")}`,coursePlan:u.plan,id:u.courseId})}),t={orderType:e.goodType,goodName:e.goodName,courseGroupId:r.courseGroupId,courseGroupName:r.courseGroupName,coursePrice:r.coursePrice,price:r.coursePrice,teacherName:r.userName||`\u6E38\u5BA2${r.teacherId||""}`,teacherId:r.teacherId,avatar:r.avatar,courseInfo:a}}catch(r){throw new Error(r.message)}break;case"PRACTICE":case"VIP_COURSE":{t={...JSON.parse(e.bizContent),teacherName:e.username,starGrade:e.starGrade,avatar:e.avatar};break}case"VIDEO":{try{const r=await P(e.bizId),{lessonGroup:a,detailList:n}=r;t={orderType:e.goodType,goodName:e.goodName,courseGroupId:a.id,courseGroupName:a.lessonName,coursePrice:a.lessonPrice,price:a.lessonPrice,teacherName:a.username,teacherId:a.teacherId,avatar:a.avatar,courseInfo:n}}catch(r){throw new Error(r.message)}break}case"VIP":case"SVIP":try{let r=(o==null?void 0:o.expectPrice)||e.actualPrice;o!=null&&o.couponAmount?r=Number((((o==null?void 0:o.expectPrice)-(o.couponAmount-o.discountPrice))/e.goodNum).toFixed(2)):r=Number(r/e.goodNum).toFixed(2);let a=new Date;e.goodType==="SVIP"?a=s(p.user.data.userVip.svipEndDate||new Date).toDate():e.goodType==="VIP"&&(a=s(p.user.data.userVip.vipEndDate||p.user.data.userVip.svipEndDate||new Date).toDate());let n=new Date;e.period==="MONTH"?n=s(a).add(1*e.goodNum,"month").toDate():e.period==="QUARTERLY"?n=s(a).add(3*e.goodNum,"month").toDate():e.period==="YEAR_HALF"?n=s(a).add(6*e.goodNum,"month").toDate():e.period==="YEAR"&&(n=s(a).add(1*e.goodNum,"year").toDate()),t={orderType:e.goodType,goodName:e.goodName,num:e.goodNum,id:e.id,title:e.goodName||"",vipEndDays:e.vipEndDays,price:r,period:e.period,startTime:s(a).format("YYYY-MM-DD"),endTime:s(n).format("YYYY-MM-DD"),activityList:[],discountCardFlag:p.user.data.discountCardFlag,discountEndTime:p.user.data.discountEndTime,discountStartTime:p.user.data.discountStartTime},t.activityList=(e.activityList||[]).map(u=>{const{goodType:i,goodName:y,goodNum:D,giftFlag:m,bizId:E,period:h}=u;return i==="DISCOUNT"?{goodType:i,goodName:y,goodNum:D,bizContent:E,giftFlag:m,vipEndDays:null,goodsNum:D,unit:h}:{goodType:i,goodName:y,goodNum:D,bizContent:E,giftFlag:m,vipEndDays:null,goodsNum:D,unit:h}})}catch(r){throw new Error(r.message)}break;case"DISCOUNT":{const r=p.user.data||{},a=r.discountCardFlag?s(r.discountEndTime||new Date).toDate():new Date;t={orderType:e.goodType,goodName:e.goodName,num:e.goodNum,id:e.id,title:e.goodName||"",price:e.expectPrice,...b(a,e.period,r.discountCardFlag)}}break;case"MUSIC":try{const r=await C(e.bizId);t={orderType:e.goodType,goodName:e.goodName,...r}}catch(r){throw new Error(r.message)}break;case"ALBUM":try{const r=await L(e.bizId);t={orderType:e.goodType,goodName:e.goodName,...r}}catch(r){throw new Error(r.message)}break;case"ACTI_REGIST":try{const r=await M(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=c,t.goodName=e.goodName,d.orderObject.orderList.push(t)},P=async e=>{try{return(await l.get(`${N}/videoLesson/selectVideoLesson`,{params:{groupId:e}})).data}catch{throw new Error("\u83B7\u53D6\u89C6\u9891\u8BFE\u8BE6\u60C5\u5931\u8D25")}},v=async e=>{try{return(await l.get(`${N}/courseGroup/queryLiveCourseInfo`,{params:{groupId:e}})).data}catch{throw new Error("\u83B7\u53D6\u76F4\u64AD\u8BFE\u8BE6\u60C5\u5931\u8D25")}},C=async e=>{try{return(await l.get(`${N}/music/sheet/detail/${e}`)).data}catch{throw new Error("\u83B7\u53D6\u66F2\u76EE\u8BE6\u60C5\u5931\u8D25")}},M=async e=>{try{return(await l.post(`${N}/open/activity/info/${e}`)).data}catch{throw new Error("\u83B7\u53D6\u66F2\u76EE\u8BE6\u60C5\u5931\u8D25")}},L=async e=>{try{return(await l.post(`${N}/music/album/detail`,{data:{id:e}})).data}catch{throw new Error("\u83B7\u53D6\u4E13\u8F91\u8BE6\u60C5\u5931\u8D25")}},O=()=>{const e=d.orderObject.orderList||[],o=e.findIndex(c=>c.orderType==="DISCOUNT");if(o!==-1){const c=e.splice(o,1);d.orderObject.orderList=[...e,...c]}},j=async(e,o)=>{const{orderNo:c,actualPrice:t,orderDesc:r,orderName:a,orderType:n,orderDetailList:u,couponAmount:i,cardDiscountPrice:y,discountPrice:D,paymentConfig:m,paymentVendor:E,paymentVersion:h,activityType:w,expectPrice:f}=e;d.orderObject.orderType=n,d.orderObject.orderName=a,d.orderObject.orderDesc=r,d.orderObject.actualPrice=t,d.orderObject.orderNo=c,d.orderObject.discountCardPrice=y,d.orderObject.discountPrice=D,d.orderObject.couponAmount=i,d.orderObject.paymentConfig={...m,paymentVendor:E,paymentVersion:h},d.orderObject.orderList=[];try{const T=[],Y=[];u.map(g=>{g.giftFlag?Y.push(g):T.push(g)}),T[0]&&(T[0].activityList=Y);for(let g=0;g<T.length;g++)await I(T[g],{couponAmount:i,discountPrice:D,expectPrice:f,activityType:w}),O();o&&o()}catch{}};export{C as g,j as t};
|