|
@@ -1,5 +1,7 @@
|
|
|
package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.GoodTypeEnum;
|
|
|
+
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -12,6 +14,7 @@ import com.yonge.cooleshow.biz.dal.dao.CourseGroupDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.CheckCourseTimeDto;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto.CoursePlanDto;
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.req.OrderReq;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.search.LiveCourseGroupSearch;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.search.LiveCourseGroupStudentSearch;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.*;
|
|
@@ -22,7 +25,9 @@ import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.support.PageUtil;
|
|
|
import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.*;
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.res.OrderCreateRes;
|
|
|
import com.yonge.cooleshow.common.constant.SysConfigConstant;
|
|
|
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
import com.yonge.cooleshow.common.exception.BizException;
|
|
|
import com.yonge.cooleshow.common.page.PageInfo;
|
|
|
import com.yonge.toolset.utils.date.DateUtil;
|
|
@@ -488,17 +493,14 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
/**
|
|
|
* 学生购买直播课程组
|
|
|
*
|
|
|
- * @param param 传入参数
|
|
|
- * <p> - groupId 直播课程组id
|
|
|
- * <p> - studentId 学员id
|
|
|
- * <p> - price 购买金额
|
|
|
+ * @param orderReqInfo 订单信息
|
|
|
*/
|
|
|
- public void buyLiveCourse(Map<String, Object> param) {
|
|
|
- Long studentId = WrapperUtil.toLong(param, "studentId", "学员id不能为空!");
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public HttpResponseResult<OrderCreateRes> buyLiveCourse(OrderReq.OrderReqInfo orderReqInfo) {
|
|
|
+ Map<String, Object> param = WrapperUtil.toMap(orderReqInfo.getBizContent());
|
|
|
Long groupId = WrapperUtil.toLong(param, "groupId", "课程组id不能为空!");
|
|
|
- String priceStr = WrapperUtil.toStr(param, "price", "购买金额不能为空!");
|
|
|
- //获取传入金额
|
|
|
- BigDecimal buyPrice = new BigDecimal(priceStr).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ Long studentId = orderReqInfo.getUserId();
|
|
|
//校验学生信息
|
|
|
getSysUser(studentId);
|
|
|
//课程组信息
|
|
@@ -509,38 +511,47 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
if (Objects.isNull(courseGroup)) {
|
|
|
throw new BizException("课程组不存在!");
|
|
|
}
|
|
|
- //校验购买金额是否正确 - 如后期加入优惠券之类的要先判断优惠券是否正确,并减去优惠券金额再比较
|
|
|
- if (buyPrice.compareTo(courseGroup.getCoursePrice()) != 0) {
|
|
|
- throw new BizException("购买金额不正确!");
|
|
|
- }
|
|
|
//课程信息
|
|
|
List<CourseSchedule> courseList = courseScheduleService.list(Wrappers.<CourseSchedule>lambdaQuery()
|
|
|
- .eq(CourseSchedule::getCourseGroupId, groupId)
|
|
|
- );
|
|
|
+ .eq(CourseSchedule::getCourseGroupId, groupId));
|
|
|
if (CollectionUtils.isEmpty(courseList)) {
|
|
|
throw new BizException("课程组课程不存在!");
|
|
|
}
|
|
|
//校验购买的课程组每节课时间是否和自己的课时冲突
|
|
|
batchCheckStudentCourseTime(studentId, courseList, CourseSchedule::getStartTime, CourseSchedule::getEndTime);
|
|
|
//返回的数据 有用后面aftet的方法使用
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- result.put("courseGroup", courseGroup);
|
|
|
- result.put("courseList", courseList);
|
|
|
- result.put("studentId", studentId);
|
|
|
-
|
|
|
+ Map<String, Object> bizContent = new HashMap<>();
|
|
|
+ bizContent.put("courseGroup", courseGroup);
|
|
|
+ bizContent.put("courseList", courseList);
|
|
|
+ bizContent.put("studentId", studentId);
|
|
|
+ OrderCreateRes orderCreateRes = new OrderCreateRes();
|
|
|
+ orderCreateRes.setRes(true);
|
|
|
+ orderCreateRes.setMerchId(courseGroup.getTeacherId());
|
|
|
+ orderCreateRes.setBizId(courseGroup.getId());
|
|
|
+ orderCreateRes.setOriginalPrice(courseGroup.getCoursePrice());
|
|
|
+ orderCreateRes.setExpectPrice(courseGroup.getCoursePrice());
|
|
|
+ orderCreateRes.setBizParam(bizContent);
|
|
|
+ orderCreateRes.setGoodNum(courseGroup.getCourseNum());
|
|
|
+ orderCreateRes.setGoodType(GoodTypeEnum.LIVE);
|
|
|
+
|
|
|
+ HttpResponseResult<OrderCreateRes> httpResponseResult = new HttpResponseResult<>();
|
|
|
+ httpResponseResult.setData(orderCreateRes);
|
|
|
+ return httpResponseResult;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 待订单创建完毕后继续后续操作
|
|
|
*
|
|
|
- * @param param 传入参数
|
|
|
- * <p> - courseList 课程列表
|
|
|
- * <p> - studentId 学员id
|
|
|
- * <p> - courseGroup 直播课程组信息
|
|
|
- * <p> - orderNo 订单号
|
|
|
+ * @param afterParam 传入参数
|
|
|
+ * <p> - courseList 课程列表
|
|
|
+ * <p> - studentId 学员id
|
|
|
+ * <p> - courseGroup 直播课程组信息
|
|
|
*/
|
|
|
- public void buyLiveCourseAfter(Map<String, Object> param) {
|
|
|
- String orderNo = WrapperUtil.toStr(param, "orderNo", "订单号不能为空!");
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void buyLiveCourseAfter(UserOrderDetailVo afterParam) {
|
|
|
+ Map<String, Object> param = WrapperUtil.toMap(afterParam.getBizParam());
|
|
|
+ String orderNo = afterParam.getOrderNo();
|
|
|
Long studentId = (Long) param.get("studentId");
|
|
|
List<CourseSchedule> courseList = (List<CourseSchedule>) param.get("courseList");
|
|
|
CourseGroup courseGroup = (CourseGroup) param.get("courseGroup");
|