|
@@ -36,6 +36,8 @@ import com.ym.mec.util.string.MessageFormatter;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.joda.time.DateTime;
|
|
|
+import org.joda.time.format.DateTimeFormat;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -50,9 +52,11 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.MessageFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -4979,6 +4983,76 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
// 更新通知状态
|
|
|
courseScheduleDao.updateRemindStatus(ids);
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ for (CourseSchedule courseSchedule : courseSchedules) {
|
|
|
+ createVipGroupLiveRoom(courseSchedule.getId().toString(), courseSchedule);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建网络课直播间
|
|
|
+ * @param roomId 课程房间编号
|
|
|
+ * @param courseSchedule 课程信息
|
|
|
+ * @return ImLiveBroadcastRoom
|
|
|
+ */
|
|
|
+ private void createVipGroupLiveRoom(String roomId, CourseSchedule courseSchedule) {
|
|
|
+ //记录用户实际选择的房间
|
|
|
+ if (courseSchedule.getGroupType() == GroupType.COMM) {
|
|
|
+ roomId = "I" + roomId;
|
|
|
+ } else {
|
|
|
+ roomId = "S" + roomId;
|
|
|
+ }
|
|
|
+ // 主动创建直播间
|
|
|
+ VipGroup vipGroup = vipGroupDao.get(Long.parseLong(courseSchedule.getMusicGroupId()));
|
|
|
+ if (Objects.isNull(vipGroup)) {
|
|
|
+ throw new BizException("直播课程组不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(vipGroup.getLiveConfigJson())) {
|
|
|
+ throw new BizException("直播课程组未配置直播间");
|
|
|
+ }
|
|
|
+
|
|
|
+ ImLiveBroadcastRoom liveRoom = JSON.parseObject(vipGroup.getLiveConfigJson(), ImLiveBroadcastRoom.class);
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(liveRoom.getServiceProvider())) {
|
|
|
+ //查询房间过期时间
|
|
|
+ String liveClient = sysConfigDao.findConfigValue("live_client");
|
|
|
+ liveRoom.setServiceProvider(liveClient);
|
|
|
+ }
|
|
|
+
|
|
|
+ String liveStartTime = MessageFormat.format("{0} {1}", DateUtil.format(courseSchedule.getClassDate(), DateUtil.DEFAULT_PATTERN),
|
|
|
+ DateUtil.format(courseSchedule.getStartClassTime(), DateUtil.EXPANDED_TIME_FORMAT));
|
|
|
+
|
|
|
+ DateTime time = DateTime.parse(liveStartTime, DateTimeFormat.forPattern(DateUtil.DEFAULT_PATTERN + " " + DateUtil.EXPANDED_TIME_FORMAT));
|
|
|
+
|
|
|
+ String roomUid = "LIVE-" + roomId + "-" + time.toDate().getTime();
|
|
|
+ liveRoom.setTenantId(TenantContextHolder.getTenantId());
|
|
|
+ liveRoom.setRoomUid(roomUid);
|
|
|
+ //liveRoom.setRoomConfig(liveRoom.getRoomConfig());
|
|
|
+ liveRoom.setLiveState(1);
|
|
|
+ liveRoom.setRoomState(0);
|
|
|
+ liveRoom.setGroupType("LIVE");
|
|
|
+ liveRoom.setCreatedBy(liveRoom.getSpeakerId());
|
|
|
+ liveRoom.setCreatedTime(DateTime.now().toDate());
|
|
|
+ liveRoom.setLiveStartTime(DateTime.now().toDate());
|
|
|
+ liveRoom.setTenantId(courseSchedule.getTenantId());
|
|
|
+
|
|
|
+ // 创建直播间
|
|
|
+ imLiveBroadcastRoomService.save(liveRoom);
|
|
|
+
|
|
|
+ // 开启直播间
|
|
|
+ imLiveBroadcastRoomService.createLiveRoom(liveRoom);
|
|
|
+
|
|
|
+ // 更新课程关联直播间
|
|
|
+ CourseSchedule schedule = new CourseSchedule();
|
|
|
+ schedule.setId(courseSchedule.getId());
|
|
|
+ schedule.setTenantId(courseSchedule.getTenantId());
|
|
|
+ schedule.setLiveRoomId(roomUid);
|
|
|
+ courseScheduleDao.update(schedule);
|
|
|
|
|
|
}
|
|
|
|