فهرست منبع

修改课程定时任务

cy 3 سال پیش
والد
کامیت
922563f98b

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleRepliedDao.java

@@ -66,4 +66,6 @@ public interface CourseScheduleRepliedDao extends BaseMapper<CourseScheduleRepli
     CourseRepliedVo selectReplied(CourseScheduleReplied replied);
 
     void insertBatch(List<CourseScheduleStudentVo> list);
+
+    void deleteBatch(List<Long> list);
 }

+ 15 - 22
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -1656,29 +1656,22 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         if (CollectionUtils.isNotEmpty(userList)) {
             List<CourseScheduleStudentVo> practiceList = userList.stream().filter(s -> s.getType().equals(CourseScheduleEnum.PRACTICE.getCode())).collect(Collectors.toList());
             if (CollectionUtils.isNotEmpty(practiceList)) {//陪练课
-                //校验评价是否存在
-                List<Long> ids = practiceList.stream().map(CourseScheduleStudentVo::getCourseId).collect(Collectors.toList());
-                List<CourseScheduleReplied> replieds = repliedDao.selectList(Wrappers.<CourseScheduleReplied>lambdaQuery().in(CourseScheduleReplied::getCourseScheduleId, ids));
-                if (CollectionUtils.isNotEmpty(replieds)) {
-                    List<Long> courseIds = replieds.stream().map(CourseScheduleReplied::getCourseScheduleId).collect(Collectors.toList());
-                    practiceList = practiceList.stream().filter(s -> !courseIds.contains(s.getCourseId())).collect(Collectors.toList());
-                }
+                //老师课酬状态改为待结算
+                courseScheduleTeacherSalaryService.update(null, Wrappers.<CourseScheduleTeacherSalary>lambdaUpdate()
+                        .set(CourseScheduleTeacherSalary::getStatus, TeacherSalaryEnum.WAIT.getCode())
+                        .in(CourseScheduleTeacherSalary::getCourseScheduleId, practiceList.stream().map(CourseScheduleStudentVo::getCourseId).collect(Collectors.toList())));
+
                 //创建课程评论
-                if (CollectionUtils.isNotEmpty(practiceList)) {
-                    repliedDao.insertBatch(practiceList);
-
-                    //老师课酬状态改为已完成
-                    courseScheduleTeacherSalaryService.update(null, Wrappers.<CourseScheduleTeacherSalary>lambdaUpdate()
-                            .set(CourseScheduleTeacherSalary::getStatus, TeacherSalaryEnum.WAIT.getCode())
-                            .in(CourseScheduleTeacherSalary::getCourseScheduleId, practiceList.stream().map(CourseScheduleStudentVo::getCourseId).collect(Collectors.toList())));
-
-                    //清除缓存
-                    for (CourseScheduleStudentVo practice : practiceList) {
-                        //清除学生统计缓存
-                        redissonClient.getBucket(CacheNameEnum.STUDENT_TOTAL.getRedisKey(practice.getStudentId())).delete();
-                        //清除老师统计缓存
-                        redissonClient.getBucket(CacheNameEnum.TEACHER_TOTAL.getRedisKey(practice.getTeacherId())).delete();
-                    }
+                List<Long> ids = practiceList.stream().map(CourseScheduleStudentVo::getCourseId).collect(Collectors.toList());
+                repliedDao.deleteBatch(ids);
+                repliedDao.insertBatch(practiceList);
+
+                //清除缓存
+                for (CourseScheduleStudentVo practice : practiceList) {
+                    //清除学生统计缓存
+                    redissonClient.getBucket(CacheNameEnum.STUDENT_TOTAL.getRedisKey(practice.getStudentId())).delete();
+                    //清除老师统计缓存
+                    redissonClient.getBucket(CacheNameEnum.TEACHER_TOTAL.getRedisKey(practice.getTeacherId())).delete();
                 }
             }
 

+ 6 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleRepliedMapper.xml

@@ -82,6 +82,12 @@
             (#{item.studentId},#{item.courseId},#{item.type},#{item.courseGroupId})
         </foreach>
     </insert>
+    <delete id="deleteBatch" parameterType="java.util.List">
+        DELETE FROM course_schedule_replied WHERE course_schedule_id_ IN
+        <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </delete>
 
     <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.CourseScheduleRepliedVo">
         SELECT