ソースを参照

会员营期修改时间添加批量修改功能

xgb 1 日 前
コミット
aebc934d1f

+ 9 - 0
fs-service/src/main/java/com/fs/course/mapper/FsUserCoursePeriodDaysMapper.java

@@ -122,4 +122,13 @@ public interface FsUserCoursePeriodDaysMapper extends BaseMapper<FsUserCoursePer
 
     @Select("SELECT distinct period_id from fs_user_course_period_days  where day_date >=#{periodSTime} and day_date <=#{periodETime} ")
     List<Long> selectFsUserCoursePeriodDaysByTime(@Param("periodSTime") String periodSTime,@Param("periodETime") String periodETime);
+
+    /**
+     * @Description: 根据id获取当前营期的所有的大于该id数据lesson的id
+     * @Param:
+     * @Return:
+     * @Author xgb
+     * @Date 2025/11/18 11:04
+     */
+    List<Long> selectFsUserCoursePeriodDaysForLastById(FsUserCoursePeriodDays param);
 }

+ 78 - 24
fs-service/src/main/java/com/fs/course/service/impl/FsUserCoursePeriodDaysServiceImpl.java

@@ -344,35 +344,89 @@ public class FsUserCoursePeriodDaysServiceImpl extends ServiceImpl<FsUserCourseP
 
     @Override
     public R updateCourseTime(UpdateCourseTimeVo vo) {
-        List<FsUserCoursePeriodDays> list = fsUserCoursePeriodDaysMapper.selectBatchIds(vo.getIds());
-        list.forEach(day -> {
+        // 批量更新
+        if(vo.getBatchUpdateSwitch()!=null && vo.getBatchUpdateSwitch()==1
+                && vo.getIds()!=null && vo.getIds().size()==1){
+            Long id=vo.getIds().get(0);
+
+            FsUserCoursePeriodDays info= fsUserCoursePeriodDaysMapper.selectFsUserCoursePeriodDaysById(id);
+
+            if(info==null || info.getPeriodId()==null || info.getLesson()==null){
+                return R.error(400, "该课程参数异常,请联系管理员");
+            }
+            // 根据id获取当前营期的所有的大于该id数据lesson的id
+            FsUserCoursePeriodDays param = new FsUserCoursePeriodDays();
+            param.setPeriodId(info.getPeriodId());
+            param.setLesson(info.getLesson());
+            List<Long> ids = fsUserCoursePeriodDaysMapper.selectFsUserCoursePeriodDaysForLastById(param);
+            List<FsUserCoursePeriodDays> list = fsUserCoursePeriodDaysMapper.selectBatchIds(ids);
+            list.forEach(day -> {
+
+                // 调整时间为直接接收前端传入的年月日,不使用营期的日期(2025年6月11日 10点41分)
+                day.setStartDateTime(vo.getStartTime());
+                day.setEndDateTime(vo.getEndTime1());
+
+
+                SysConfig config = sysConfigMapper.selectConfigByConfigKey("joinTime.switch.config");
+                if (ObjectUtils.isNotEmpty(config)&&config.getConfigValue().equals("1")){
+                    day.setLastJoinTime(vo.getEndTime1());
+                }else {
+                    day.setLastJoinTime(vo.getJoinTime());
+                }
+
+                // 把营期时间改成开始时间
+                day.setDayDate(vo.getStartTime().toLocalDate());
+                // 设置状态
+                LocalDateTime compareDayTime = LocalDateTime.now();
+                if(compareDayTime.isAfter(day.getStartDateTime()) && compareDayTime.isBefore(day.getEndDateTime())){
+                    day.setStatus(1);
+                } else if(compareDayTime.isBefore(day.getStartDateTime())){
+                    day.setStatus(0);
+                } else {
+                    day.setStatus(2);
+                }
+                fsUserCoursePeriodDaysMapper.updateById(day);
+
+                // 时间加一天
+                vo.setStartTime(vo.getStartTime().plusDays(1));
+                vo.setEndTime1(vo.getEndTime1().plusDays(1));
+                vo.setJoinTime(vo.getJoinTime().plusDays(1));
+            });
+
+        }else {
+            List<FsUserCoursePeriodDays> list = fsUserCoursePeriodDaysMapper.selectBatchIds(vo.getIds());
+            list.forEach(day -> {
 //            day.setStartDateTime(LocalDateTime.of(day.getDayDate(), vo.getStartTime()));
 //            day.setEndDateTime(LocalDateTime.of(day.getDayDate(), vo.getEndTime1()));
 //            day.setLastJoinTime(LocalDateTime.of(day.getDayDate(), vo.getJoinTime()));
-            // 调整时间为直接接收前端传入的年月日,不使用营期的日期(2025年6月11日 10点41分)
-            day.setStartDateTime(vo.getStartTime());
-            day.setEndDateTime(vo.getEndTime1());
+                // 调整时间为直接接收前端传入的年月日,不使用营期的日期(2025年6月11日 10点41分)
+                day.setStartDateTime(vo.getStartTime());
+                day.setEndDateTime(vo.getEndTime1());
+
+                SysConfig config = sysConfigMapper.selectConfigByConfigKey("joinTime.switch.config");
+                if (ObjectUtils.isNotEmpty(config)&&config.getConfigValue().equals("1")){
+                    day.setLastJoinTime(vo.getEndTime1());
+                }else {
+                    day.setLastJoinTime(vo.getJoinTime());
+                }
+
+                // 把营期时间改成开始时间
+                day.setDayDate(vo.getStartTime().toLocalDate());
+                // 设置状态
+                LocalDateTime compareDayTime = LocalDateTime.now();
+                if(compareDayTime.isAfter(day.getStartDateTime()) && compareDayTime.isBefore(day.getEndDateTime())){
+                    day.setStatus(1);
+                } else if(compareDayTime.isBefore(day.getStartDateTime())){
+                    day.setStatus(0);
+                } else {
+                    day.setStatus(2);
+                }
+                fsUserCoursePeriodDaysMapper.updateById(day);
+            });
+        }
+
 
-            SysConfig config = sysConfigMapper.selectConfigByConfigKey("joinTime.switch.config");
-            if (ObjectUtils.isNotEmpty(config)&&config.getConfigValue().equals("1")){
-                day.setLastJoinTime(vo.getEndTime1());
-            }else {
-                day.setLastJoinTime(vo.getJoinTime());
-            }
 
-            // 把营期时间改成开始时间
-            day.setDayDate(vo.getStartTime().toLocalDate());
-            // 设置状态
-            LocalDateTime compareDayTime = LocalDateTime.now();
-            if(compareDayTime.isAfter(day.getStartDateTime()) && compareDayTime.isBefore(day.getEndDateTime())){
-                day.setStatus(1);
-            } else if(compareDayTime.isBefore(day.getStartDateTime())){
-                day.setStatus(0);
-            } else {
-                day.setStatus(2);
-            }
-            fsUserCoursePeriodDaysMapper.updateById(day);
-        });
         return R.ok();
     }
 

+ 3 - 0
fs-service/src/main/java/com/fs/course/vo/UpdateCourseTimeVo.java

@@ -21,4 +21,7 @@ public class UpdateCourseTimeVo {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private LocalDateTime joinTime;
     private LocalDate dayDate;
+
+    // 批量修改开关 0 关闭 1 开启 默认关闭 打开的话修改时间,后续的时间会一起改变
+    private Integer batchUpdateSwitch;
 }

+ 4 - 0
fs-service/src/main/resources/mapper/course/FsUserCoursePeriodDaysMapper.xml

@@ -239,4 +239,8 @@
         ORDER BY
             a.day_date
     </select>
+
+    <select id="selectFsUserCoursePeriodDaysForLastById" resultType="java.lang.Long">
+       select id from fs_user_course_period_days where del_flag ='0' and period_id = #{periodId} and lesson &gt;= #{lesson} order by lesson
+    </select>
 </mapper>