Pārlūkot izejas kodu

搜索条件新增

change 3 gadi atpakaļ
vecāks
revīzija
6adea6b6af

+ 122 - 93
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/UserPeriodServiceImpl.java

@@ -80,7 +80,7 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
 
 
     @Override
-    public UserPeriodVo queryById(Long id){
+    public UserPeriodVo queryById(Long id) {
         UserPeriod db = this.baseMapper.selectById(id);
         return BeanUtil.toBean(db, UserPeriodVo.class);
     }
@@ -100,19 +100,19 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
     }
 
     /**
-    * 实体类转化成视图对象
-    *
-    * @param collection 实体类集合
-    * @return
-    */
+     * 实体类转化成视图对象
+     *
+     * @param collection 实体类集合
+     * @return
+     */
     private List<UserPeriodVo> entity2Vo(Collection<UserPeriod> collection) {
         List<UserPeriodVo> voList = collection.stream()
                 .map(any -> BeanUtil.toBean(any, UserPeriodVo.class))
                 .collect(Collectors.toList());
         if (collection instanceof Page) {
-            Page<UserPeriod> page = (Page<UserPeriod>)collection;
+            Page<UserPeriod> page = (Page<UserPeriod>) collection;
             Page<UserPeriodVo> pageVo = new Page<>();
-            BeanUtil.copyProperties(page,pageVo);
+            BeanUtil.copyProperties(page, pageVo);
             pageVo.addAll(voList);
             voList = pageVo;
         }
@@ -138,38 +138,39 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
             userPeriodStatus.setStatus(bo.getStatus());
             userPeriodStatus.setUpdateTime(DateUtils.getNowTime());
             LambdaQueryWrapper<UserPeriodStatus> lqw = Wrappers.lambdaQuery();
-            lqw.eq( UserPeriodStatus::getPeriodId, aLong);
-            lqw.eq( UserPeriodStatus::getPeriodStatus, 1);
-            userPeriodStatusService.update(userPeriodStatus,lqw);
+            lqw.eq(UserPeriodStatus::getPeriodId, aLong);
+            lqw.eq(UserPeriodStatus::getPeriodStatus, 1);
+            userPeriodStatusService.update(userPeriodStatus, lqw);
             list = userPeriodStatusService.list(lqw);
         }
-        if (!CollectionUtils.isEmpty(list)){
+        if (!CollectionUtils.isEmpty(list)) {
             UserPeriodStatus userPeriodStatus = list.get(0);
             UserPeriodVo userPeriodVo = this.queryById(userPeriodStatus.getPeriodId());
-
             LambdaQueryWrapper<UserPeriod> lqw = Wrappers.lambdaQuery();
             lqw.eq(userPeriodVo.getUserId() != null, UserPeriod::getUserId, userPeriodVo.getUserId());
             lqw.eq(userPeriodVo.getGoodsId() != null, UserPeriod::getGoodsId, userPeriodVo.getGoodsId());
             lqw.eq(userPeriodVo.getGradeId() != null, UserPeriod::getGradeId, userPeriodVo.getGradeId());
             List<UserPeriod> listPeriodVo = this.list(lqw);
-            for (UserPeriod userPeriod : listPeriodVo) {
-                LambdaQueryWrapper<UserPeriodStatus> userPeriods = Wrappers.lambdaQuery();
-                userPeriods.eq(UserPeriodStatus::getPeriodId, userPeriod.getId());
-                userPeriods.eq(UserPeriodStatus::getPeriodStatus, 1);
-                userPeriods.eq(UserPeriodStatus::getStatus, 1);
-                List<UserPeriodStatus> list1 = userPeriodStatusService.list(userPeriods);
-                if (CollectionUtils.isEmpty(list1)){
-                    return true;
-                }
-            }
-            UserPeriodEditBo userPeriodEditBo = new UserPeriodEditBo();
-            userPeriodEditBo.setUserId(userPeriodVo.getUserId());
-            userPeriodEditBo.setGoodsId(userPeriodVo.getGoodsId());
-            userPeriodEditBo.setGradeId(userPeriodVo.getGradeId());
-            userPeriodEditBo.setStatus(bo.getStatus());
-            sendPeriodSMS(userPeriodEditBo);
-            sendPeriodSevenSMS(userPeriodEditBo);
             if (bo.getStatus().equals(1)) {
+
+                for (UserPeriod userPeriod : listPeriodVo) {
+                    LambdaQueryWrapper<UserPeriodStatus> userPeriods = Wrappers.lambdaQuery();
+                    userPeriods.eq(UserPeriodStatus::getPeriodId, userPeriod.getId());
+                    userPeriods.eq(UserPeriodStatus::getPeriodStatus, 1);
+                    userPeriods.eq(UserPeriodStatus::getStatus, 1);
+                    List<UserPeriodStatus> list1 = userPeriodStatusService.list(userPeriods);
+                    if (CollectionUtils.isEmpty(list1)) {
+                        return true;
+                    }
+                }
+                UserPeriodEditBo userPeriodEditBo = new UserPeriodEditBo();
+                userPeriodEditBo.setUserId(userPeriodVo.getUserId());
+                userPeriodEditBo.setGoodsId(userPeriodVo.getGoodsId());
+                userPeriodEditBo.setGradeId(userPeriodVo.getGradeId());
+                userPeriodEditBo.setStatus(bo.getStatus());
+                sendPeriodSMS(userPeriodEditBo);
+                sendPeriodSevenSMS(userPeriodEditBo);
+
                 LambdaQueryWrapper<ClassGradeUser> classGradeUser = Wrappers.lambdaQuery();
                 classGradeUser.eq(ClassGradeUser::getUserId, userPeriodVo.getUserId());
                 classGradeUser.eq(ClassGradeUser::getGradeId, userPeriodVo.getGradeId());
@@ -178,6 +179,34 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
                 classGradeUser1.setUpdateTime(DateUtils.getNowTime());
                 List<ClassGradeUser> list1 = iClassGradeUserService.list(classGradeUser);
                 iClassGradeUserService.update(classGradeUser1, classGradeUser);
+            } else {
+                for (UserPeriod userPeriod : listPeriodVo) {
+                    LambdaQueryWrapper<UserPeriodStatus> userPeriods = Wrappers.lambdaQuery();
+                    userPeriods.eq(UserPeriodStatus::getPeriodId, userPeriod.getId());
+                    userPeriods.eq(UserPeriodStatus::getPeriodStatus, 1);
+                    userPeriods.notIn(UserPeriodStatus::getStatus, 1);
+                    List<UserPeriodStatus> list1 = userPeriodStatusService.list(userPeriods);
+                    if (CollectionUtils.isEmpty(list1)) {
+                        return true;
+                    }
+                }
+                UserPeriodEditBo userPeriodEditBo = new UserPeriodEditBo();
+                userPeriodEditBo.setUserId(userPeriodVo.getUserId());
+                userPeriodEditBo.setGoodsId(userPeriodVo.getGoodsId());
+                userPeriodEditBo.setGradeId(userPeriodVo.getGradeId());
+                userPeriodEditBo.setStatus(bo.getStatus());
+                sendPeriodSMS(userPeriodEditBo);
+                sendPeriodSevenSMS(userPeriodEditBo);
+                if (bo.getStatus().equals(1)) {
+                    LambdaQueryWrapper<ClassGradeUser> classGradeUser = Wrappers.lambdaQuery();
+                    classGradeUser.eq(ClassGradeUser::getUserId, userPeriodVo.getUserId());
+                    classGradeUser.eq(ClassGradeUser::getGradeId, userPeriodVo.getGradeId());
+                    ClassGradeUser classGradeUser1 = new ClassGradeUser();
+                    classGradeUser1.setPeriodStatus(1);
+                    classGradeUser1.setUpdateTime(DateUtils.getNowTime());
+                    List<ClassGradeUser> list1 = iClassGradeUserService.list(classGradeUser);
+                    iClassGradeUserService.update(classGradeUser1, classGradeUser);
+                }
             }
         }
         return true;
@@ -188,13 +217,13 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
      *
      * @param entity 实体类数据
      */
-    private void validEntityBeforeSave(UserPeriod entity){
+    private void validEntityBeforeSave(UserPeriod entity) {
         //TODO 做一些数据校验,如唯一约束
     }
 
     @Override
     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
-        if(isValid){
+        if (isValid) {
             //TODO 做一些业务上的校验,判断是否需要校验
         }
         return this.removeByIds(ids);
@@ -203,71 +232,71 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean editPeriodAll(UserPeriodEditBo bo) {
-            LambdaQueryWrapper<UserPeriod> lqw = Wrappers.lambdaQuery();
-            lqw.eq(bo.getUserId() != null, UserPeriod::getUserId, bo.getUserId());
-            lqw.eq(bo.getGoodsId() != null, UserPeriod::getGoodsId, bo.getGoodsId());
-            lqw.eq(bo.getGradeId() != null, UserPeriod::getGradeId, bo.getGradeId());
-            List<UserPeriod> list = this.list(lqw);
-            for (UserPeriod userPeriod : list) {
-                UserPeriodStatus userPeriodStatus = new UserPeriodStatus();
-                userPeriodStatus.setPeriodStatus(1);
-                userPeriodStatus.setStatus(bo.getStatus());
-                userPeriodStatus.setUpdateTime(DateUtils.getNowTime());
-                LambdaQueryWrapper<UserPeriodStatus> userPeriods = Wrappers.lambdaQuery();
-                userPeriods.eq( UserPeriodStatus::getPeriodId, userPeriod.getId());
-                userPeriods.eq( UserPeriodStatus::getPeriodStatus, 1);
-                userPeriodStatusService.update(userPeriodStatus,userPeriods);
-            }
+        LambdaQueryWrapper<UserPeriod> lqw = Wrappers.lambdaQuery();
+        lqw.eq(bo.getUserId() != null, UserPeriod::getUserId, bo.getUserId());
+        lqw.eq(bo.getGoodsId() != null, UserPeriod::getGoodsId, bo.getGoodsId());
+        lqw.eq(bo.getGradeId() != null, UserPeriod::getGradeId, bo.getGradeId());
+        List<UserPeriod> list = this.list(lqw);
+        for (UserPeriod userPeriod : list) {
+            UserPeriodStatus userPeriodStatus = new UserPeriodStatus();
+            userPeriodStatus.setPeriodStatus(1);
+            userPeriodStatus.setStatus(bo.getStatus());
+            userPeriodStatus.setUpdateTime(DateUtils.getNowTime());
+            LambdaQueryWrapper<UserPeriodStatus> userPeriods = Wrappers.lambdaQuery();
+            userPeriods.eq(UserPeriodStatus::getPeriodId, userPeriod.getId());
+            userPeriods.eq(UserPeriodStatus::getPeriodStatus, 1);
+            userPeriodStatusService.update(userPeriodStatus, userPeriods);
+        }
         LambdaQueryWrapper<ClassGradeUser> classGradeUser = Wrappers.lambdaQuery();
-        classGradeUser.eq( ClassGradeUser::getUserId, bo.getUserId());
-        classGradeUser.eq( ClassGradeUser::getGradeId, bo.getGradeId());
+        classGradeUser.eq(ClassGradeUser::getUserId, bo.getUserId());
+        classGradeUser.eq(ClassGradeUser::getGradeId, bo.getGradeId());
         ClassGradeUser classGradeUser1 = new ClassGradeUser();
         classGradeUser1.setPeriodStatus(bo.getStatus());
         classGradeUser1.setUpdateTime(DateUtils.getNowTime());
-        iClassGradeUserService.update(classGradeUser1,classGradeUser);
-            sendPeriodSMS(bo);
-            sendPeriodSevenSMS(bo);
+        iClassGradeUserService.update(classGradeUser1, classGradeUser);
+        sendPeriodSMS(bo);
+        sendPeriodSevenSMS(bo);
         return true;
     }
 
     private void sendPeriodSMS(UserPeriodEditBo bo) {
         GoodsVo goodsVo1 = iGoodsService.queryById(bo.getGoodsId());
-        if (bo.getStatus().equals(1)){
-        InformRemindVo informRemindVo = informRemindService.queryById(9L);
-        if (!CollectionUtils.isEmpty(informRemindVo.getInformRemindBusiness()) && !CollectionUtils.isEmpty(informRemindVo.getInformRemindBusiness().stream().filter(informRemindBusinessVo -> informRemindBusinessVo.getBusinessId().equals(goodsVo1.getBusinessId())).collect(Collectors.toList()))) {
-            if (informRemindVo.getWayStatus().equals(1)) {
-                InformUserAddBo informUserAddBo = new InformUserAddBo();
-                informUserAddBo.setUserId(bo.getUserId());
-                informUserAddBo.setSendStatus(1);
-                informUserAddBo.setSendTime(DateUtils.getNowTime());
-                informUserAddBo.setCreateTime(DateUtils.getNowTime());
-                informUserAddBo.setUpdateTime(DateUtils.getNowTime());
-                informUserAddBo.setRemindId(9L);
-                informUserAddBo.setSystemStatus(1);
-                informUserAddBo.setRemind("学时机构审核通过提醒");
-                informUserAddBo.setGoodsId(bo.getGoodsId());
-                informUserAddBo.setText("尊敬的用户:你已完成本课程的所有学时学习,经机构审核通过,需注册中心复审后即可获得继续教育学时,审核时间约15个工作日。");
-                iInformUserService.insertByAddBo(informUserAddBo);
-            }
-            if (informRemindVo.getNoteStatus().equals(1)) {
-                InformUserAddBo informUserAddBo = new InformUserAddBo();
-                informUserAddBo.setUserId(bo.getUserId());
-                informUserAddBo.setSendTime(DateUtils.getNowTime());
-                informUserAddBo.setSendStatus(1);
-                informUserAddBo.setCreateTime(DateUtils.getNowTime());
-                informUserAddBo.setUpdateTime(DateUtils.getNowTime());
-                informUserAddBo.setRemindId(9L);
-                informUserAddBo.setSystemStatus(3);
-                informUserAddBo.setRemind("学时机构审核通过提醒");
-                informUserAddBo.setGoodsId(bo.getGoodsId());
-                informUserAddBo.setText("尊敬的用户:你已完成本课程的所有学时学习,经机构审核通过,需注册中心复审后即可获得继续教育学时,审核时间约15个工作日。");
-                iInformUserService.insertByAddBo(informUserAddBo);
-                UserVo userVo = iUserService.queryById(bo.getUserId());
-                Map<String, Object> param = new HashMap<>();
-                IAliSmsService.sendInformSms(userVo.getTelphone(), JSON.toJSONString(param), schoolHoursCode);
+        if (bo.getStatus().equals(1)) {
+            InformRemindVo informRemindVo = informRemindService.queryById(9L);
+            if (!CollectionUtils.isEmpty(informRemindVo.getInformRemindBusiness()) && !CollectionUtils.isEmpty(informRemindVo.getInformRemindBusiness().stream().filter(informRemindBusinessVo -> informRemindBusinessVo.getBusinessId().equals(goodsVo1.getBusinessId())).collect(Collectors.toList()))) {
+                if (informRemindVo.getWayStatus().equals(1)) {
+                    InformUserAddBo informUserAddBo = new InformUserAddBo();
+                    informUserAddBo.setUserId(bo.getUserId());
+                    informUserAddBo.setSendStatus(1);
+                    informUserAddBo.setSendTime(DateUtils.getNowTime());
+                    informUserAddBo.setCreateTime(DateUtils.getNowTime());
+                    informUserAddBo.setUpdateTime(DateUtils.getNowTime());
+                    informUserAddBo.setRemindId(9L);
+                    informUserAddBo.setSystemStatus(1);
+                    informUserAddBo.setRemind("学时机构审核通过提醒");
+                    informUserAddBo.setGoodsId(bo.getGoodsId());
+                    informUserAddBo.setText("尊敬的用户:你已完成本课程的所有学时学习,经机构审核通过,需注册中心复审后即可获得继续教育学时,审核时间约15个工作日。");
+                    iInformUserService.insertByAddBo(informUserAddBo);
+                }
+                if (informRemindVo.getNoteStatus().equals(1)) {
+                    InformUserAddBo informUserAddBo = new InformUserAddBo();
+                    informUserAddBo.setUserId(bo.getUserId());
+                    informUserAddBo.setSendTime(DateUtils.getNowTime());
+                    informUserAddBo.setSendStatus(1);
+                    informUserAddBo.setCreateTime(DateUtils.getNowTime());
+                    informUserAddBo.setUpdateTime(DateUtils.getNowTime());
+                    informUserAddBo.setRemindId(9L);
+                    informUserAddBo.setSystemStatus(3);
+                    informUserAddBo.setRemind("学时机构审核通过提醒");
+                    informUserAddBo.setGoodsId(bo.getGoodsId());
+                    informUserAddBo.setText("尊敬的用户:你已完成本课程的所有学时学习,经机构审核通过,需注册中心复审后即可获得继续教育学时,审核时间约15个工作日。");
+                    iInformUserService.insertByAddBo(informUserAddBo);
+                    UserVo userVo = iUserService.queryById(bo.getUserId());
+                    Map<String, Object> param = new HashMap<>();
+                    IAliSmsService.sendInformSms(userVo.getTelphone(), JSON.toJSONString(param), schoolHoursCode);
+                }
             }
-        }
-    }else {
+        } else {
             InformRemindVo informRemindTwoVo = informRemindService.queryById(10L);
             if (!CollectionUtils.isEmpty(informRemindTwoVo.getInformRemindBusiness()) && !CollectionUtils.isEmpty(informRemindTwoVo.getInformRemindBusiness().stream().filter(informRemindBusinessVo -> informRemindBusinessVo.getBusinessId().equals(goodsVo1.getBusinessId())).collect(Collectors.toList()))) {
 
@@ -282,7 +311,7 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
                     informUserAddBo.setSystemStatus(1);
                     informUserAddBo.setRemind("学时机构审核不通过提醒");
                     informUserAddBo.setGoodsId(bo.getGoodsId());
-                    informUserAddBo.setText("尊敬的用户:您购买的"+goodsVo1.getGoodsName()+"课程学时机构审核不通过,为了不影响您的学习进度,请点击立即重学进行重学。");
+                    informUserAddBo.setText("尊敬的用户:您购买的" + goodsVo1.getGoodsName() + "课程学时机构审核不通过,为了不影响您的学习进度,请点击立即重学进行重学。");
                     iInformUserService.insertByAddBo(informUserAddBo);
                 }
                 if (informRemindTwoVo.getNoteStatus().equals(1)) {
@@ -296,7 +325,7 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
                     informUserAddBo.setSystemStatus(3);
                     informUserAddBo.setRemind("学时机构审核不通过提醒");
                     informUserAddBo.setGoodsId(bo.getGoodsId());
-                    informUserAddBo.setText("尊敬的用户:您购买的"+goodsVo1.getGoodsName()+"课程学时机构审核不通过,为了不影响您的学习进度,请点击立即重学进行重学。");
+                    informUserAddBo.setText("尊敬的用户:您购买的" + goodsVo1.getGoodsName() + "课程学时机构审核不通过,为了不影响您的学习进度,请点击立即重学进行重学。");
                     iInformUserService.insertByAddBo(informUserAddBo);
                     UserVo userVo = iUserService.queryById(bo.getUserId());
                     Map<String, Object> param = new HashMap<>();
@@ -309,7 +338,7 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
 
     private void sendPeriodSevenSMS(UserPeriodEditBo bo) {
         GoodsVo goodsVo1 = iGoodsService.queryById(bo.getGoodsId());
-        if (bo.getStatus().equals(1)){
+        if (bo.getStatus().equals(1)) {
             InformRemindVo informRemindVo = informRemindService.queryById(11L);
             if (!CollectionUtils.isEmpty(informRemindVo.getInformRemindBusiness()) && !CollectionUtils.isEmpty(informRemindVo.getInformRemindBusiness().stream().filter(informRemindBusinessVo -> informRemindBusinessVo.getBusinessId().equals(goodsVo1.getBusinessId())).collect(Collectors.toList()))) {
                 if (informRemindVo.getWayStatus().equals(1)) {
@@ -344,7 +373,7 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
                     IAliSmsService.sendInformSms(userVo.getTelphone(), JSON.toJSONString(param), ReminderApproval);
                 }
             }
-        }else {
+        } else {
             InformRemindVo informRemindTwoVo = informRemindService.queryById(12L);
             if (!CollectionUtils.isEmpty(informRemindTwoVo.getInformRemindBusiness()) && !CollectionUtils.isEmpty(informRemindTwoVo.getInformRemindBusiness().stream().filter(informRemindBusinessVo -> informRemindBusinessVo.getBusinessId().equals(goodsVo1.getBusinessId())).collect(Collectors.toList()))) {
 
@@ -359,7 +388,7 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
                     informUserAddBo.setSystemStatus(1);
                     informUserAddBo.setRemind("学时机构审核不通过提醒");
                     informUserAddBo.setGoodsId(bo.getGoodsId());
-                    informUserAddBo.setText("尊敬的用户:您购买的"+goodsVo1.getGoodsName()+"课程学时审核不通过,为了不影响您的学习进度,请点击立即重学进行重学。");
+                    informUserAddBo.setText("尊敬的用户:您购买的" + goodsVo1.getGoodsName() + "课程学时审核不通过,为了不影响您的学习进度,请点击立即重学进行重学。");
                     iInformUserService.insertByAddBo(informUserAddBo);
                 }
                 if (informRemindTwoVo.getNoteStatus().equals(1)) {
@@ -373,7 +402,7 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
                     informUserAddBo.setSystemStatus(3);
                     informUserAddBo.setRemind("学时机构审核不通过提醒");
                     informUserAddBo.setGoodsId(bo.getGoodsId());
-                    informUserAddBo.setText("尊敬的用户:您购买的"+goodsVo1.getGoodsName()+"课程学时审核不通过,为了不影响您的学习进度,请点击立即重学进行重学。");
+                    informUserAddBo.setText("尊敬的用户:您购买的" + goodsVo1.getGoodsName() + "课程学时审核不通过,为了不影响您的学习进度,请点击立即重学进行重学。");
                     iInformUserService.insertByAddBo(informUserAddBo);
                     UserVo userVo = iUserService.queryById(bo.getUserId());
                     Map<String, Object> param = new HashMap<>();