|
@@ -9,9 +9,11 @@ import com.beust.jcommander.internal.Lists;
|
|
|
import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.LiveRoomDao;
|
|
|
-import com.yonge.cooleshow.biz.dal.dto.UserAccountRecordDto;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.*;
|
|
|
-import com.yonge.cooleshow.biz.dal.enums.*;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.OrderStatusEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.RoomTypeEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.TeacherSalaryEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.support.IMHelper;
|
|
|
import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
|
|
@@ -38,7 +40,8 @@ import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.yonge.cooleshow.biz.dal.constant.LiveRoomConstant.*;
|
|
|
-import static com.yonge.cooleshow.common.constant.SysConfigConstant.*;
|
|
|
+import static com.yonge.cooleshow.common.constant.SysConfigConstant.DESTROY_EXPIRED_LIVE_ROOM_MINUTE;
|
|
|
+import static com.yonge.cooleshow.common.constant.SysConfigConstant.PRE_CREATE_LIVE_ROOM_MINUTE;
|
|
|
|
|
|
/**
|
|
|
* 直播房间与课程的关系表表(LiveRoom)表服务实现类
|
|
@@ -63,8 +66,6 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
@Autowired
|
|
|
private SysConfigService sysConfigService;
|
|
|
@Autowired
|
|
|
- private UserAccountService userAccountService;
|
|
|
- @Autowired
|
|
|
private UserOrderService userOrderService;
|
|
|
@Autowired
|
|
|
private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
|
|
@@ -338,14 +339,18 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
List<LiveRoom> list = this.list(Wrappers.<LiveRoom>lambdaQuery()
|
|
|
.eq(LiveRoom::getRoomState, 0)
|
|
|
.eq(LiveRoom::getLiveState, 1)
|
|
|
- .eq(LiveRoom::getType, RoomTypeEnum.LIVE.getCode())
|
|
|
.le(LiveRoom::getLiveEndTime, now));
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
return;
|
|
|
}
|
|
|
list.forEach(room -> {
|
|
|
- Date expiredDate = DateUtil.addMinutes(room.getLiveEndTime(), Integer.parseInt(expiredMinuteStr));
|
|
|
- //当前时间 大于(结束播时间 + 设置的过期分钟数)
|
|
|
+ //直播间过期时间
|
|
|
+ Date expiredDate = room.getLiveEndTime();
|
|
|
+ if (room.getType().equals(RoomTypeEnum.LIVE.getCode())) {
|
|
|
+ //如果是直播课,那么结束时间 = 直播间结束时间 + 设置的过期分钟数
|
|
|
+ expiredDate = DateUtil.addMinutes(room.getLiveEndTime(), Integer.parseInt(expiredMinuteStr));
|
|
|
+ }
|
|
|
+ //当前时间 大于 直播间过期时间
|
|
|
if (now.getTime() >= expiredDate.getTime()) {
|
|
|
destroyLiveRoom(room);
|
|
|
}
|
|
@@ -373,93 +378,26 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
if (Objects.isNull(room)) {
|
|
|
return;
|
|
|
}
|
|
|
- //查询老师分润表
|
|
|
- List<CourseScheduleTeacherSalary> salaryList = courseScheduleTeacherSalaryService.list(Wrappers.<CourseScheduleTeacherSalary>lambdaQuery()
|
|
|
- .eq(CourseScheduleTeacherSalary::getCourseScheduleId, room.getCourseId())
|
|
|
- );
|
|
|
- if (CollectionUtils.isEmpty(salaryList)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- salaryList.forEach(salary -> {
|
|
|
- //查询该学生及课程id 对应的支付订单号
|
|
|
- CourseScheduleStudentPayment payment = courseScheduleStudentPaymentService.getOne(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
|
|
|
- .eq(CourseScheduleStudentPayment::getCourseId, room.getCourseId())
|
|
|
- .eq(CourseScheduleStudentPayment::getUserId, salary.getStudentId())
|
|
|
+ //直播课
|
|
|
+ if (room.getType().equals(RoomTypeEnum.LIVE.getCode())) {
|
|
|
+ //查询老师分润表
|
|
|
+ List<CourseScheduleTeacherSalary> salaryList = courseScheduleTeacherSalaryService.list(Wrappers.<CourseScheduleTeacherSalary>lambdaQuery()
|
|
|
+ .eq(CourseScheduleTeacherSalary::getCourseScheduleId, room.getCourseId())
|
|
|
);
|
|
|
- if (Objects.isNull(payment)) {
|
|
|
+ if (CollectionUtils.isEmpty(salaryList)) {
|
|
|
return;
|
|
|
}
|
|
|
- //获取教师课酬写入到金额变更表
|
|
|
- UserAccountRecordDto userAccountRecord = new UserAccountRecordDto();
|
|
|
- userAccountRecord.setUserId(room.getSpeakerId());
|
|
|
- userAccountRecord.setInOrOut(InOrOutEnum.IN);
|
|
|
- userAccountRecord.setBizType(AccountBizTypeEnum.LIVE);
|
|
|
- userAccountRecord.setBizId(room.getCourseId());
|
|
|
- userAccountRecord.setBizName(room.getRoomTitle());
|
|
|
- userAccountRecord.setTransAmount(salary.getActualSalary());//扣除手续费后所得金额
|
|
|
- userAccountRecord.setOrderNo(payment.getOrderNo());
|
|
|
- userAccountService.accountChange(userAccountRecord);
|
|
|
- //修改教师课酬状态-已结算
|
|
|
- salary.setStatus(TeacherSalaryEnum.COMPLETE.getCode());
|
|
|
- courseScheduleTeacherSalaryService.updateById(salary);
|
|
|
- });
|
|
|
+ salaryList.forEach(salary -> {
|
|
|
+ //修改教师课酬状态-已结算
|
|
|
+ salary.setStatus(TeacherSalaryEnum.WAIT.getCode());
|
|
|
+ courseScheduleTeacherSalaryService.updateById(salary);
|
|
|
+ });
|
|
|
+ }
|
|
|
//删除房间
|
|
|
ImDestroyLiveRoom(room.getRoomUid());
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 定时任务-清理过期的房间-陪练课
|
|
|
- */
|
|
|
- public void destroyExpiredPracticeRoom() {
|
|
|
- //查询房间过期时间
|
|
|
- String expiredMinuteStr = sysConfigService.findConfigValue(PRE_CREATE_PRACTICE_ROOM_MINUTE);
|
|
|
- if (StringUtils.isEmpty(expiredMinuteStr)) {
|
|
|
- log.info("roomDestroy>>>> 未查询到配置:{}", PRE_CREATE_PRACTICE_ROOM_MINUTE);
|
|
|
- return;
|
|
|
- }
|
|
|
- Date now = new Date();
|
|
|
- //查询已经开始并且没有删除及销毁的直播间
|
|
|
- List<LiveRoom> list = this.list(Wrappers.<LiveRoom>lambdaQuery()
|
|
|
- .eq(LiveRoom::getRoomState, 0)
|
|
|
- .eq(LiveRoom::getLiveState, 1)
|
|
|
- .eq(LiveRoom::getType, RoomTypeEnum.PRACTICE.getCode())
|
|
|
- .le(LiveRoom::getLiveEndTime, now));
|
|
|
- if (CollectionUtils.isEmpty(list)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- list.forEach(room -> {
|
|
|
- Date expiredDate = DateUtil.addMinutes(room.getLiveEndTime(), Integer.parseInt(expiredMinuteStr));
|
|
|
- //当前时间 大于(结束播时间 + 设置的过期分钟数)
|
|
|
- if (now.getTime() >= expiredDate.getTime()) {
|
|
|
- //删除房间
|
|
|
- ImDestroyLiveRoom(room.getRoomUid());
|
|
|
- //查询老师分润表
|
|
|
- CourseScheduleTeacherSalary salary = courseScheduleTeacherSalaryService.getOne(Wrappers.<CourseScheduleTeacherSalary>lambdaQuery()
|
|
|
- .eq(CourseScheduleTeacherSalary::getCourseScheduleId, room.getCourseId())
|
|
|
- );
|
|
|
- if (Objects.isNull(salary)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- //查询该学生及课程id 对应的支付订单号
|
|
|
- CourseScheduleStudentPayment payment = courseScheduleStudentPaymentService.getOne(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
|
|
|
- .eq(CourseScheduleStudentPayment::getCourseId, room.getCourseId())
|
|
|
- .eq(CourseScheduleStudentPayment::getUserId, salary.getStudentId())
|
|
|
- );
|
|
|
- if (Objects.isNull(payment)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- //获取教师课酬写入到金额变更表
|
|
|
- UserAccountRecordDto userAccountRecord = new UserAccountRecordDto();
|
|
|
- userAccountRecord.setUserId(room.getSpeakerId());
|
|
|
- userAccountRecord.setInOrOut(InOrOutEnum.IN);
|
|
|
- userAccountRecord.setBizType(AccountBizTypeEnum.PRACTICE);
|
|
|
- userAccountRecord.setBizId(room.getCourseId());
|
|
|
- userAccountRecord.setBizName(room.getRoomTitle());
|
|
|
- userAccountRecord.setTransAmount(salary.getActualSalary());//扣除手续费后所得金额
|
|
|
- userAccountRecord.setOrderNo(payment.getOrderNo());
|
|
|
- userAccountService.accountChange(userAccountRecord);
|
|
|
- }
|
|
|
- });
|
|
|
+ //修改房间状态
|
|
|
+ room.setLiveState(2);
|
|
|
+ this.updateById(room);
|
|
|
}
|
|
|
|
|
|
/**
|