Parcourir la source

积分修改逻辑

change il y a 4 ans
Parent
commit
0126a529de

+ 23 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserPlanServiceImpl.java

@@ -2,6 +2,7 @@ package com.zhongzheng.modules.user.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -12,6 +13,7 @@ import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.modules.exam.vo.ExamArrangementTimeVo;
 import com.zhongzheng.modules.user.domain.UserPlanCource;
 import com.zhongzheng.modules.user.domain.UserStudyRecord;
+import com.zhongzheng.modules.user.service.IOrderPossessUserService;
 import com.zhongzheng.modules.user.service.IUserPlanCourceService;
 import com.zhongzheng.modules.user.service.IUserStudyRecordService;
 import com.zhongzheng.modules.user.vo.*;
@@ -52,6 +54,9 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
     @Autowired
     private IUserStudyRecordService userStudyRecordService;
 
+    @Autowired
+    private IOrderPossessUserService iOrderPossessUserService;
+
     @Override
     public UserPlanVo queryById(Long userId){
         UserPlan db = this.baseMapper.selectById(userId);
@@ -135,6 +140,15 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
         if (rank > 0){
             throw new IllegalArgumentException("您当前有课程的计划,请到计划修改上修改计划");
         }
+        //查询是否拥有该课程
+        Arrays.stream(bo.getCourseId()).forEach(a ->{
+            Integer i = Validator.isNotNull(iOrderPossessUserService.queryByTypeAndId(Convert.toLong(a),1,bo.getUserId()))?1:0;
+            if (i < 1){
+                throw new IllegalArgumentException("您没有拥有该课程");
+            }
+        });
+
+
         //自定义学习计划,自动生成计划
         if (bo.getCourseId() != null && bo.getStudyCount() == null){
             UserPlanVo userPlanVo = generateSelf(bo);
@@ -643,7 +657,9 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
 
         //总节数
         Integer sectionNum = planVo.getSectionNum();
-
+        if(sectionNum <= 0){
+            throw new IllegalArgumentException("该课程没有节数,无法生成计划");
+        }
 
         //获得今天日期,将每天节数写入
         Calendar cal = Calendar.getInstance();
@@ -797,6 +813,9 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
 
         //总节数
         Integer sectionNum = coursePlanVo.getSectionNum();
+        if(sectionNum <= 0){
+            throw new IllegalArgumentException("该课程没有节数,无法生成计划");
+        }
         userPlanVo.setPitchNum(Convert.toLong(sectionNum));
 
         //获得今天日期,将每天节数写入
@@ -901,6 +920,9 @@ public class UserPlanServiceImpl extends ServiceImpl<UserPlanMapper, UserPlan> i
 
         //总节数
         Integer sectionNum = coursePlanVo.getSectionNum();
+        if(sectionNum <= 0){
+            throw new IllegalArgumentException("该课程没有节数,无法生成计划");
+        }
         userPlanVo.setPitchNum(Convert.toLong(sectionNum));
 
         //获得今天日期,将每天节数写入