|
@@ -35,6 +35,7 @@ import com.yonge.toolset.base.exception.BizException;
|
|
|
import com.yonge.toolset.base.page.PageInfo;
|
|
|
import com.yonge.toolset.base.string.MessageFormatter;
|
|
|
import com.yonge.toolset.mybatis.support.PageUtil;
|
|
|
+import com.yonge.toolset.payment.core.util.SpringBeansUtil;
|
|
|
import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.yonge.toolset.utils.date.DateUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
@@ -1526,59 +1527,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
}
|
|
|
courseGroupList.forEach(courseGroup -> {
|
|
|
try {
|
|
|
- List<CourseScheduleStudentPayment> list = courseScheduleStudentPaymentService.list(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
|
|
|
- .eq(CourseScheduleStudentPayment::getCourseGroupId, courseGroup.getId()));
|
|
|
- Set<Long> userIds = list.stream().map(CourseScheduleStudentPayment::getUserId).collect(Collectors.toSet());
|
|
|
- if (courseGroup.getPreStudentNum() >= courseGroup.getMixStudentNum() &&courseGroup.getStatus().equals(CourseGroupEnum.APPLY.getCode())) {
|
|
|
- //人数达标则修改课程组为进行中状态
|
|
|
- courseGroup.setStatus(CourseGroupEnum.ING.getCode());
|
|
|
- List<Long> noGroupJoinUserIds = Lists.newArrayList();
|
|
|
- //创建群聊 并添加人员到群中
|
|
|
- String imGroupId = imGroupService.autoCreate(courseGroup.getId(), courseGroup.getType(), noGroupJoinUserIds);
|
|
|
-
|
|
|
- // 排除未进群的学生
|
|
|
- if (CollectionUtils.isNotEmpty(noGroupJoinUserIds)) {
|
|
|
- noGroupJoinUserIds.forEach(userIds::remove);
|
|
|
- }
|
|
|
- // 更新已进群用户身份
|
|
|
- imGroupMemberService.initGroupMembers(imGroupId, userIds, ImGroupMemberRoleType.STUDENT);
|
|
|
- //添加老师进群
|
|
|
- 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());
|
|
|
- //更新课程组下课程状态为取消
|
|
|
- courseScheduleService.update(Wrappers.<CourseSchedule>lambdaUpdate()
|
|
|
- .eq(CourseSchedule::getCourseGroupId, courseGroup.getId())
|
|
|
- .set(CourseSchedule::getStatus, CourseScheduleEnum.CANCEL.getCode())
|
|
|
- );
|
|
|
-
|
|
|
- //退款
|
|
|
- this.refund(courseGroup);
|
|
|
-
|
|
|
- // 小组课成课推送
|
|
|
- if (courseGroup.getType().equals(CourseScheduleEnum.GROUP.getCode())) {
|
|
|
-
|
|
|
- // 极光-消息推送-老师端-通知老师小组课程组成课
|
|
|
- sendGroupSuccessMessage(courseGroup,false);
|
|
|
- } else {
|
|
|
- // 老师直播课成课失败发送消息
|
|
|
- this.sendMessage(courseGroup);
|
|
|
-
|
|
|
- // 学生直播课成课失败发送消息
|
|
|
- this.sendStudentMessage(userIds, courseGroup);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- courseGroup.setUpdatedTime(new Date());
|
|
|
- this.updateById(courseGroup);
|
|
|
+ Objects.requireNonNull(SpringBeansUtil.getBean(CourseGroupService.class)).closeCourseGroup(courseGroup);
|
|
|
} catch (Exception e) {
|
|
|
log.error("closeCourseGroup error >>> courseGroup: {} ", JSON.toJSONString(courseGroup));
|
|
|
log.error("closeCourseGroup error >>> ", e);
|
|
@@ -1586,6 +1535,70 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void closeCourseGroup(CourseGroup courseGroup) {
|
|
|
+ try {
|
|
|
+ List<CourseScheduleStudentPayment> list = courseScheduleStudentPaymentService.list(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
|
|
|
+ .eq(CourseScheduleStudentPayment::getCourseGroupId, courseGroup.getId()));
|
|
|
+ Set<Long> userIds = list.stream().map(CourseScheduleStudentPayment::getUserId).collect(Collectors.toSet());
|
|
|
+ if (courseGroup.getPreStudentNum() >= courseGroup.getMixStudentNum() && courseGroup.getStatus().equals(CourseGroupEnum.APPLY.getCode())) {
|
|
|
+ //人数达标则修改课程组为进行中状态
|
|
|
+ courseGroup.setStatus(CourseGroupEnum.ING.getCode());
|
|
|
+ List<Long> noGroupJoinUserIds = Lists.newArrayList();
|
|
|
+ //创建群聊 并添加人员到群中
|
|
|
+ String imGroupId = imGroupService.autoCreate(courseGroup.getId(), courseGroup.getType(), noGroupJoinUserIds);
|
|
|
+
|
|
|
+ // 排除未进群的学生
|
|
|
+ if (CollectionUtils.isNotEmpty(noGroupJoinUserIds)) {
|
|
|
+ noGroupJoinUserIds.forEach(userIds::remove);
|
|
|
+ }
|
|
|
+ // 更新已进群用户身份
|
|
|
+ imGroupMemberService.initGroupMembers(imGroupId, userIds, ImGroupMemberRoleType.STUDENT);
|
|
|
+ //添加老师进群
|
|
|
+ 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());
|
|
|
+ //更新课程组下课程状态为取消
|
|
|
+ courseScheduleService.update(Wrappers.<CourseSchedule>lambdaUpdate()
|
|
|
+ .eq(CourseSchedule::getCourseGroupId, courseGroup.getId())
|
|
|
+ .set(CourseSchedule::getStatus, CourseScheduleEnum.CANCEL.getCode())
|
|
|
+ );
|
|
|
+
|
|
|
+ //退款
|
|
|
+ this.refund(courseGroup);
|
|
|
+
|
|
|
+ // 小组课成课推送
|
|
|
+ if (courseGroup.getType().equals(CourseScheduleEnum.GROUP.getCode())) {
|
|
|
+
|
|
|
+ // 极光-消息推送-老师端-通知老师小组课程组成课
|
|
|
+ sendGroupSuccessMessage(courseGroup,false);
|
|
|
+ } else {
|
|
|
+ // 老师直播课成课失败发送消息
|
|
|
+ this.sendMessage(courseGroup);
|
|
|
+
|
|
|
+ // 学生直播课成课失败发送消息
|
|
|
+ this.sendStudentMessage(userIds, courseGroup);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ courseGroup.setUpdatedTime(new Date());
|
|
|
+ this.updateById(courseGroup);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("closeCourseGroup error >>> courseGroup: {} ", JSON.toJSONString(courseGroup));
|
|
|
+ log.error("closeCourseGroup error >>> ", e);
|
|
|
+ throw new BizException("课程状态更新失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void sendGroupSuccessMessage(CourseGroup courseGroup,boolean success) {
|
|
|
// 老师
|
|
|
SysUser sysUser = sysUserService.getByUserId(courseGroup.getTeacherId());
|