| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
| | | import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.biz.zbom.ZbomZhongTaiService; |
| | | import com.doumee.biz.zbom.model.IamUserRoleModel; |
| | | import com.doumee.biz.zbom.model.IamUserTypeModel; |
| | | import com.doumee.biz.zbom.model.zhongtai.ZTBaseRequst; |
| | | import com.doumee.biz.zbom.model.zhongtai.ZTConstants; |
| | | import com.doumee.config.Jwt.JwtPayLoad; |
| | | import com.doumee.config.Jwt.JwtTokenUtil; |
| | | import com.doumee.core.annotation.excel.ExcelImporter; |
| | |
| | | import com.doumee.core.utils.tyyun.TyyZosUtil; |
| | | import com.doumee.dao.admin.request.ShopImport; |
| | | import com.doumee.dao.admin.request.UserImport; |
| | | import com.doumee.dao.business.MemberMapper; |
| | | import com.doumee.dao.business.ShopMapper; |
| | | import com.doumee.core.wx.WxMiniConfig; |
| | | import com.doumee.dao.business.SmsEmailMapper; |
| | |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.dao.web.reqeust.EditUsersRequest; |
| | | import com.doumee.dao.web.reqeust.ContentShareImgDto; |
| | | import com.doumee.dao.web.reqeust.WxPhoneRequest; |
| | | import com.doumee.dao.web.response.AccountResponse; |
| | | import com.doumee.service.business.UsersService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | private SmsEmailMapper smsEmailMapper; |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | |
| | | @Autowired |
| | | private ZbomZhongTaiService zbomZhongTaiService; |
| | | |
| | | @Override |
| | | public Long create(Users users) { |
| | |
| | | } |
| | | Users users = usersMapper.selectOne(new QueryWrapper<Users>().lambda().eq(Users::getPhone,phone).last("limit 1")); |
| | | if(Objects.isNull(users)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到账户信息"); |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,账号信息不存在!"); |
| | | } |
| | | if(!Constants.equalsInteger(users.getIsdeleted(), Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前账户已删除"); |
| | | } |
| | | if(!StringUtils.equals(users.getStatus(),Constants.ZERO+"")){ |
| | | if(StringUtils.equals(users.getStatus(),Constants.ZERO+"")){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前账户已停用,请联系管理员"); |
| | | } |
| | | //验证短信 |
| | |
| | | // } |
| | | // smsEmailMapper.updateById(model); |
| | | //创建token |
| | | JwtPayLoad payLoad = new JwtPayLoad(users.getId(),Constants.ONE); |
| | | String token = JwtTokenUtil.generateToken(payLoad); |
| | | // JwtPayLoad payLoad = new JwtPayLoad(users.getId(),Constants.ONE); |
| | | // String token = JwtTokenUtil.generateToken(payLoad); |
| | | // redisTemplate.opsForValue().set(ZTConstants.BUSINESS+"_"+users.getId(),token); |
| | | String token = JwtTokenUtil.generateTokenForZb(users.getId(),ZTConstants.BUSINESS,"",redisTemplate); |
| | | AccountResponse accountResponse = new AccountResponse(); |
| | | accountResponse.setToken(token); |
| | | accountResponse.setUsers(users); |
| | |
| | | accountResponse.setSessionKey(session.getSessionKey()); |
| | | Users users = usersMapper.selectOne(new QueryWrapper<Users>().lambda().eq(Users::getOpenid,openId).last("limit 1")); |
| | | if(Objects.isNull(users)){ |
| | | accountResponse.setSessionKey(session.getSessionKey()); |
| | | return accountResponse; |
| | | } |
| | | if(!Constants.equalsInteger(users.getIsdeleted(),Constants.ZERO)){ |
| | |
| | | if(!StringUtils.equals(users.getStatus(),Constants.ZERO+"")){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前账户已停用,请联系管理员"); |
| | | } |
| | | users.setOpenid(openId); |
| | | usersMapper.updateById(users); |
| | | //创建token |
| | | JwtPayLoad payLoad = new JwtPayLoad(users.getId(),Constants.ONE); |
| | | String token = JwtTokenUtil.generateToken(payLoad); |
| | | redisTemplate.opsForValue().set(ZTConstants.BUSINESS+"_"+users.getId(),token); |
| | | accountResponse.setToken(token); |
| | | getUsersDetail(users); |
| | | accountResponse.setSessionKey(session.getSessionKey()); |
| | | accountResponse.setUsers(users); |
| | | return accountResponse; |
| | | } catch (WxErrorException e) { |
| | |
| | | } |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"微信登录异常!请联系管理员"); |
| | | } |
| | | |
| | | @Override |
| | | public AccountResponse getWxMiniPhoneLogin(WxPhoneRequest wxPhoneRequest){ |
| | | try { |
| | | WxMaPhoneNumberInfo userPhoneInfo = WxMiniConfig.wxPersonnelService.getUserService().getPhoneNoInfo( |
| | | wxPhoneRequest.getSessionKey(), wxPhoneRequest.getEncryptedData(), wxPhoneRequest.getIv()); |
| | | //获取手机号 |
| | | String phone= userPhoneInfo.getPurePhoneNumber(); |
| | | if(Objects.isNull(phone)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未获取到手机号"); |
| | | } |
| | | Users users = usersMapper.selectOne(new QueryWrapper<Users>().lambda() |
| | | .eq(Users::getPhone,phone).last("limit 1")); |
| | | AccountResponse accountResponse = new AccountResponse(); |
| | | accountResponse.setPhone(phone); |
| | | if(Objects.isNull(users)){ |
| | | return accountResponse; |
| | | } |
| | | accountResponse.setUsers(users); |
| | | //创建token |
| | | JwtPayLoad payLoad = new JwtPayLoad(users.getId(),Constants.ZERO); |
| | | String token = JwtTokenUtil.generateToken(payLoad); |
| | | redisTemplate.opsForValue().set(ZTConstants.BUSINESS+"_"+users.getId(),token); |
| | | return accountResponse; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"更新手机号失败"); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | if(Objects.isNull(users)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(Constants.equalsInteger(users.getIsdeleted(),Constants.ZERO)){ |
| | | if(!Constants.equalsInteger(users.getIsdeleted(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用户已禁用"); |
| | | } |
| | | getUsersDetail(users); |
| | |
| | | if(Objects.isNull(users)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(Constants.equalsInteger(users.getIsdeleted(),Constants.ZERO)){ |
| | | if(!Constants.equalsInteger(users.getIsdeleted(),Constants.ZERO)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"用户已禁用"); |
| | | } |
| | | getUsersDetail(users); |
| | |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public ZTBaseRequst logOff(Long userId){ |
| | | Users users = usersMapper.selectById(userId); |
| | | if(Objects.isNull(users)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(StringUtils.isBlank(users.getOpenid())){ |
| | | redisTemplate.delete(ZTConstants.BUSINESS+"_"+ users.getId()); |
| | | return null; |
| | | } |
| | | //校验用户token信息 |
| | | MemberServiceImpl.getZTToken(zbomZhongTaiService,memberMapper,usersMapper,systemDictDataBiz,users.getId(), ZTConstants.BUSINESS); |
| | | //调起中台注销接口 |
| | | ZTBaseRequst ztBaseRequst = new ZTBaseRequst(); |
| | | ztBaseRequst.setUserType(ZTConstants.BUSINESS); |
| | | ztBaseRequst.setOpenId(users.getOpenid()); |
| | | ztBaseRequst.setToken(users.getToken()); |
| | | usersMapper.update(new UpdateWrapper<Users>().lambda() |
| | | .set(Users::getOpenid,null) |
| | | .set(Users::getEditDate,new Date()) |
| | | .eq(Users::getId,users.getId()) |
| | | ); |
| | | redisTemplate.delete(ZTConstants.BUSINESS+"_"+ users.getId()); |
| | | return ztBaseRequst; |
| | | } |
| | | |
| | | } |
| | | |