| | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DESUtil; |
| | | import com.doumee.core.utils.HttpsUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.core.utils.redis.RedisUtil; |
| | | import com.doumee.core.wx.WXConstant; |
| | | import com.doumee.dao.admin.request.LaborEmpowerDTO; |
| | | import com.doumee.dao.admin.request.LaborMemberDTO; |
| | |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.system.model.SystemDictData; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.dao.web.reqeust.AccountLoginDTO; |
| | | import com.doumee.dao.web.reqeust.CheckVisitedDTO; |
| | | import com.doumee.dao.web.reqeust.VisitMemberDTO; |
| | | import com.doumee.dao.web.reqeust.VisitRecordDTO; |
| | | import com.doumee.dao.web.response.MemberVO; |
| | | import com.doumee.dao.web.response.VisitRecordVO; |
| | | import com.doumee.dao.web.response.WxAuthorizeVO; |
| | | import com.doumee.service.business.MemberService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Autowired |
| | | private UserActionJoinMapper userActionJoinMapper; |
| | | |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | |
| | | @Override |
| | | public Integer create(Member member) { |
| | |
| | | Member member = memberMapper.selectOne(new QueryWrapper<Member>().lambda() |
| | | .eq(Member::getOpenid,openId) |
| | | .eq(Member::getIsdeleted,Constants.ZERO) |
| | | .ne(Member::getType,Constants.memberType.visitor) |
| | | ); |
| | | |
| | | |
| | | |
| | | //非访客用户 进行判断是否存在用户 |
| | | if(Objects.isNull(member)&&!member.getType().equals(Constants.memberType.visitor)){ |
| | | if(member.getIsdeleted() == Constants.ONE){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户已删除,请联系管理员"); |
| | | } |
| | | if(member.getStatus() != Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户已禁用,请联系管理员"); |
| | | } |
| | | JwtPayLoad payLoad = new JwtPayLoad(Integer.toString(member.getId())); |
| | | String token = JwtTokenUtil.generateToken(payLoad); |
| | | //存储token至redis |
| | | RedisUtil.addObject(redisTemplate,Constants.RedisKeys.INTERNAL_TOKEN+"_"+member.getId(),token,Constants.RedisKeys.EXPIRE_TIME); |
| | | wxAuthorizeVO.setToken(token); |
| | | } |
| | | return wxAuthorizeVO; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public PageData<MemberVO> getVisitedMemberList(PageWrap<VisitMemberDTO> param) { |
| | | VisitMemberDTO visitMemberDTO = param.getModel(); |
| | | IPage<Member> page = new Page<>(param.getPage(), param.getCapacity()); |
| | | MPJLambdaWrapper<Member> queryWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(visitMemberDTO); |
| | | |
| | | queryWrapper.selectAs(Member::getId,MemberVO::getId); |
| | | queryWrapper.selectAs(Member::getName,MemberVO::getName); |
| | | queryWrapper.selectAs(Member::getPhone,MemberVO::getPhone); |
| | | queryWrapper.selectAs(Member::getCompanyId,MemberVO::getCompanyId); |
| | | queryWrapper.selectAs(Member::getFaceImg,MemberVO::getFaceImg); |
| | | |
| | | queryWrapper.eq(Member::getIsdeleted,Constants.ZERO); |
| | | queryWrapper.eq(Member::getStatus,Constants.ZERO); |
| | | queryWrapper.eq(Member::getCanVisit,Constants.ONE); |
| | | queryWrapper.eq(Member::getType,Constants.memberType.internal); |
| | | if(!Objects.isNull(visitMemberDTO)){ |
| | | queryWrapper.and(StringUtils.isNotBlank(visitMemberDTO.getName()), ms->ms.like(Member::getPhone,visitMemberDTO.getName()) |
| | | .or().like(Member::getPhone,visitMemberDTO.getName())); |
| | | } |
| | | queryWrapper.orderByDesc(Visits::getCreateDate); |
| | | IPage<MemberVO> result = memberJoinMapper.selectJoinPage(page, MemberVO.class,queryWrapper); |
| | | |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() + |
| | | systemDictDataBiz.queryByCode(Constants.FTP,Constants.MEMBER_IMG).getCode(); |
| | | result.getRecords().forEach(i->{ |
| | | i.setPrefixUrl(prefixUrl); |
| | | }); |
| | | |
| | | return PageData.from(result); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public WxAuthorizeVO accountLogin(AccountLoginDTO accountLoginDTO){ |
| | | if(accountLoginDTO.getAccount().length()!=18 |
| | | //&&!IdcardUtil.isValidCard(accountLoginDTO.getAccount()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,身份证号码有误,请核实后重试!"); |
| | | } |
| | | Member member = memberMapper.selectOne(new QueryWrapper<Member>().lambda() |
| | | .eq(Member::getIdcardNo, DESUtil.encrypt(Constants.EDS_PWD, accountLoginDTO.getAccount())) |
| | | .ne(Member::getType,Constants.memberType.visitor) |
| | | ); |
| | | if(Objects.isNull(member)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到用户,请联系管理员"); |
| | | } |
| | | if(member.getIsdeleted() == Constants.ONE){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户已删除,请联系管理员"); |
| | | } |
| | | if(member.getStatus() != Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户已禁用,请联系管理员"); |
| | | } |
| | | String md5Password = DESUtil.encrypt(Constants.EDS_PWD, accountLoginDTO.getPassword()); |
| | | if(!md5Password.equals(member.getPassward())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"账户密码错误!"); |
| | | } |
| | | if(StringUtils.isNotBlank(accountLoginDTO.getOpenId())){ |
| | | //先清空原有访客的openid绑定关系 |
| | | memberMapper.update(null, new UpdateWrapper<Member>().lambda() |
| | | .ne(Member::getType,Constants.memberType.visitor) |
| | | .eq(Member::getOpenid,accountLoginDTO.getOpenId()) |
| | | .set(Member::getOpenid,null) |
| | | ); |
| | | //更新当前登录用户 openId |
| | | member.setOpenid(accountLoginDTO.getOpenId()); |
| | | memberMapper.updateById(member); |
| | | } |
| | | WxAuthorizeVO wxAuthorizeVO = new WxAuthorizeVO(); |
| | | JwtPayLoad payLoad = new JwtPayLoad(Integer.toString(member.getId())); |
| | | String token = JwtTokenUtil.generateToken(payLoad); |
| | | //存储token至redis |
| | | RedisUtil.addObject(redisTemplate,Constants.RedisKeys.INTERNAL_TOKEN+"_"+member.getId(),token,Constants.RedisKeys.EXPIRE_TIME); |
| | | wxAuthorizeVO.setToken(token); |
| | | return wxAuthorizeVO; |
| | | } |
| | | |
| | | |
| | | |