|
@@ -13,6 +13,7 @@ import com.yonge.cooleshow.biz.dal.dao.CourseGroupDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.CheckCourseTimeDto;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto.CoursePlanDto;
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.LiveSaleOutDto;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.UserAccountRecordDto;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.req.OrderRefundReq;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.req.OrderReq;
|
|
@@ -1074,13 +1075,13 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
List<CourseGroup> courseGroupList = this.list(Wrappers.<CourseGroup>lambdaQuery()
|
|
|
.eq(CourseGroup::getType, CourseScheduleEnum.LIVE.getCode())
|
|
|
.eq(CourseGroup::getSalesEndDate, LocalDate.now().plusDays(-1))
|
|
|
- .eq(CourseGroup::getStatus, CourseGroupEnum.APPLY.getCode()));
|
|
|
+ .in(CourseGroup::getStatus, CourseGroupEnum.APPLY.getCode(),CourseGroupEnum.OUT_SALE.getCode()));
|
|
|
if (CollectionUtils.isEmpty(courseGroupList)) {
|
|
|
return;
|
|
|
}
|
|
|
courseGroupList.forEach(courseGroup -> {
|
|
|
try {
|
|
|
- if (courseGroup.getPreStudentNum() >= courseGroup.getMixStudentNum()) {
|
|
|
+ if (courseGroup.getPreStudentNum() >= courseGroup.getMixStudentNum() &&courseGroup.getStatus().equals(CourseGroupEnum.APPLY.getCode())) {
|
|
|
//人数达标则修改课程组为进行中状态
|
|
|
courseGroup.setStatus(CourseGroupEnum.ING.getCode());
|
|
|
//创建群聊 并添加人员到群中
|
|
@@ -1138,6 +1139,10 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
* @param courseGroup 课程组
|
|
|
*/
|
|
|
private void sendMessage(CourseGroup courseGroup) {
|
|
|
+ // 直播课下架后,不推送直播课成课失败消息
|
|
|
+ if (courseGroup.getStatus().equals(CourseGroupEnum.OUT_SALE.getCode())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 发短信
|
|
|
try {
|
|
|
SysUser user = sysUserFeignService.queryUserById(courseGroup.getTeacherId());
|
|
@@ -1269,5 +1274,54 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
|
|
|
result.setAvatar(sysUser.getAvatar());
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Boolean liveSaleOut(LiveSaleOutDto dto) {
|
|
|
+
|
|
|
+
|
|
|
+ CourseGroup liveCourseGroupVo = this.getById(dto.getCourseGourpId());
|
|
|
+ if (liveCourseGroupVo == null || !CourseScheduleEnum.LIVE.getCode().equals(liveCourseGroupVo.getType())) {
|
|
|
+ throw new BizException("没找到课程组信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 条件检查
|
|
|
+ if(dto.getStatus() == 0 && StringUtils.isEmpty(dto.getReason())) {
|
|
|
+ throw new BizException("请填写下架原因");
|
|
|
+ } else if (dto.getStatus() == 0 && !CourseGroupEnum.APPLY.getCode().equals(liveCourseGroupVo.getStatus())) {
|
|
|
+ throw new BizException("只能下架销售中的课程组");
|
|
|
+ } else if (dto.getStatus() == 1 && !CourseGroupEnum.OUT_SALE.getCode().equals(liveCourseGroupVo.getStatus())) {
|
|
|
+ throw new BizException("只能上架被下架的课程组");
|
|
|
+ } else if ( new Date().compareTo(liveCourseGroupVo.getSalesEndDate()) > 0) {
|
|
|
+ throw new BizException("课程组售卖时间已结束,不能操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dto.getStatus() == 0) {
|
|
|
+ liveCourseGroupVo.setStatus(CourseGroupEnum.OUT_SALE.getCode());
|
|
|
+
|
|
|
+ // 发送下架消息
|
|
|
+ sendOutSaleMessage(dto, liveCourseGroupVo);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ liveCourseGroupVo.setStatus(CourseGroupEnum.APPLY.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return this.updateById(liveCourseGroupVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendOutSaleMessage(LiveSaleOutDto dto, CourseGroup liveCourseGroupVo) {
|
|
|
+ // 发送课程下架通知
|
|
|
+ try {
|
|
|
+ SysUser user = sysUserFeignService.queryUserById(liveCourseGroupVo.getTeacherId());
|
|
|
+ Map<Long, String> receivers = new HashMap<>();
|
|
|
+ receivers.put(user.getId(), user.getPhone());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.LIVE_COURSE_OUT_SALE_REASON,
|
|
|
+ receivers, null, 0, null, ClientEnum.TEACHER.getCode(),
|
|
|
+ liveCourseGroupVo.getName(), dto.getReason());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("直播课下架推送发送失败,{}", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|