|
@@ -9,29 +9,21 @@ import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.dto.*;
|
|
|
import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
+import com.ym.mec.biz.dal.enums.ImSendTypeEnum;
|
|
|
import com.ym.mec.common.entity.ImPrivateMessage;
|
|
|
import com.ym.mec.common.entity.ImTxtMessage;
|
|
|
import com.ym.mec.im.ImFeignService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
-import com.ym.mec.biz.dal.dao.CourseHomeworkDao;
|
|
|
-import com.ym.mec.biz.dal.dao.CourseScheduleComplaintsDao;
|
|
|
-import com.ym.mec.biz.dal.dao.CourseScheduleDao;
|
|
|
-import com.ym.mec.biz.dal.dao.CourseScheduleReviewDao;
|
|
|
-import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
|
|
|
-import com.ym.mec.biz.dal.dao.OrganizationDao;
|
|
|
-import com.ym.mec.biz.dal.dao.PracticeGroupDao;
|
|
|
-import com.ym.mec.biz.dal.dao.StudentCourseHomeworkDao;
|
|
|
-import com.ym.mec.biz.dal.dao.SubjectDao;
|
|
|
-import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
-import com.ym.mec.biz.dal.dao.TeacherDao;
|
|
|
import com.ym.mec.biz.dal.entity.ClassGroup;
|
|
|
import com.ym.mec.biz.dal.entity.CourseHomework;
|
|
|
import com.ym.mec.biz.dal.entity.CourseSchedule;
|
|
@@ -103,13 +95,16 @@ public class CourseReviewServiceImpl extends BaseServiceImpl<Integer, CourseSche
|
|
|
private TeacherDao teacherDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ private StudentDao studentDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private CourseScheduleComplaintsDao courseScheduleComplaintsDao;
|
|
|
|
|
|
@Autowired
|
|
|
private SysConfigDao sysConfigDao;
|
|
|
|
|
|
@Autowired
|
|
|
- private RedisCache redisCache;
|
|
|
+ private RedisCache<String, Object> redisCache;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, CourseScheduleReview> getDAO() {
|
|
@@ -169,7 +164,7 @@ public class CourseReviewServiceImpl extends BaseServiceImpl<Integer, CourseSche
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
public CourseScheduleReview addPracticeGroupReview(CourseScheduleReview courseScheduleReview) {
|
|
|
Integer courseScheduleId = courseScheduleReview.getCourseScheduleId();
|
|
|
if (courseScheduleId == null || courseScheduleId <= 0) {
|
|
@@ -181,49 +176,54 @@ public class CourseReviewServiceImpl extends BaseServiceImpl<Integer, CourseSche
|
|
|
throw new BizException("课程不存在");
|
|
|
}
|
|
|
|
|
|
- String lockKey = "course_review" + courseSchedule.getId();
|
|
|
- if (!redisCache.getLocked(lockKey, 1, 10)) {
|
|
|
- throw new BizException("评论提交中,请稍等");
|
|
|
- }
|
|
|
+ studentDao.lockUser(courseScheduleReview.getTeacherId());
|
|
|
+
|
|
|
PracticeGroup practiceGroup = practiceGroupDao.get(Long.parseLong(courseSchedule.getMusicGroupId()));
|
|
|
|
|
|
- try {
|
|
|
- CourseScheduleReview hasReview = courseScheduleReviewDao.findByCourseScheduleAndStudent(courseScheduleId.longValue(), practiceGroup.getStudentId());
|
|
|
- if (hasReview != null) {
|
|
|
- throw new BizException("评论已提交,请勿重复提交");
|
|
|
- }
|
|
|
- courseScheduleReview.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
- courseScheduleReview.setEducationalTeacherId(practiceGroup.getEducationalTeacherId());
|
|
|
- courseScheduleReview.setStudentId(practiceGroup.getStudentId());
|
|
|
- courseScheduleReview.setCreateTime(date);
|
|
|
- courseScheduleReview.setUpdateTime(date);
|
|
|
- long num = courseScheduleReviewDao.insert(courseScheduleReview);
|
|
|
- if (num <= 0) {
|
|
|
- throw new BizException("评论提交失败,请重试");
|
|
|
- }
|
|
|
+ CourseScheduleReview hasReview = courseScheduleReviewDao.findByCourseScheduleAndStudent(courseScheduleId.longValue(), practiceGroup.getStudentId());
|
|
|
+ if (hasReview != null) {
|
|
|
+ throw new BizException("评论已提交,请勿重复提交");
|
|
|
+ }
|
|
|
+ courseScheduleReview.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
+ courseScheduleReview.setEducationalTeacherId(practiceGroup.getEducationalTeacherId());
|
|
|
+ courseScheduleReview.setStudentId(practiceGroup.getStudentId());
|
|
|
+ courseScheduleReview.setCreateTime(date);
|
|
|
+ courseScheduleReview.setUpdateTime(date);
|
|
|
+ long num = courseScheduleReviewDao.insert(courseScheduleReview);
|
|
|
+ if (num <= 0) {
|
|
|
+ throw new BizException("评论提交失败,请重试");
|
|
|
+ }
|
|
|
|
|
|
- CourseHomework existHomework = courseHomeworkDao.findByCourseSchedule(courseScheduleId.longValue());
|
|
|
+ CourseHomework existHomework = courseHomeworkDao.findByCourseSchedule(courseScheduleId.longValue());
|
|
|
|
|
|
- if (StringUtils.isNotBlank(courseScheduleReview.getHomeWork()) && Objects.isNull(existHomework)) {
|
|
|
- //新增课堂作业
|
|
|
- CourseHomework courseHomework = new CourseHomework();
|
|
|
+ if (StringUtils.isNotBlank(courseScheduleReview.getHomeWork())) {
|
|
|
+ //新增课堂作业
|
|
|
+ CourseHomework courseHomework = new CourseHomework();
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseSchedule(courseSchedule.getId());
|
|
|
+
|
|
|
+ if(Objects.nonNull(existHomework)){
|
|
|
+ courseHomework.setId(existHomework.getId());
|
|
|
+ courseHomework.setContent(courseScheduleReview.getHomeWork());
|
|
|
+ courseHomework.setExpiryDate(DateUtil.addDays(date, 7));
|
|
|
+ courseHomeworkService.update(courseHomework);
|
|
|
+ }else{
|
|
|
courseHomework.setContent(courseScheduleReview.getHomeWork());
|
|
|
courseHomework.setCourseScheduleId(courseSchedule.getId());
|
|
|
courseHomework.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
courseHomework.setGroupType(courseSchedule.getGroupType());
|
|
|
courseHomework.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
courseHomework.setExpiryDate(DateUtil.addDays(date, 7));
|
|
|
- List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseSchedule(courseSchedule.getId());
|
|
|
-
|
|
|
courseHomework.setExpectNum(CollectionUtils.isEmpty(courseScheduleStudentPayments) ? 0 : courseScheduleStudentPayments.size());
|
|
|
courseHomeworkService.insert(courseHomework);
|
|
|
+ }
|
|
|
|
|
|
- if (!CollectionUtils.isEmpty(courseScheduleStudentPayments)) {
|
|
|
+ if (!CollectionUtils.isEmpty(courseScheduleStudentPayments)) {
|
|
|
// List<StudentCourseHomework> studentCourseHomeworks = new ArrayList<>();
|
|
|
- Teacher teacher = teacherDao.get(courseScheduleReview.getTeacherId());
|
|
|
- String dateStr = DateUtil.dateToString(DateUtil.addDays(date, 1), "MM月dd日");
|
|
|
- for (CourseScheduleStudentPayment courseScheduleStudentPayment : courseScheduleStudentPayments) {
|
|
|
- StudentCourseHomework studentCourseHomework = new StudentCourseHomework();
|
|
|
+ Teacher teacher = teacherDao.get(courseScheduleReview.getTeacherId());
|
|
|
+ String dateStr = DateUtil.dateToString(DateUtil.addDays(date, 1), "MM月dd日");
|
|
|
+ for (CourseScheduleStudentPayment courseScheduleStudentPayment : courseScheduleStudentPayments) {
|
|
|
+ StudentCourseHomework studentCourseHomework = new StudentCourseHomework();
|
|
|
+ if(Objects.isNull(existHomework)){
|
|
|
studentCourseHomework.setCourseHomeworkId(courseHomework.getId());
|
|
|
studentCourseHomework.setUserId(courseScheduleStudentPayment.getUserId());
|
|
|
studentCourseHomework.setCourseScheduleId(courseSchedule.getId());
|
|
@@ -232,25 +232,31 @@ public class CourseReviewServiceImpl extends BaseServiceImpl<Integer, CourseSche
|
|
|
studentCourseHomework.setStatus(YesOrNoEnum.NO);
|
|
|
studentCourseHomework.setIsView(YesOrNoEnum.NO);
|
|
|
studentCourseHomework.setIsReplied(YesOrNoEnum.NO);
|
|
|
+ studentCourseHomework.setIsRepliedTimely(0);
|
|
|
studentCourseHomeworkDao.insert(studentCourseHomework);
|
|
|
+ }else{
|
|
|
+ studentCourseHomework = studentCourseHomeworkDao.findByStudentAndCourseHomewok(existHomework.getId(), courseScheduleStudentPayment.getUserId());
|
|
|
+ }
|
|
|
|
|
|
- Map<Integer, String> userMap = new HashMap<>();
|
|
|
- userMap.put(courseScheduleStudentPayment.getUserId(), courseScheduleStudentPayment.getUserId().toString());
|
|
|
- String notifyUrl = "3?courseScheduleID=" + courseSchedule.getId() + "&studentCourseHomeworkId=" + studentCourseHomework.getId() + "&extra=0";
|
|
|
- sysMessageService.batchSendImMessage(MessageTypeEnum.IM_HOMEWORK_REMIND,courseScheduleReview.getTeacherId().toString(),
|
|
|
- new String[]{courseScheduleStudentPayment.getUserId().toString()},
|
|
|
- null,courseSchedule.getName(), dateStr,courseHomework.getContent());
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.HOMEWORK_REMIND,
|
|
|
- userMap, null, 0, notifyUrl, "STUDENT", teacher.getRealName(), courseSchedule.getName(), dateStr);
|
|
|
+ Map<Integer, String> userMap = new HashMap<>();
|
|
|
+ userMap.put(courseScheduleStudentPayment.getUserId(), courseScheduleStudentPayment.getUserId().toString());
|
|
|
+ String notifyUrl = "?courseScheduleID=" + courseSchedule.getId() + "&studentCourseHomeworkId=" + studentCourseHomework.getId() + "&extra=0";
|
|
|
+ String extra = "dayaedu" + notifyUrl + "&userId=" + courseScheduleStudentPayment.getUserId();
|
|
|
+ if (courseScheduleReview.getMsgType() != ImSendTypeEnum.TXT){
|
|
|
+ sysMessageService.batchSendImMessage(MessageTypeEnum.IM_HOMEWORK_REMIND_DETAIL,courseScheduleReview.getTeacherId().toString(),extra,
|
|
|
+ new String[]{courseScheduleStudentPayment.getUserId().toString()},
|
|
|
+ null,courseSchedule.getName(), dateStr,courseHomework.getContent());
|
|
|
+ }else {
|
|
|
+ sysMessageService.batchSendImMessage(MessageTypeEnum.IM_HOMEWORK_REMIND,courseScheduleReview.getTeacherId().toString(),extra,
|
|
|
+ new String[]{courseScheduleStudentPayment.getUserId().toString()},
|
|
|
+ null,courseSchedule.getName(), dateStr,courseHomework.getContent());
|
|
|
}
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.HOMEWORK_REMIND,
|
|
|
+ userMap, null, 0, 3+notifyUrl, "STUDENT", teacher.getRealName(), courseSchedule.getName(), dateStr);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- } finally {
|
|
|
- redisCache.releaseLocked(lockKey, 1);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
return courseScheduleReview;
|
|
|
}
|
|
|
|