| | |
| | | import com.ltkj.framework.config.UserHoder; |
| | | import com.ltkj.hosp.domain.DictHosp; |
| | | import com.ltkj.hosp.domain.TjCustomer; |
| | | import com.ltkj.hosp.domain.TjOrder; |
| | | import com.ltkj.hosp.mapper.TjCustomerMapper; |
| | | import com.ltkj.hosp.service.IDictHospService; |
| | | import com.ltkj.hosp.service.ITjCustomerService; |
| | | import com.ltkj.hosp.service.ITjOrderService; |
| | | import com.ltkj.system.domain.SysPost; |
| | | import com.ltkj.system.domain.SysRoleMenu; |
| | | import com.ltkj.system.domain.SysUserPost; |
| | |
| | | public class SysLoginController { |
| | | @Autowired |
| | | private SysLoginService loginService; |
| | | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | @Autowired |
| | | private SysPermissionService permissionService; |
| | | |
| | | @Resource |
| | | private ITjCustomerService customerService; |
| | | @Resource |
| | |
| | | private boolean secretKeyLogin; |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | @Autowired |
| | | private ITjOrderService tjOrderService; |
| | | @Autowired |
| | | private TjCustomerMapper tjCustomerMapper; |
| | | |
| | | /** |
| | | * 登录方法 |
| | |
| | | // 生成令牌 |
| | | String token; |
| | | if (loginBody.getMobile()) { |
| | | token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getType(),loginBody.getCode(),loginBody.getUuid()); |
| | | token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getType(), loginBody.getCode(), loginBody.getUuid()); |
| | | } else { |
| | | token = loginService.Cuslogin(loginBody.getUsername(), loginBody.getPassword(), loginBody.getType(),loginBody.getCode(),loginBody.getUuid()); |
| | | token = loginService.Cuslogin(loginBody.getUsername(), loginBody.getPassword(), loginBody.getType(), loginBody.getCode(), loginBody.getUuid()); |
| | | LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>(); |
| | | wq.eq(TjCustomer::getCusPhone, loginBody.getUsername()); |
| | | TjCustomer tjCustomer = customerService.getOne(wq); |
| | | List<Map<String ,Object>> customer = tjCustomerMapper.getCusInfoListByCardAndName(tjCustomer.getCusIdcard(),tjCustomer.getCusName()); |
| | | ajax.put("orderList",customer); |
| | | } |
| | | if (null == token) { |
| | | return success("该账号正在使用中"); |
| | |
| | | AjaxResult ajax = success(); |
| | | SysUser user = UserHoder.getLoginUser().getUser(); |
| | | if (null != user.getUserId()) { |
| | | if (secretKeyLogin) |
| | | { |
| | | if(null !=user.getDeptId()){ |
| | | 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.getHospAreaName(), |
| | | dictHosp.getExpirationTime(),dictHosp.getSecretKey())) { |
| | | if (secretKeyLogin) { |
| | | if (null != user.getDeptId()) { |
| | | SysDept sysDept = deptService.getById(user.getDeptId()); |
| | | if (null != sysDept) { |
| | | DictHosp dictHosp = hospService.getById(sysDept.getHospId()); |
| | | if (null != dictHosp) { |
| | | user.setHospName(dictHosp.getHospAreaName()); |
| | | user.setHospId(dictHosp.getHospAreaId()); |
| | | } |
| | | if (!SecurityUtils.isAdmin(user.getUserId())) { |
| | | if (null != dictHosp && dictHosp.getSecretKey() != null && dictHosp.getExpirationTime() != null) { |
| | | if (!SecurityUtils.matchesMallMerchantSecretKey(secret, dictHosp.getHospAreaId(), dictHosp.getHospAreaName(), |
| | | dictHosp.getExpirationTime(), dictHosp.getSecretKey())) { |
| | | |
| | | String userIdKey = Constants.LOGIN_USERID_KEY + user.getUserId(); |
| | | String userKey = redisCache.getCacheObject(userIdKey); |
| | | if (org.apache.commons.lang3.StringUtils.isNotEmpty(userKey)) |
| | | { |
| | | if (org.apache.commons.lang3.StringUtils.isNotEmpty(userKey)) { |
| | | redisCache.deleteObject(userIdKey); |
| | | redisCache.deleteObject(userKey); |
| | | } |
| | | throw new SecretKeyException("商家已过期请续费使用"); |
| | | } |
| | | long between = DateUtil.between(new Date(), DateUtil.endOfDay(dictHosp.getExpirationTime()), DateUnit.DAY); |
| | | if(between<=30){ |
| | | UserHoder.getLoginUser().setMessage("还有 "+between+" 天到期 请注意续费! 以免影响正常使用!"); |
| | | if (between <= 30) { |
| | | UserHoder.getLoginUser().setMessage("还有 " + between + " 天到期 请注意续费! 以免影响正常使用!"); |
| | | } |
| | | }else { |
| | | } else { |
| | | throw new SecretKeyException("请缴费使用"); |
| | | } |
| | | } |
| | |
| | | ajax.put("user", user); |
| | | ajax.put("roles", roles); |
| | | ajax.put("permissions", permissions); |
| | | ajax.put("securitMessage",UserHoder.getLoginUser().getMessage()); |
| | | ajax.put("hospName",UserHoder.getLoginUser().getHospName()); |
| | | ajax.put("securitMessage", UserHoder.getLoginUser().getMessage()); |
| | | ajax.put("hospName", UserHoder.getLoginUser().getHospName()); |
| | | } else { |
| | | Set<String> roles = new HashSet<>(); |
| | | LambdaQueryWrapper<SysRole> wq = new LambdaQueryWrapper<>(); |
| | |
| | | ajax.put("user", user1); |
| | | ajax.put("roles", roles); |
| | | ajax.put("permissions", permissions); |
| | | ajax.put("post",null); |
| | | ajax.put("securitMessage",null); |
| | | ajax.put("hospName",UserHoder.getLoginUser().getHospName()); |
| | | ajax.put("post", null); |
| | | ajax.put("securitMessage", null); |
| | | ajax.put("hospName", UserHoder.getLoginUser().getHospName()); |
| | | } |
| | | return ajax; |
| | | } |