|
@@ -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;
|
|
|
|
|
@@ -354,6 +358,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
vipGroupApplyBaseInfoDto.setTotalPrice(vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice().multiply(new BigDecimal(vipGroupApplyBaseInfoDto.getOnlineClassesNum())));
|
|
|
vipGroupApplyBaseInfoDto.setOriginalTotalPrice(vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice().multiply(new BigDecimal(vipGroupApplyBaseInfoDto.getOnlineClassesNum())));
|
|
|
}
|
|
|
+ vipGroupApplyBaseInfoDto.setPaymentExpireDate(DateUtil.getLastSecondWithDay(vipGroupApplyBaseInfoDto.getPaymentExpireDate()));
|
|
|
|
|
|
vipGroupDao.update(vipGroupApplyBaseInfoDto);
|
|
|
|
|
@@ -2272,7 +2277,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
|
|
|
if (Objects.isNull(teacherDefaultVipGroupSalary) || Objects.isNull(teacherDefaultVipGroupSalary.getOfflineClassesSalary())) {
|
|
|
- throw new BizException("请设置教师VIP课课酬");
|
|
|
+ throw new BizException("请设置教师默认课酬");
|
|
|
}
|
|
|
|
|
|
Map<String, BigDecimal> results = new HashMap<>(2);
|
|
@@ -2377,12 +2382,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
if (Objects.isNull(gofts)) {
|
|
|
gofts = BigDecimal.ZERO;
|
|
|
}
|
|
|
- if (!vipGroupCategory.getMusicTheory()) {
|
|
|
+ if (!vipGroupCategory.getMusicTheory() && !"LIVE".equals(vipGroup.getGroupType())) {
|
|
|
gofts = gofts.divide(new BigDecimal(vipGroupCategory.getStudentNum()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
|
|
|
ofts = ofts.divide(new BigDecimal(vipGroupCategory.getStudentNum()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
|
|
|
- } else if("LIVE".equals(vipGroup.getGroupType())){
|
|
|
- gofts = gofts.multiply(new BigDecimal(normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
|
|
|
- ofts = ofts.multiply(new BigDecimal(normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
results.put("offlineTeacherSalary", ofts);
|
|
|
results.put("giveOfflineTeacherSalary", gofts);
|
|
@@ -2647,7 +2649,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
if (result.getCode() != 200) {
|
|
|
return result;
|
|
|
}
|
|
|
- classGroup.setStudentNum(classGroup.getStudentNum() - 1);
|
|
|
+ if(groupType == GroupType.VIP){
|
|
|
+ classGroupDao.modifyStudentNum(classGroup.getId(),-1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
Date date = new Date();
|
|
@@ -2678,9 +2682,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("您无法购买此课程");
|
|
|
}
|
|
|
}
|
|
|
- //增加学员数
|
|
|
- classGroup.setStudentNum(classGroup.getStudentNum() + 1);
|
|
|
- classGroupDao.update(classGroup);
|
|
|
+ if(groupType == GroupType.VIP){
|
|
|
+ //增加学员数
|
|
|
+ classGroupDao.modifyStudentNum(classGroup.getId(),1);
|
|
|
+ }
|
|
|
|
|
|
List<CourseSchedule> courseSchedules = JSON.parseArray(vipGroup.getCourseSchedulesJson(), CourseSchedule.class);
|
|
|
courseScheduleService.checkNewCourseSchedules(courseSchedules, false, false);
|
|
@@ -2795,6 +2800,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
if("LIVE".equals(vipGroup.getGroupType())){
|
|
|
groupType = GroupType.LIVE;
|
|
|
messageTypeEnum = MessageTypeEnum.STUDENT_PUSH_LIVE_BUY;
|
|
|
+ classGroupDao.modifyStudentNum(classGroup.getId(),1);
|
|
|
}
|
|
|
if (vipGroup.getStatus() == VipGroupStatusEnum.DELETE ||
|
|
|
vipGroup.getStatus() == VipGroupStatusEnum.CANCEL ||
|
|
@@ -2963,7 +2969,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- classGroup.setStudentNum(classGroup.getStudentNum() - 1);
|
|
|
+ if("VIP".equals(classGroup.getGroupType().getCode())){
|
|
|
+ classGroupDao.modifyStudentNum(classGroup.getId(),-1);
|
|
|
+ }
|
|
|
if (order.getBalancePaymentAmount() != null && order.getBalancePaymentAmount().doubleValue() > 0) {
|
|
|
sysUserCashAccountService.updateBalance(userId, order.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS,
|
|
|
"小课购买失败");
|
|
@@ -3158,6 +3166,16 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
groupType = GroupType.LIVE;
|
|
|
returnFeeEnum = ReturnFeeEnum.LIVE;
|
|
|
}
|
|
|
+ //记录日志
|
|
|
+ SysUserCashAccountLog sysUserCashAccountLog = new SysUserCashAccountLog();
|
|
|
+ sysUserCashAccountLog.setUserId(studentId);
|
|
|
+ sysUserCashAccountLog.setGroupType(groupType);
|
|
|
+ sysUserCashAccountLog.setOrganId(vipGroup.getOrganId());
|
|
|
+ sysUserCashAccountLog.setGroupId(vipGroupId.toString());
|
|
|
+ sysUserCashAccountLog.setAmount(amount);
|
|
|
+ sysUserCashAccountLog.setReturnFeeType(returnFeeEnum);
|
|
|
+ sysUserCashAccountLog.setComment("OA审批" + groupType.getDesc() + "退学");
|
|
|
+ sysUserCashAccountLogDao.insert(sysUserCashAccountLog);
|
|
|
|
|
|
if (classStudentMapperByUserIdAndClassGroupId.getStatus().equals(ClassGroupStudentStatusEnum.QUIT_SCHOOL)) {
|
|
|
classStudentMapperByUserIdAndClassGroupId.setStatus(ClassGroupStudentStatusEnum.QUIT);
|
|
@@ -3169,16 +3187,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- //记录日志
|
|
|
- SysUserCashAccountLog sysUserCashAccountLog = new SysUserCashAccountLog();
|
|
|
- sysUserCashAccountLog.setUserId(studentId);
|
|
|
- sysUserCashAccountLog.setGroupType(groupType);
|
|
|
- sysUserCashAccountLog.setOrganId(vipGroup.getOrganId());
|
|
|
- sysUserCashAccountLog.setGroupId(vipGroupId.toString());
|
|
|
- sysUserCashAccountLog.setAmount(amount);
|
|
|
- sysUserCashAccountLog.setReturnFeeType(returnFeeEnum);
|
|
|
- sysUserCashAccountLog.setComment("OA审批" + groupType.getDesc() + "退学");
|
|
|
- sysUserCashAccountLogDao.insert(sysUserCashAccountLog);
|
|
|
|
|
|
classStudentMapperByUserIdAndClassGroupId.setStatus(ClassGroupStudentStatusEnum.QUIT);
|
|
|
classGroupStudentMapperDao.update(classStudentMapperByUserIdAndClassGroupId);
|
|
@@ -4979,6 +4987,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);
|
|
|
|
|
|
}
|
|
|
|