|
@@ -10,6 +10,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.microsvc.toolkit.middleware.rtc.RTCRoomPluginContext;
|
|
|
+import com.microsvc.toolkit.middleware.rtc.RTCRoomPluginService;
|
|
|
+import com.microsvc.toolkit.middleware.rtc.impl.TencentCloudRTCPlugin;
|
|
|
import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.*;
|
|
@@ -142,6 +145,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
@Autowired
|
|
|
private RedisCacheService redisCacheService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RTCRoomPluginContext rtcRoomPluginContext;
|
|
|
@Override
|
|
|
public CourseScheduleDao getDao() {
|
|
|
return this.baseMapper;
|
|
@@ -2513,6 +2518,57 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void rtcRoomCreate() {
|
|
|
+
|
|
|
+ //是否提前进入教室
|
|
|
+ String courseBeforeBufferTime = sysConfigService.findConfigValue(SysConfigConstant.PRE_CREATE_PRACTICE_ROOM_MINUTE);
|
|
|
+ if (StringUtils.isEmpty(courseBeforeBufferTime)) {
|
|
|
+ courseBeforeBufferTime = "5";
|
|
|
+ }
|
|
|
+ Integer beforeTime = Integer.parseInt(courseBeforeBufferTime) + 5;
|
|
|
+
|
|
|
+ List<CourseSchedule> scheduleList = baseMapper.getNotStartRtc(beforeTime);
|
|
|
+ if (CollectionUtils.isEmpty(scheduleList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (CourseSchedule courseSchedule : scheduleList) {
|
|
|
+ try {
|
|
|
+ RTCRoomPluginService pluginService;
|
|
|
+ if (StringUtils.isBlank(courseSchedule.getServiceProvider())) {
|
|
|
+ pluginService = rtcRoomPluginContext.getPluginService();
|
|
|
+ } else {
|
|
|
+ pluginService = rtcRoomPluginContext.getPluginService(courseSchedule.getServiceProvider());
|
|
|
+ }
|
|
|
+ // 群组帐号注册
|
|
|
+ SysUser sysUser = getSysUser();
|
|
|
+ if (Objects.nonNull(sysUser)) {
|
|
|
+ try {
|
|
|
+ pluginService.register(courseSchedule.getTeacherId().toString(), sysUser.getRealName(), sysUser.getAvatar());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("直播房间群主注册失败: userId={}", courseSchedule.getTeacherId(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //记录用户实际选择的房间
|
|
|
+ String roomId = courseSchedule.getId().toString();
|
|
|
+
|
|
|
+ // 生成群组
|
|
|
+ pluginService.chatRoomCreate(roomId, roomId, courseSchedule.getTeacherId().toString());
|
|
|
+ this.lambdaUpdate()
|
|
|
+ .eq(CourseSchedule::getId, courseSchedule.getId())
|
|
|
+ .set(CourseSchedule::getLiveRemind,1)
|
|
|
+ .update();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("创建rtc房间失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private UserOrderDetail buyPracticeCourseTranV2(UserPaymentOrderWrapper.OrderGoodsInfo orderGoodsInfo) {
|
|
|
log.info("buyPracticeCourse param:{}", JSON.toJSONString(orderGoodsInfo));
|
|
|
Long studentId = orderGoodsInfo.getUserId();
|
|
@@ -2651,4 +2707,31 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
|
|
|
return liveRoomTime;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void destroyRtcRoom() {
|
|
|
+
|
|
|
+ // 查询结束时间在昨天到现在的课程
|
|
|
+ List<CourseSchedule> scheduleList = baseMapper.getEndTimeBetweenYesterdayAndNow();
|
|
|
+ if (CollectionUtils.isEmpty(scheduleList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (CourseSchedule courseSchedule : scheduleList) {
|
|
|
+ try {
|
|
|
+ RTCRoomPluginService pluginService;
|
|
|
+ if (StringUtils.isBlank(courseSchedule.getServiceProvider())) {
|
|
|
+ pluginService = rtcRoomPluginContext.getPluginService();
|
|
|
+ } else {
|
|
|
+ pluginService = rtcRoomPluginContext.getPluginService(courseSchedule.getServiceProvider());
|
|
|
+ }
|
|
|
+ if (TencentCloudRTCPlugin.PLUGIN_NAME.equals(pluginService.pluginName())) {
|
|
|
+ // 腾讯云群销毁
|
|
|
+ String roomId = courseSchedule.getId().toString();
|
|
|
+ pluginService.chatRoomDestroy(roomId);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("销毁rtc房间失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|