فهرست منبع

Merge branch 'zx_online_update_1218' into develop-new

刘俊驰 1 روز پیش
والد
کامیت
a43d1390c2

+ 4 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseGroupService.java

@@ -20,6 +20,7 @@ import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.base.page.PageInfo;
 import org.apache.ibatis.annotations.Param;
 import org.redisson.api.RMap;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
 import java.util.List;
@@ -270,6 +271,9 @@ public interface CourseGroupService extends IService<CourseGroup> {
      */
     CourseGroupInfoVo selectLiveGroupInfo(Long groupId);
 
+    @Transactional
+    void closeCourseGroup(CourseGroup courseGroup);
+
     /**
      * 课程组管理-琴房课
      *

+ 66 - 53
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseGroupServiceImpl.java

@@ -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());

+ 0 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ImGroupServiceImpl.java

@@ -450,9 +450,6 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
         imGroup.setName(courseGroup.getName());
         imGroup.setType(ImGroupType.COURSE);
         imGroup.setImg(sysConfigService.findConfigValue(SysConfigConstant.ICON_COURSE_GROUP_DEFAULT));
-        if (courseGroup.getType().equals(CourseScheduleEnum.GROUP.name())) {
-            imGroup.setImg(sysConfigService.findConfigValue(SysConfigConstant.GOOD_LOGO_GROUP));
-        }
         imGroup.setCreateTime(now);
         imGroup.setUpdateTime(now);
 //        String imGroupId = UUID.randomUUID() + imGroup.getType().getCode();