|
@@ -361,7 +361,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
//课程组信息
|
|
|
CourseGroup courseGroup = this.getOne(Wrappers.<CourseGroup>lambdaQuery()
|
|
|
.eq(CourseGroup::getId, groupId)
|
|
|
- .eq(CourseGroup::getType, CourseScheduleEnum.LIVE.getCode())
|
|
|
+ .eq(CourseGroup::getType, orderGoodsInfo.getGoodType().name())
|
|
|
);
|
|
|
if (Objects.isNull(courseGroup)) {
|
|
|
throw new BizException("课程组不存在!");
|
|
@@ -379,6 +379,14 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
//校验购买的课程组每节课时间是否和自己的课时冲突
|
|
|
batchCheckStudentCourseTime(studentId, courseList, CourseSchedule::getStartTime, CourseSchedule::getEndTime);
|
|
|
|
|
|
+ // 小组课判断购买人数
|
|
|
+ if (orderGoodsInfo.getGoodType() == GoodTypeEnum.GROUP) {
|
|
|
+ String configValue = sysConfigService.findConfigValue(SysConfigConstant.GROUP_MAX_STUDENT_NUM);
|
|
|
+ if (StringUtils.isNotBlank(configValue)) {
|
|
|
+ int maxStudentNum = Integer.parseInt(configValue);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
UserOrderDetail userOrderDetail = JSON.parseObject(JSON.toJSONString(orderGoodsInfo), UserOrderDetail.class);
|
|
@@ -541,6 +549,26 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void buyGroupSendMessage(CourseScheduleStudentPayment studentPayment, CourseGroup courseGroup) {
|
|
|
+ //查询老师信息
|
|
|
+ SysUser teacherInfo = sysUserService.findUserById(courseGroup.getTeacherId());
|
|
|
+ //查询学生信息
|
|
|
+ SysUser studentInfo = sysUserService.findUserById(studentPayment.getUserId());
|
|
|
+ try {
|
|
|
+
|
|
|
+ //极光-消息推送-学生端-通知学生购买成功-跳转到APP
|
|
|
+ MessageTypeEnum liveBuy = MessageTypeEnum.GROUP_BUY;
|
|
|
+ Map<Long, String> studentReceivers = new HashMap<>();
|
|
|
+ studentReceivers.put(studentInfo.getId(), studentInfo.getPhone());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, liveBuy,
|
|
|
+ studentReceivers, null, 0, "", ClientEnum.STUDENT.getCode(),
|
|
|
+ teacherInfo.getUsername(), courseGroup.getName());
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error("buyGroupSendMessage error", ex.getCause());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* 直播课购买后数据写入
|
|
@@ -555,7 +583,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
//课程组信息
|
|
|
CourseGroup courseGroup = this.getOne(Wrappers.<CourseGroup>lambdaQuery()
|
|
|
.eq(CourseGroup::getId, groupId)
|
|
|
- .eq(CourseGroup::getType, CourseScheduleEnum.LIVE.getCode())
|
|
|
+ .eq(CourseGroup::getType, orderGoodsInfo.getGoodType().name())
|
|
|
);
|
|
|
if (Objects.isNull(courseGroup)) {
|
|
|
throw new BizException("课程组不存在!");
|
|
@@ -1372,7 +1400,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
LocalDate yesterday = today.plusDays(-1L);
|
|
|
//查询今天未开售的课程组
|
|
|
List<CourseGroup> courseGroupList = this.list(Wrappers.<CourseGroup>lambdaQuery()
|
|
|
- .eq(CourseGroup::getType, CourseScheduleEnum.LIVE.getCode())
|
|
|
+ .in(CourseGroup::getType, CourseScheduleEnum.LIVE.getCode(),CourseScheduleEnum.GROUP.getCode())
|
|
|
.ge(CourseGroup::getSalesStartDate, yesterday)
|
|
|
.le(CourseGroup::getSalesStartDate, today)
|
|
|
.eq(CourseGroup::getStatus, CourseGroupEnum.NOT_SALE.getCode()));
|
|
@@ -1397,7 +1425,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
private void closeCourseGroup() {
|
|
|
//查询昨天要结束售卖的课程组
|
|
|
List<CourseGroup> courseGroupList = this.list(Wrappers.<CourseGroup>lambdaQuery()
|
|
|
- .eq(CourseGroup::getType, CourseScheduleEnum.LIVE.getCode())
|
|
|
+ .in(CourseGroup::getType, CourseScheduleEnum.LIVE.getCode(),CourseScheduleEnum.GROUP.getCode())
|
|
|
.eq(CourseGroup::getSalesEndDate, LocalDate.now().plusDays(-1))
|
|
|
.in(CourseGroup::getStatus, CourseGroupEnum.APPLY.getCode(),CourseGroupEnum.OUT_SALE.getCode()));
|
|
|
if (CollectionUtils.isEmpty(courseGroupList)) {
|
|
@@ -1424,6 +1452,12 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
//添加老师进群
|
|
|
imGroupMemberService.initGroupMembers(imGroupId, Collections.singleton(courseGroup.getTeacherId()), ImGroupMemberRoleType.TEACHER);
|
|
|
courseGroup.setImGroupId(imGroupId);
|
|
|
+
|
|
|
+ // 小组课成课推送
|
|
|
+ if (courseGroup.getType().equals(CourseScheduleEnum.GROUP.getCode())) {
|
|
|
+ // 极光-消息推送-老师端-通知老师小组课程组成课
|
|
|
+ sendGroupSuccessMessage(courseGroup,true);
|
|
|
+ }
|
|
|
} else {
|
|
|
//人数未达标则修改课程组为取消状态
|
|
|
courseGroup.setStatus(CourseGroupEnum.CANCEL.getCode());
|
|
@@ -1432,11 +1466,19 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
.eq(CourseSchedule::getCourseGroupId, courseGroup.getId())
|
|
|
.set(CourseSchedule::getStatus, CourseScheduleEnum.CANCEL.getCode())
|
|
|
);
|
|
|
- // 老师直播课成课失败发送消息
|
|
|
- this.sendMessage(courseGroup);
|
|
|
|
|
|
- // 学生直播课成课失败发送消息
|
|
|
- this.sendStudentMessage(userIds,courseGroup);
|
|
|
+ // 小组课成课推送
|
|
|
+ if (courseGroup.getType().equals(CourseScheduleEnum.GROUP.getCode())) {
|
|
|
+
|
|
|
+ // 极光-消息推送-老师端-通知老师小组课程组成课
|
|
|
+ sendGroupSuccessMessage(courseGroup,false);
|
|
|
+ } else {
|
|
|
+ // 老师直播课成课失败发送消息
|
|
|
+ this.sendMessage(courseGroup);
|
|
|
+
|
|
|
+ // 学生直播课成课失败发送消息
|
|
|
+ this.sendStudentMessage(userIds, courseGroup);
|
|
|
+ }
|
|
|
|
|
|
//退款
|
|
|
this.refund(courseGroup);
|
|
@@ -1450,6 +1492,37 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private void sendGroupSuccessMessage(CourseGroup courseGroup,boolean success) {
|
|
|
+ // 老师
|
|
|
+ SysUser sysUser = sysUserService.getByUserId(courseGroup.getTeacherId());
|
|
|
+ try {
|
|
|
+ Map<Long, String> receivers = new HashMap<>();
|
|
|
+ receivers.put(sysUser.getId(), sysUser.getPhone());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, success?MessageTypeEnum.GROUP_SUCCESS_TEACHER:MessageTypeEnum.GROUP_FAIL_TEACHER,
|
|
|
+ receivers, null, 0, null, ClientEnum.TEACHER.getCode(), courseGroup.getName());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("小组课成课成功推送发送失败,{}", e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<CourseScheduleStudentPayment> list = courseScheduleStudentPaymentService.list(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
|
|
|
+ .eq(CourseScheduleStudentPayment::getCourseGroupId, courseGroup.getId()));
|
|
|
+ Set<Long> userIds = list.stream().map(CourseScheduleStudentPayment::getUserId).collect(Collectors.toSet());
|
|
|
+ // 学生
|
|
|
+ Map<Long, com.yonge.cooleshow.biz.dal.entity.SysUser> mapByIds = sysUserService.getMapByIds((List<Long>) userIds);
|
|
|
+
|
|
|
+ Map<Long, String> receivers = new HashMap<>();
|
|
|
+ for (com.yonge.cooleshow.biz.dal.entity.SysUser value : mapByIds.values()) {
|
|
|
+ receivers.put(value.getId(), value.getPhone());
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, success?MessageTypeEnum.GROUP_SUCCESS_STUDENT:MessageTypeEnum.GROUP_FAIL_STUDENT,
|
|
|
+ receivers, null, 0, null, ClientEnum.STUDENT.getCode(), courseGroup.getName());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("小组课成课成功推送发送失败,{}", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void sendStudentMessage(Set<Long> userIds, CourseGroup courseGroup) {
|
|
|
for (Long userId : userIds) {
|
|
|
|
|
@@ -1498,14 +1571,15 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
|
|
|
List<Long> orderDetailIds = new ArrayList<>();
|
|
|
if (CollectionUtils.isNotEmpty(detail.getOrderDetailList())) {
|
|
|
- detail.getOrderDetailList().stream().filter(orderDetail -> orderDetail.getGoodType() == GoodTypeEnum.LIVE)
|
|
|
+ detail.getOrderDetailList().stream()
|
|
|
+ .filter(orderDetail -> orderDetail.getGoodType() == GoodTypeEnum.LIVE || orderDetail.getGoodType() == GoodTypeEnum.GROUP)
|
|
|
.filter(orderDetail -> orderDetail.getBizId().equals(courseGroup.getId()))
|
|
|
.forEach(orderDetail -> orderDetailIds.add(orderDetail.getId()));
|
|
|
}
|
|
|
if (order.getPaymentVersion().equals(EPaymentVersion.V1)) {
|
|
|
- userOrderRefundService.orderRefund(order.getOrderNo(), "直播课成课失败退款");
|
|
|
+ userOrderRefundService.orderRefund(order.getOrderNo(), CourseScheduleEnum.valueOf(courseGroup.getType()).name() +"成课失败退款");
|
|
|
} else {
|
|
|
- userPaymentCoreService.refundPayment(order.getOrderNo(),"直播课成课失败退款", orderDetailIds);
|
|
|
+ userPaymentCoreService.refundPayment(order.getOrderNo(),CourseScheduleEnum.valueOf(courseGroup.getType()).name() +"成课失败退款", orderDetailIds);
|
|
|
}
|
|
|
|
|
|
//退还优惠券
|
|
@@ -1513,8 +1587,8 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
couponInfoService.updateUserOrderCouponInfo(CouponOrderWrapper.builder().orderNo(order.getOrderNo()).reset(true).build());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.warn("直播课成课失败退款 退款失败,退款订单号 {}", order);
|
|
|
- log.error("直播课成课失败退款 退款失败", e);
|
|
|
+ log.warn("成课失败退款 退款失败,退款订单号 {}", order);
|
|
|
+ log.error("成课失败退款 退款失败", e);
|
|
|
}
|
|
|
}
|
|
|
}
|