浏览代码

submit:批量删除

yangdamao 2 年之前
父节点
当前提交
65899801c4
共有 22 个文件被更改,包括 244 次插入5 次删除
  1. 10 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamServiceImpl.java
  2. 10 2
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionChapterServiceImpl.java
  3. 12 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionModuleServiceImpl.java
  4. 11 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java
  5. 11 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseChapterServiceImpl.java
  6. 12 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseModuleServiceImpl.java
  7. 12 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionServiceImpl.java
  8. 8 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseServiceImpl.java
  9. 25 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java
  10. 10 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/bo/UserPeriodQueryBo.java
  11. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/mapper/UserPeriodMapper.java
  12. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/IUserPeriodService.java
  13. 5 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/UserPeriodServiceImpl.java
  14. 1 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/mapper/OrderGoodsMapper.java
  15. 1 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsServiceImpl.java
  16. 27 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/CheckUserExamRecordBo.java
  17. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserExamRecordMapper.java
  18. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserExamRecordService.java
  19. 6 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserExamRecordServiceImpl.java
  20. 33 0
      zhongzheng-system/src/main/resources/mapper/modules/grade/UserPeriodMapper.xml
  21. 1 1
      zhongzheng-system/src/main/resources/mapper/modules/order/OrderGoodsMapper.xml
  22. 39 0
      zhongzheng-system/src/main/resources/mapper/modules/user/UserExamRecordMapper.xml

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamServiceImpl.java

@@ -27,7 +27,9 @@ import com.zhongzheng.modules.goods.bo.GoodsAttachedQueryBo;
 import com.zhongzheng.modules.goods.domain.GoodsAttached;
 import com.zhongzheng.modules.goods.domain.GoodsAttached;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import com.zhongzheng.modules.goods.vo.GoodsAttachedVo;
 import com.zhongzheng.modules.goods.vo.GoodsAttachedVo;
+import com.zhongzheng.modules.user.bo.CheckUserExamRecordBo;
 import com.zhongzheng.modules.user.domain.User;
 import com.zhongzheng.modules.user.domain.User;
+import com.zhongzheng.modules.user.service.IUserExamRecordService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -65,6 +67,8 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
 
 
     @Autowired
     @Autowired
     private ExamMapper examMapper;
     private ExamMapper examMapper;
+    @Autowired
+    private IUserExamRecordService iUserExamRecordService;
 
 
     @Override
     @Override
     public ExamVo queryById(Long examId){
     public ExamVo queryById(Long examId){
@@ -278,10 +282,16 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
     }
     }
 
 
     @Override
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public boolean batchDelExam(QuestionBatchDelBo bo) {
     public boolean batchDelExam(QuestionBatchDelBo bo) {
         if (CollectionUtils.isEmpty(bo.getIds())){
         if (CollectionUtils.isEmpty(bo.getIds())){
             throw new CustomException("试卷ID不能为空");
             throw new CustomException("试卷ID不能为空");
         }
         }
+        CheckUserExamRecordBo checkBo = new CheckUserExamRecordBo();
+        checkBo.setExamIds(bo.getIds());
+        if (iUserExamRecordService.checkBatchUserExamRecord(checkBo) > 0){
+            throw new CustomException("存在学员已做过的试卷,不能删除,请检查!");
+        }
         return update(new LambdaUpdateWrapper<Exam>()
         return update(new LambdaUpdateWrapper<Exam>()
                 .set(Exam::getStatus,bo.getStatus())
                 .set(Exam::getStatus,bo.getStatus())
                 .in(Exam::getExamId,bo.getIds()));
                 .in(Exam::getExamId,bo.getIds()));

+ 10 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionChapterServiceImpl.java

@@ -18,6 +18,8 @@ import com.zhongzheng.modules.bank.vo.QuestionChapterVo;
 import com.zhongzheng.modules.course.bo.CourseSectionAddBo;
 import com.zhongzheng.modules.course.bo.CourseSectionAddBo;
 import com.zhongzheng.modules.goods.domain.GoodsAttached;
 import com.zhongzheng.modules.goods.domain.GoodsAttached;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
+import com.zhongzheng.modules.user.bo.CheckUserExamRecordBo;
+import com.zhongzheng.modules.user.service.IUserExamRecordService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -47,8 +49,8 @@ public class QuestionChapterServiceImpl extends ServiceImpl<QuestionChapterMappe
     private QuestionChapterMapper questionChapterMapper;
     private QuestionChapterMapper questionChapterMapper;
     @Autowired
     @Autowired
     private IGoodsAttachedService iGoodsAttachedService;
     private IGoodsAttachedService iGoodsAttachedService;
-
-
+    @Autowired
+    private IUserExamRecordService iUserExamRecordService;
     @Autowired
     @Autowired
     private IQuestionModuleChapterService iQuestionModuleChapterService;
     private IQuestionModuleChapterService iQuestionModuleChapterService;
 
 
@@ -205,10 +207,16 @@ public class QuestionChapterServiceImpl extends ServiceImpl<QuestionChapterMappe
     }
     }
 
 
     @Override
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public boolean batchDelChapterExam(QuestionBatchDelBo bo) {
     public boolean batchDelChapterExam(QuestionBatchDelBo bo) {
         if (CollectionUtils.isEmpty(bo.getIds())){
         if (CollectionUtils.isEmpty(bo.getIds())){
             throw new CustomException("章卷ID不能为空");
             throw new CustomException("章卷ID不能为空");
         }
         }
+        CheckUserExamRecordBo checkBo = new CheckUserExamRecordBo();
+        checkBo.setChapterExamIds(bo.getIds());
+        if (iUserExamRecordService.checkBatchUserExamRecord(checkBo) > 0){
+            throw new CustomException("存在学员已做过的章卷,不能删除,请检查!");
+        }
         return update(new LambdaUpdateWrapper<QuestionChapter>()
         return update(new LambdaUpdateWrapper<QuestionChapter>()
                 .set(QuestionChapter::getStatus,bo.getStatus())
                 .set(QuestionChapter::getStatus,bo.getStatus())
                 .in(QuestionChapter::getChapterExamId,bo.getIds()));
                 .in(QuestionChapter::getChapterExamId,bo.getIds()));

+ 12 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionModuleServiceImpl.java

@@ -19,6 +19,8 @@ import com.zhongzheng.modules.bank.vo.QuestionModuleVo;
 import com.zhongzheng.modules.course.domain.CourseModule;
 import com.zhongzheng.modules.course.domain.CourseModule;
 import com.zhongzheng.modules.goods.domain.GoodsAttached;
 import com.zhongzheng.modules.goods.domain.GoodsAttached;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
+import com.zhongzheng.modules.user.bo.CheckUserExamRecordBo;
+import com.zhongzheng.modules.user.service.IUserExamRecordService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -54,6 +56,9 @@ public class QuestionModuleServiceImpl extends ServiceImpl<QuestionModuleMapper,
     @Autowired
     @Autowired
     private IGoodsAttachedService iGoodsAttachedService;
     private IGoodsAttachedService iGoodsAttachedService;
 
 
+    @Autowired
+    private IUserExamRecordService iUserExamRecordService;
+
     @Override
     @Override
     public QuestionModuleVo queryById(Long questionModuleId){
     public QuestionModuleVo queryById(Long questionModuleId){
         QuestionModule db = this.baseMapper.selectById(questionModuleId);
         QuestionModule db = this.baseMapper.selectById(questionModuleId);
@@ -186,12 +191,19 @@ public class QuestionModuleServiceImpl extends ServiceImpl<QuestionModuleMapper,
     }
     }
 
 
     @Override
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public boolean batchDelModuleExam(QuestionBatchDelBo bo) {
     public boolean batchDelModuleExam(QuestionBatchDelBo bo) {
         if (CollectionUtils.isEmpty(bo.getIds())){
         if (CollectionUtils.isEmpty(bo.getIds())){
             throw new CustomException("模块卷ID不能为空");
             throw new CustomException("模块卷ID不能为空");
         }
         }
+        CheckUserExamRecordBo checkBo = new CheckUserExamRecordBo();
+        checkBo.setModuleExamIds(bo.getIds());
+        if (iUserExamRecordService.checkBatchUserExamRecord(checkBo) > 0){
+            throw new CustomException("存在学员已做过的模块卷,不能删除,请检查!");
+        }
         return update(new LambdaUpdateWrapper<QuestionModule>()
         return update(new LambdaUpdateWrapper<QuestionModule>()
                 .set(QuestionModule::getStatus,bo.getStatus())
                 .set(QuestionModule::getStatus,bo.getStatus())
+                .set(QuestionModule::getUpdateTime,DateUtils.getNowTime())
                 .in(QuestionModule::getModuleExamId,bo.getIds()));
                 .in(QuestionModule::getModuleExamId,bo.getIds()));
     }
     }
 }
 }

+ 11 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -35,6 +35,8 @@ import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsUserQuestionVo;
 import com.zhongzheng.modules.goods.vo.GoodsUserQuestionVo;
 
 
+import com.zhongzheng.modules.user.bo.CheckUserExamRecordBo;
+import com.zhongzheng.modules.user.service.IUserExamRecordService;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import org.apache.poi.xwpf.usermodel.XWPFParagraph;
 import org.apache.poi.xwpf.usermodel.XWPFParagraph;
@@ -93,6 +95,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
     @Autowired
     @Autowired
     private IExamQuestionService iExamQuestionService;
     private IExamQuestionService iExamQuestionService;
 
 
+    @Autowired
+    private IUserExamRecordService iUserExamRecordService;
+
     @Autowired
     @Autowired
     private IGoodsService iGoodsService;
     private IGoodsService iGoodsService;
 
 
@@ -1721,10 +1726,16 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
     }
     }
 
 
     @Override
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public boolean batchDelQuestion(QuestionBatchDelBo bo) {
     public boolean batchDelQuestion(QuestionBatchDelBo bo) {
         if (CollectionUtils.isEmpty(bo.getIds())){
         if (CollectionUtils.isEmpty(bo.getIds())){
             throw new CustomException("题目ID不能为空");
             throw new CustomException("题目ID不能为空");
         }
         }
+        CheckUserExamRecordBo checkBo = new CheckUserExamRecordBo();
+        checkBo.setQuestionIds(bo.getIds());
+        if (iUserExamRecordService.checkBatchUserExamRecord(checkBo) > 0){
+            throw new CustomException("存在学员已做过的题目,不能删除,请检查!");
+        }
         return update(new LambdaUpdateWrapper<Question>()
         return update(new LambdaUpdateWrapper<Question>()
                 .set(Question::getStatus,bo.getStatus())
                 .set(Question::getStatus,bo.getStatus())
                 .in(Question::getQuestionId,bo.getIds()));
                 .in(Question::getQuestionId,bo.getIds()));

+ 11 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseChapterServiceImpl.java

@@ -18,6 +18,8 @@ import com.zhongzheng.modules.course.service.*;
 import com.zhongzheng.modules.course.vo.CourseChapterVo;
 import com.zhongzheng.modules.course.vo.CourseChapterVo;
 import com.zhongzheng.modules.goods.bo.GoodsBatchDelBo;
 import com.zhongzheng.modules.goods.bo.GoodsBatchDelBo;
 import com.zhongzheng.modules.goods.domain.GoodsAttached;
 import com.zhongzheng.modules.goods.domain.GoodsAttached;
+import com.zhongzheng.modules.grade.bo.UserPeriodQueryBo;
+import com.zhongzheng.modules.grade.service.IUserPeriodService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -53,6 +55,9 @@ public class CourseChapterServiceImpl extends ServiceImpl<CourseChapterMapper, C
     @Autowired
     @Autowired
     private ICourseModuleChapterService iCourseModuleChapterService;
     private ICourseModuleChapterService iCourseModuleChapterService;
 
 
+    @Autowired
+    private IUserPeriodService iUserPeriodService;
+
     @Override
     @Override
     public CourseChapterVo queryById(Long chapterId){
     public CourseChapterVo queryById(Long chapterId){
         return this.baseMapper.getInfo(chapterId);
         return this.baseMapper.getInfo(chapterId);
@@ -200,10 +205,16 @@ public class CourseChapterServiceImpl extends ServiceImpl<CourseChapterMapper, C
     }
     }
 
 
     @Override
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public boolean batchDelChapter(GoodsBatchDelBo bo) {
     public boolean batchDelChapter(GoodsBatchDelBo bo) {
         if (CollectionUtils.isEmpty(bo.getIds())){
         if (CollectionUtils.isEmpty(bo.getIds())){
             throw new CustomException("模块ID不能为空");
             throw new CustomException("模块ID不能为空");
         }
         }
+        UserPeriodQueryBo queryBo = new UserPeriodQueryBo();
+        queryBo.setChapterIds(bo.getIds());
+        if (iUserPeriodService.checkBatchGoodsStudy(queryBo) > 0){
+            throw new CustomException("存在已有学员学习的章,不能删除,请检查!");
+        }
         return update(new LambdaUpdateWrapper<CourseChapter>()
         return update(new LambdaUpdateWrapper<CourseChapter>()
                 .set(CourseChapter::getStatus,bo.getStatus())
                 .set(CourseChapter::getStatus,bo.getStatus())
                 .in(CourseChapter::getChapterId,bo.getIds()));
                 .in(CourseChapter::getChapterId,bo.getIds()));

+ 12 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseModuleServiceImpl.java

@@ -15,6 +15,8 @@ import com.zhongzheng.modules.course.service.*;
 import com.zhongzheng.modules.course.vo.CourseModuleVo;
 import com.zhongzheng.modules.course.vo.CourseModuleVo;
 import com.zhongzheng.modules.goods.bo.GoodsBatchDelBo;
 import com.zhongzheng.modules.goods.bo.GoodsBatchDelBo;
 import com.zhongzheng.modules.goods.domain.GoodsAttached;
 import com.zhongzheng.modules.goods.domain.GoodsAttached;
+import com.zhongzheng.modules.grade.bo.UserPeriodQueryBo;
+import com.zhongzheng.modules.grade.service.IUserPeriodService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -50,6 +52,9 @@ public class CourseModuleServiceImpl extends ServiceImpl<CourseModuleMapper, Cou
     @Autowired
     @Autowired
     private ICourseMenuService iCourseMenuService;
     private ICourseMenuService iCourseMenuService;
 
 
+    @Autowired
+    private IUserPeriodService iUserPeriodService;
+
     @Override
     @Override
     public CourseModuleVo queryById(Long moduleId){
     public CourseModuleVo queryById(Long moduleId){
         CourseModule db = this.baseMapper.selectById(moduleId);
         CourseModule db = this.baseMapper.selectById(moduleId);
@@ -188,12 +193,19 @@ public class CourseModuleServiceImpl extends ServiceImpl<CourseModuleMapper, Cou
     }
     }
 
 
     @Override
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public boolean batchDelModule(GoodsBatchDelBo bo) {
     public boolean batchDelModule(GoodsBatchDelBo bo) {
         if (CollectionUtils.isEmpty(bo.getIds())){
         if (CollectionUtils.isEmpty(bo.getIds())){
             throw new CustomException("模块ID不能为空");
             throw new CustomException("模块ID不能为空");
         }
         }
+        UserPeriodQueryBo queryBo = new UserPeriodQueryBo();
+        queryBo.setModuleIds(bo.getIds());
+        if (iUserPeriodService.checkBatchGoodsStudy(queryBo) > 0){
+            throw new CustomException("存在已有学员学习的模块,不能删除,请检查!");
+        }
         return update(new LambdaUpdateWrapper<CourseModule>()
         return update(new LambdaUpdateWrapper<CourseModule>()
                 .set(CourseModule::getStatus,bo.getStatus())
                 .set(CourseModule::getStatus,bo.getStatus())
+                .set(CourseModule::getUpdateTime,DateUtils.getNowTime())
                 .in(CourseModule::getModuleId,bo.getIds()));
                 .in(CourseModule::getModuleId,bo.getIds()));
     }
     }
 
 

+ 12 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseSectionServiceImpl.java

@@ -25,6 +25,8 @@ import com.zhongzheng.modules.goods.bo.GoodsBatchDelBo;
 import com.zhongzheng.modules.goods.bo.GoodsCourseQueryBo;
 import com.zhongzheng.modules.goods.bo.GoodsCourseQueryBo;
 import com.zhongzheng.modules.goods.service.IGoodsCourseService;
 import com.zhongzheng.modules.goods.service.IGoodsCourseService;
 import com.zhongzheng.modules.goods.vo.GoodsCourseVo;
 import com.zhongzheng.modules.goods.vo.GoodsCourseVo;
+import com.zhongzheng.modules.grade.bo.UserPeriodQueryBo;
+import com.zhongzheng.modules.grade.service.IUserPeriodService;
 import com.zhongzheng.modules.grade.vo.ClassPeriodVo;
 import com.zhongzheng.modules.grade.vo.ClassPeriodVo;
 import com.zhongzheng.modules.polyv.bo.PolyvLiveQueryBo;
 import com.zhongzheng.modules.polyv.bo.PolyvLiveQueryBo;
 import com.zhongzheng.modules.polyv.service.IPolyvLiveService;
 import com.zhongzheng.modules.polyv.service.IPolyvLiveService;
@@ -98,6 +100,9 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
     @Autowired
     @Autowired
     private ICourseChapterService iCourseChapterService;
     private ICourseChapterService iCourseChapterService;
 
 
+    @Autowired
+    private IUserPeriodService iUserPeriodService;
+
     @Override
     @Override
     public CourseSectionVo queryById(Long sectionId){
     public CourseSectionVo queryById(Long sectionId){
         CourseSection db = this.baseMapper.selectById(sectionId);
         CourseSection db = this.baseMapper.selectById(sectionId);
@@ -639,12 +644,19 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
     }
     }
 
 
     @Override
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public boolean batchDelSection(GoodsBatchDelBo bo) {
     public boolean batchDelSection(GoodsBatchDelBo bo) {
         if (CollectionUtils.isEmpty(bo.getIds())){
         if (CollectionUtils.isEmpty(bo.getIds())){
             throw new CustomException("节ID不能为空");
             throw new CustomException("节ID不能为空");
         }
         }
+        UserPeriodQueryBo queryBo = new UserPeriodQueryBo();
+        queryBo.setSectionIds(bo.getIds());
+        if (iUserPeriodService.checkBatchGoodsStudy(queryBo) > 0){
+            throw new CustomException("存在已有学员学习的节,不能删除,请检查!");
+        }
         return update(new LambdaUpdateWrapper<CourseSection>()
         return update(new LambdaUpdateWrapper<CourseSection>()
                 .set(CourseSection::getStatus,bo.getStatus())
                 .set(CourseSection::getStatus,bo.getStatus())
+                .set(CourseSection::getUpdateTime,DateUtils.getNowTime())
                 .in(CourseSection::getSectionId,bo.getIds()));
                 .in(CourseSection::getSectionId,bo.getIds()));
     }
     }
 
 

+ 8 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseServiceImpl.java

@@ -34,6 +34,7 @@ import com.zhongzheng.modules.goods.vo.GoodsPeriodVo;
 import com.zhongzheng.modules.goods.vo.GoodsUserVo;
 import com.zhongzheng.modules.goods.vo.GoodsUserVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
+import com.zhongzheng.modules.grade.bo.UserPeriodQueryBo;
 import com.zhongzheng.modules.grade.bo.UserPeriodStatusAddBo;
 import com.zhongzheng.modules.grade.bo.UserPeriodStatusAddBo;
 import com.zhongzheng.modules.grade.domain.UserPeriodStatus;
 import com.zhongzheng.modules.grade.domain.UserPeriodStatus;
 import com.zhongzheng.modules.grade.service.IClassGradeUserService;
 import com.zhongzheng.modules.grade.service.IClassGradeUserService;
@@ -150,12 +151,19 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
     }
     }
 
 
     @Override
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public boolean batchDelCourse(GoodsBatchDelBo bo) {
     public boolean batchDelCourse(GoodsBatchDelBo bo) {
         if (CollectionUtils.isEmpty(bo.getIds())){
         if (CollectionUtils.isEmpty(bo.getIds())){
             throw new CustomException("课程ID不能为空");
             throw new CustomException("课程ID不能为空");
         }
         }
+        UserPeriodQueryBo queryBo = new UserPeriodQueryBo();
+        queryBo.setCourseIds(bo.getIds());
+        if (iUserPeriodService.checkBatchGoodsStudy(queryBo) > 0){
+            throw new CustomException("存在已有学员学习的课程,不能删除,请检查!");
+        }
         return update(new LambdaUpdateWrapper<Course>()
         return update(new LambdaUpdateWrapper<Course>()
                 .set(Course::getStatus,bo.getStatus())
                 .set(Course::getStatus,bo.getStatus())
+                .set(Course::getUpdateTime,DateUtils.getNowTime())
                 .in(Course::getCourseId,bo.getIds()));
                 .in(Course::getCourseId,bo.getIds()));
     }
     }
 
 

+ 25 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -731,22 +731,47 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     }
     }
 
 
     @Override
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public boolean GoodsBatchUpdateStatusBo(GoodsBatchUpdateStatusBo bo) {
     public boolean GoodsBatchUpdateStatusBo(GoodsBatchUpdateStatusBo bo) {
         if (CollectionUtils.isEmpty(bo.getGoodsIds())){
         if (CollectionUtils.isEmpty(bo.getGoodsIds())){
             throw new CustomException("商品ID不能为空");
             throw new CustomException("商品ID不能为空");
         }
         }
+        if (bo.getGoodsStatus() !=-1) {
+            List<Goods> goodsList = listByIds(bo.getGoodsIds());
+            if (goodsList.stream().anyMatch(x -> x.getStatus() == 0) && bo.getGoodsStatus() == 1) {
+                throw new CustomException("存在无效商品不允许上架,请检查!");
+            }
+            if (goodsList.stream().anyMatch(x -> Validator.isNotEmpty(x.getValidityEndTime())&&x.getValidityEndTime() < DateUtils.getNowTime()) && bo.getGoodsStatus() == 1) {
+                throw new CustomException("存在过期商品不允许上架,请检查!");
+            }
+        }
         return update(new LambdaUpdateWrapper<Goods>()
         return update(new LambdaUpdateWrapper<Goods>()
                 .set(Goods::getGoodsStatus,bo.getGoodsStatus())
                 .set(Goods::getGoodsStatus,bo.getGoodsStatus())
+                .set(Goods::getUpdateTime,DateUtils.getNowTime())
                 .in(Goods::getGoodsId,bo.getGoodsIds()));
                 .in(Goods::getGoodsId,bo.getGoodsIds()));
     }
     }
 
 
     @Override
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public boolean batchDelGoods(GoodsBatchDelBo bo) {
     public boolean batchDelGoods(GoodsBatchDelBo bo) {
         if (CollectionUtils.isEmpty(bo.getIds())){
         if (CollectionUtils.isEmpty(bo.getIds())){
             throw new CustomException("商品ID不能为空");
             throw new CustomException("商品ID不能为空");
         }
         }
+        if (bo.getStatus() ==-1||bo.getStatus() ==0) {
+            List<Long> payStatus = new ArrayList<>();
+            payStatus.add(2L);
+            payStatus.add(3L);
+            payStatus.add(4L);
+            //查看是否有出售过
+            List<OrderGoods> orderGoodsList = iOrderGoodsService.list(new LambdaQueryWrapper< OrderGoods >().in(OrderGoods::getGoodsId,bo.getIds())
+                    .in(OrderGoods::getPayStatus,payStatus).ne(OrderGoods::getRefundStatus,2));
+            if(CollectionUtils.isNotEmpty(orderGoodsList)){
+                throw new CustomException("存在已购买商品,无法改变状态,请检查!");
+            }
+        }
         return update(new LambdaUpdateWrapper<Goods>()
         return update(new LambdaUpdateWrapper<Goods>()
                 .set(Goods::getStatus,bo.getStatus())
                 .set(Goods::getStatus,bo.getStatus())
+                .set(Goods::getUpdateTime,DateUtils.getNowTime())
                 .in(Goods::getGoodsId,bo.getIds()));
                 .in(Goods::getGoodsId,bo.getIds()));
     }
     }
 
 

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/bo/UserPeriodQueryBo.java

@@ -6,6 +6,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.EqualsAndHashCode;
 
 
 import java.util.Date;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.HashMap;
 
 
@@ -73,4 +74,13 @@ public class UserPeriodQueryBo extends BaseEntity {
 	private Long todayEndTime;
 	private Long todayEndTime;
 	@ApiModelProperty("章卷ID")
 	@ApiModelProperty("章卷ID")
 	private Long chapterExamId;
 	private Long chapterExamId;
+
+	@ApiModelProperty("课程IDs")
+	private List<Long> courseIds;
+	@ApiModelProperty("模块IDs")
+	private List<Long> moduleIds;
+	@ApiModelProperty("章IDs")
+	private List<Long> chapterIds;
+	@ApiModelProperty("节IDs")
+	private List<Long> sectionIds;
 }
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/mapper/UserPeriodMapper.java

@@ -24,4 +24,6 @@ public interface UserPeriodMapper extends BaseMapper<UserPeriod> {
     Long selectCountConfirmPeriod(@Param("userId") Long userId, @Param("goodsId") Long goodsId);
     Long selectCountConfirmPeriod(@Param("userId") Long userId, @Param("goodsId") Long goodsId);
 
 
     Long todayStudySectionNum(UserPeriodQueryBo bo);
     Long todayStudySectionNum(UserPeriodQueryBo bo);
+
+    Long checkBatchGoodsStudy(UserPeriodQueryBo bo);
 }
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/IUserPeriodService.java

@@ -29,6 +29,8 @@ public interface IUserPeriodService extends IService<UserPeriod> {
 
 
 	Long checkGoodsStudy(UserPeriodQueryBo bo);
 	Long checkGoodsStudy(UserPeriodQueryBo bo);
 
 
+	Long checkBatchGoodsStudy(UserPeriodQueryBo bo);
+
 	/**
 	/**
 	 * 查询列表
 	 * 查询列表
 	 */
 	 */

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/UserPeriodServiceImpl.java

@@ -174,6 +174,11 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
         return this.baseMapper.checkGoodsStudy(bo);
         return this.baseMapper.checkGoodsStudy(bo);
     }
     }
 
 
+    @Override
+    public Long checkBatchGoodsStudy(UserPeriodQueryBo bo) {
+        return this.baseMapper.checkBatchGoodsStudy(bo);
+    }
+
     @Override
     @Override
     public List<UserPeriodVo> queryList(UserPeriodQueryBo bo) {
     public List<UserPeriodVo> queryList(UserPeriodQueryBo bo) {
         LambdaQueryWrapper<UserPeriod> lqw = Wrappers.lambdaQuery();
         LambdaQueryWrapper<UserPeriod> lqw = Wrappers.lambdaQuery();

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/mapper/OrderGoodsMapper.java

@@ -17,7 +17,7 @@ import java.util.List;
  * @date 2021-11-08
  * @date 2021-11-08
  */
  */
 public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
 public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
-    List<OrderGoodsVo> selectList(OrderGoodsQueryBo bo);
+    List<OrderGoodsVo> selectListBybo(OrderGoodsQueryBo bo);
 
 
     OrderGoodsVo selectDetail(OrderGoodsQueryBo bo);
     OrderGoodsVo selectDetail(OrderGoodsQueryBo bo);
 
 

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsServiceImpl.java

@@ -165,7 +165,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
 
 
     @Override
     @Override
     public List<OrderGoodsVo> selectList(OrderGoodsQueryBo bo) {
     public List<OrderGoodsVo> selectList(OrderGoodsQueryBo bo) {
-        return orderGoodsMapper.selectList(bo);
+        return orderGoodsMapper.selectListBybo(bo);
     }
     }
 
 
 
 

+ 27 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/CheckUserExamRecordBo.java

@@ -0,0 +1,27 @@
+package com.zhongzheng.modules.user.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 校验用户做题记录
+ *
+ * @author hjl
+ * @date 2021-12-15
+ */
+@Data
+@ApiModel("校验用户做题记录")
+public class CheckUserExamRecordBo{
+
+	@ApiModelProperty("模块卷IDs")
+	private List<Long> moduleExamIds;
+	@ApiModelProperty("章卷IDs")
+	private List<Long> chapterExamIds;
+	@ApiModelProperty("试卷IDs")
+	private List<Long> examIds;
+	@ApiModelProperty("题目IDs")
+	private List<Long> questionIds;
+}

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserExamRecordMapper.java

@@ -3,6 +3,7 @@ package com.zhongzheng.modules.user.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.course.bo.CourseQueryBo;
 import com.zhongzheng.modules.course.bo.CourseQueryBo;
 import com.zhongzheng.modules.course.vo.CourseVo;
 import com.zhongzheng.modules.course.vo.CourseVo;
+import com.zhongzheng.modules.user.bo.CheckUserExamRecordBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordQueryBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordQueryBo;
 import com.zhongzheng.modules.user.domain.UserExamRecord;
 import com.zhongzheng.modules.user.domain.UserExamRecord;
 import com.zhongzheng.modules.user.vo.UserExamRecordVo;
 import com.zhongzheng.modules.user.vo.UserExamRecordVo;
@@ -36,4 +37,6 @@ public interface UserExamRecordMapper extends BaseMapper<UserExamRecord> {
     List<UserExamRecordVo> selectGroupList(UserExamRecordQueryBo bo);
     List<UserExamRecordVo> selectGroupList(UserExamRecordQueryBo bo);
 
 
     UserExamRecordVo getUserDoLast(UserExamRecordQueryBo bo);
     UserExamRecordVo getUserDoLast(UserExamRecordQueryBo bo);
+
+    Long checkBatchUserExamRecord(CheckUserExamRecordBo bo);
 }
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserExamRecordService.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.modules.user.service;
 package com.zhongzheng.modules.user.service;
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhongzheng.modules.user.bo.CheckUserExamRecordBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordAddBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordAddBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordEditBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordEditBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordQueryBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordQueryBo;
@@ -35,6 +36,8 @@ public interface IUserExamRecordService extends IService<UserExamRecord> {
 
 
     Long getUserDoQuestionNum(UserExamRecordQueryBo bo);
     Long getUserDoQuestionNum(UserExamRecordQueryBo bo);
 
 
+    Long checkBatchUserExamRecord(CheckUserExamRecordBo bo);
+
     Boolean delUserBankHistory(Long userId, Long goodsId, Long orderGoodsId);
     Boolean delUserBankHistory(Long userId, Long goodsId, Long orderGoodsId);
 
 
     /**
     /**

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserExamRecordServiceImpl.java

@@ -11,6 +11,7 @@ import com.zhongzheng.modules.collect.service.ICollectBankService;
 import com.zhongzheng.modules.collect.service.ICollectQuestionService;
 import com.zhongzheng.modules.collect.service.ICollectQuestionService;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
 import com.zhongzheng.modules.order.vo.OrderGoodsVo;
 import com.zhongzheng.modules.order.vo.OrderGoodsVo;
+import com.zhongzheng.modules.user.bo.CheckUserExamRecordBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordAddBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordAddBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordEditBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordEditBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordQueryBo;
 import com.zhongzheng.modules.user.bo.UserExamRecordQueryBo;
@@ -85,6 +86,11 @@ public class UserExamRecordServiceImpl extends ServiceImpl<UserExamRecordMapper,
         return this.baseMapper.getUserDoQuestionNum(bo);
         return this.baseMapper.getUserDoQuestionNum(bo);
     }
     }
 
 
+    @Override
+    public Long checkBatchUserExamRecord(CheckUserExamRecordBo bo) {
+        return this.baseMapper.checkBatchUserExamRecord(bo);
+    }
+
     @Override
     @Override
     public Boolean delUserBankHistory(Long userId, Long goodsId,Long orderGoodsId) {
     public Boolean delUserBankHistory(Long userId, Long goodsId,Long orderGoodsId) {
         //删除做题历史
         //删除做题历史

+ 33 - 0
zhongzheng-system/src/main/resources/mapper/modules/grade/UserPeriodMapper.xml

@@ -89,6 +89,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
         </if>
     </select>
     </select>
 
 
+    <select id="checkBatchGoodsStudy" parameterType="com.zhongzheng.modules.grade.bo.UserPeriodQueryBo" resultType="Long">
+        SELECT
+        IFNULL(count(*),0)
+        FROM
+        user_period up
+        WHERE
+        1=1
+        <if test="sectionIds != null and sectionIds.size()!=0 ">
+            AND up.section_id in
+            <foreach collection="sectionIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="courseIds != null and courseIds.size()!=0 ">
+            AND up.course_id  in
+            <foreach collection="courseIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="moduleIds != null and moduleIds.size()!=0 ">
+            AND up.module_id in
+            <foreach collection="moduleIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="chapterIds != null and chapterIds.size()!=0 ">
+            AND up.chapter_id in
+            <foreach collection="chapterIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
     <select id="selectCountPeriod" parameterType="map" resultType="Long">
     <select id="selectCountPeriod" parameterType="map" resultType="Long">
         SELECT
         SELECT
             COUNT(1)
             COUNT(1)

+ 1 - 1
zhongzheng-system/src/main/resources/mapper/modules/order/OrderGoodsMapper.xml

@@ -103,7 +103,7 @@
         <result property="goodsLearningOrder" column="goods_learning_order"/>
         <result property="goodsLearningOrder" column="goods_learning_order"/>
     </resultMap>
     </resultMap>
 
 
-    <select id="selectList" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
+    <select id="selectListBybo" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
             resultMap="OrderGoodsResultVo">
             resultMap="OrderGoodsResultVo">
         SELECT
         SELECT
         og.*,
         og.*,

+ 39 - 0
zhongzheng-system/src/main/resources/mapper/modules/user/UserExamRecordMapper.xml

@@ -411,4 +411,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             LIMIT 1
             LIMIT 1
     </select>
     </select>
 
 
+    <select id="checkBatchUserExamRecord" parameterType="com.zhongzheng.modules.user.bo.CheckUserExamRecordBo" resultType="Long">
+        SELECT
+        IFNULL(count(*),0)
+        FROM
+        user_exam_record up
+        WHERE
+        1=1
+        <if test="moduleExamIds != null and moduleExamIds.size()!=0 ">
+            AND up.module_exam_id in
+            <foreach collection="moduleExamIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="chapterExamIds != null and chapterExamIds.size()!=0 ">
+            AND up.chapter_exam_id  in
+            <foreach collection="chapterExamIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="examIds != null and examIds.size()!=0 ">
+            AND up.exam_id in
+            <foreach collection="examIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="questionIds != null and questionIds.size()!=0 ">
+            <foreach collection="questionIds" item="item" index="index">
+                <choose>
+                    <when test="index == questionIds.size()-1">
+                        AND up.do_question_ids LIKE concat('%', #{item}, '%')
+                    </when>
+                    <otherwise>
+                        AND up.do_question_ids LIKE concat('%', #{item}, '%') OR
+                    </otherwise>
+                </choose>
+            </foreach>
+        </if>
+    </select>
+
 </mapper>
 </mapper>