zjh
2023-10-18 334ecc3510c6bfa4a14a05b5e1c2badcaebe69fb
ltkj-framework/src/main/java/com/ltkj/framework/web/service/SysLoginService.java
@@ -114,8 +114,11 @@
        Authentication authentication = null;
        try {
            //登录密码解密
            UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, RsaUtils.decryptByPrivateKey(password));
            //UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
            String s = RsaUtils.decryptByPrivateKey(password);
            if(username.equals("10001")){
                s=username+s;
            }
            UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username,s);
            AuthenticationContextHolder.setContext(authenticationToken);
            // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
            authentication = authenticationManager.authenticate(authenticationToken);
@@ -140,25 +143,26 @@
            Long userId =loginUser.getUser().getUserId();
            SysUser user = userService.getById(userId);
            if(null !=user && null !=user.getDeptId()){
//                loginUser.getUser().setOrgId(user.getOrgId());
                if(!SecurityUtils.isAdmin(user.getUserId())){
                    SysDept sysDept = deptService.getById(user.getDeptId());
                    if (null != sysDept) {
                        DictHosp dictHosp = hospService.getById(sysDept.getHospId());
                        if(null !=dictHosp && dictHosp.getSecretKey() !=null && dictHosp.getExpirationTime() !=null){
                            if (!SecurityUtils.matchesMallMerchantSecretKey(secret,dictHosp.getHospAreaId(),dictHosp.getAreaid(),
                                    dictHosp.getExpirationTime(),dictHosp.getSecretKey())) {
                                throw new SecretKeyException("商家已过期请续费使用");
                            }
                            long between = DateUtil.between(new Date(), DateUtil.endOfDay(dictHosp.getExpirationTime()), DateUnit.DAY);
                            if(between<=30){
                                loginUser.setMessage("还有 "+between+" 天到期 请注意续费! 以免影响正常使用!");
                            }else {
                                loginUser.setMessage(null);
                            }
                        }else {
                            throw new SecretKeyException("请缴费使用");
                        if(null !=dictHosp){
                            loginUser.setHospName(dictHosp.getHospAreaName());
                            if(!SecurityUtils.isAdmin(user.getUserId())){
                                if(dictHosp.getSecretKey() != null && dictHosp.getExpirationTime() != null){
                                    if (!SecurityUtils.matchesMallMerchantSecretKey(secret,dictHosp.getHospAreaId(),dictHosp.getHospAreaName(),
                                            dictHosp.getExpirationTime(),dictHosp.getSecretKey())) {
                                        throw new SecretKeyException("商家已过期请续费使用");
                                    }
                                    long between = DateUtil.between(new Date(), DateUtil.endOfDay(dictHosp.getExpirationTime()), DateUnit.DAY);
                                    if(between<=30){
                                        loginUser.setMessage("还有 "+between+" 天到期 请注意续费! 以免影响正常使用!");
                                    }else {
                                        loginUser.setMessage(null);
                                    }
                                }else {
                                    throw new SecretKeyException("请缴费使用");
                                }
                        }
                    }
                }