|
@@ -525,7 +525,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public HttpResponseResult<OrderCreateRes> buyLiveCourse(OrderReq.OrderReqInfo orderReqInfo) {
|
|
|
- log.info("学生购买直播课程组,请求参数:{}", JSON.toJSONString(orderReqInfo));
|
|
|
+ log.info("buyLiveCourse param:{}", JSON.toJSONString(orderReqInfo));
|
|
|
Map<String, Object> param = WrapperUtil.toMap(orderReqInfo.getBizContent());
|
|
|
Long groupId = WrapperUtil.toLong(param, "groupId", "课程组id不能为空!");
|
|
|
Long studentId = orderReqInfo.getUserId();
|
|
@@ -547,44 +547,34 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
}
|
|
|
//校验购买的课程组每节课时间是否和自己的课时冲突
|
|
|
batchCheckStudentCourseTime(studentId, courseList, CourseSchedule::getStartTime, CourseSchedule::getEndTime);
|
|
|
- //将该数据传递到后面的after方法使用
|
|
|
- Map<String, Object> bizParam = new HashMap<>();
|
|
|
- bizParam.put("courseGroup", courseGroup);
|
|
|
- bizParam.put("courseList", courseList);
|
|
|
- bizParam.put("studentId", studentId);
|
|
|
+ //写入学生购买课程记录
|
|
|
+ buyLiveCourseAfter(orderReqInfo.getOrderNo(), studentId, courseList, courseGroup);
|
|
|
+
|
|
|
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(bizParam);
|
|
|
orderCreateRes.setGoodNum(courseGroup.getCourseNum());
|
|
|
orderCreateRes.setGoodType(GoodTypeEnum.LIVE);
|
|
|
|
|
|
HttpResponseResult<OrderCreateRes> httpResponseResult = new HttpResponseResult<>();
|
|
|
httpResponseResult.setData(orderCreateRes);
|
|
|
+ log.info("buyLiveCourse return {}", httpResponseResult);
|
|
|
return httpResponseResult;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 待订单创建完毕后继续后续操作
|
|
|
*
|
|
|
- * @param afterParam 传入参数
|
|
|
- * <p> - courseList 课程列表
|
|
|
- * <p> - studentId 学员id
|
|
|
- * <p> - courseGroup 直播课程组信息
|
|
|
+ * @param orderNo 订单号
|
|
|
+ * @param courseList 课程列表
|
|
|
+ * @param studentId 学员id
|
|
|
+ * @param courseGroup 直播课程组信息
|
|
|
*/
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- @Override
|
|
|
- public void buyLiveCourseAfter(UserOrderDetailVo afterParam) {
|
|
|
- log.info("学生购买直播课程组 after ,请求参数:{}", JSON.toJSONString(afterParam));
|
|
|
- Map<String, Object> param = WrapperUtil.toMap(afterParam.getBizParam());
|
|
|
- String orderNo = afterParam.getOrderNo();
|
|
|
- Long studentId = (Long) param.get("studentId");
|
|
|
- List<CourseSchedule> courseList = JSONArray.parseArray(JSON.toJSONString(param.get("courseList")), CourseSchedule.class);
|
|
|
- CourseGroup courseGroup = (CourseGroup) param.get("courseGroup");
|
|
|
-
|
|
|
+ private void buyLiveCourseAfter(String orderNo, Long studentId, List<CourseSchedule> courseList, CourseGroup courseGroup) {
|
|
|
+ log.info("buyLiveCourse buyLiveCourseAfter -> order {} studentId {} courseList {} courseGroup {}", orderNo, studentId, JSON.toJSONString(courseList), JSON.toJSONString(courseGroup));
|
|
|
//获取每节课购买的价格
|
|
|
Map<Integer, BigDecimal> courseAveragePrice = WrapperUtil.getAveragePrice(courseGroup.getCourseNum(), courseGroup.getCoursePrice());
|
|
|
//写course_schedule_student_payment表 作为记录锁定时间用,防止重复购买,如果支付失败则删除该数据
|
|
@@ -615,7 +605,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public void buyLiveCourseSuccess(UserOrderDetailVo orderParam) {
|
|
|
- log.info("学生购买直播课程-成功-回调,请求参数:{}", JSON.toJSONString(orderParam));
|
|
|
+ log.info("buyLiveCourseSuccess param :{}", JSON.toJSONString(orderParam));
|
|
|
String orderNo = orderParam.getOrderNo();
|
|
|
//更新课程组的购买人数+1
|
|
|
CourseScheduleStudentPayment studentPayment = courseScheduleStudentPaymentService.getOne(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
|
|
@@ -659,17 +649,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
teacherSalaryList.add(teacherSalary);
|
|
|
});
|
|
|
courseScheduleTeacherSalaryService.getDao().insertBatch(teacherSalaryList);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 学生购买直播课-失败-回调
|
|
|
- */
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void buyLiveCourseFailed(String orderNo) {
|
|
|
- //删除 course_schedule_student_payment表 数据
|
|
|
-
|
|
|
-
|
|
|
- //修改订单为失败
|
|
|
+ log.info("buyLiveCourseSuccess ok");
|
|
|
}
|
|
|
|
|
|
private SysUser getSysUser(Long userId) {
|