From e3c5378b79d23f4cebb4059c78bfbdd32cd5a2f9 Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期一, 26 四月 2021 14:02:46 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 158 insertions(+), 6 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java index 4c410c1..22efbeb 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java @@ -5,19 +5,18 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.panzhihua.common.constants.Constants; import com.panzhihua.common.constants.UserConstants; import com.panzhihua.common.exceptions.ServiceException; import com.panzhihua.common.model.dtos.PageDTO; import com.panzhihua.common.model.dtos.community.ExportUserDTO; import com.panzhihua.common.model.dtos.community.NoticeReadDTO; -import com.panzhihua.common.model.dtos.user.EexcelUserDTO; -import com.panzhihua.common.model.dtos.user.PageFeedBackDTO; -import com.panzhihua.common.model.dtos.user.PageUserAppletsBackstageDTO; -import com.panzhihua.common.model.dtos.user.SysUserFeedbackDTO; +import com.panzhihua.common.model.dtos.user.*; import com.panzhihua.common.model.vos.*; import com.panzhihua.common.model.vos.community.ComActVO; import com.panzhihua.common.model.vos.community.ComMngVolunteerMngVO; import com.panzhihua.common.model.vos.partybuilding.ActivityManagerVO; +import com.panzhihua.common.model.vos.shop.ShopStoreVO; import com.panzhihua.common.model.vos.user.*; import com.panzhihua.common.utlis.IdCard; import com.panzhihua.common.utlis.RealNameUtil; @@ -519,6 +518,35 @@ return R.fail(); } + + /** + * 修改用户志愿者状态 + * + * @param userId 志愿者用户ID + * @param type + */ + @Override + public R putUserIsVolunteerById(Long userId, int type) { + SysUserDO sysUserDO = new SysUserDO(); + sysUserDO.setIsVolunteer(type); + sysUserDO.setUserId(userId); + + SysUserDO userInDB = userDao.selectById(userId); + if(userInDB!=null) { + boolean isVol = userInDB.getIsVolunteer()==1; + if(isVol){ + return R.fail("用户已是志愿者"); + } + if(userInDB.getType()!=1){ + return R.fail("用户不是小程序用户"); + } + int update = userDao.updateById(sysUserDO); + if (update > 0) { + return R.ok(); + } + } + return R.fail(); + } /** * 用户绑定社区、小区 * @@ -552,6 +580,7 @@ //接入第三方实名认证 String idCard = loginUserInfoVO.getIdCard(); String name = loginUserInfoVO.getName(); + log.info("用户实名认证发送请求,姓名:" + name + "身份证号码:" + idCard); boolean b = RealNameUtil.authentication(idCard, name); if (!b) { return R.fail("身份认证失败:公安系统认证错误"); @@ -749,11 +778,11 @@ if(roleId.intValue() == 999999999){ sysRoleDO.setCommunityId(communityId); sysRoleDO.setRoleName("超级管理员"); - sysRoleDO.setRoleKey("chaojiguanliyuan" + communityId); + sysRoleDO.setRoleKey(Constants.ADMIN_SHOP_ROLE_KEY + communityId); }else{ sysRoleDO.setCommunityId(0L); sysRoleDO.setRoleName(administratorsUserVO.getShopStoreName()); - sysRoleDO.setRoleKey("shanghupingtai" + administratorsUserVO.getShopStorePhone()); + sysRoleDO.setRoleKey(Constants.SHOP_ROLE_KEY + administratorsUserVO.getShopStorePhone()); } sysRoleDO.setRoleSort(0); sysRoleDO.setCreateBy(administratorsUserVO.getUserId()); @@ -1571,4 +1600,127 @@ BeanUtils.copyProperties(sysUserDO, sysUserVO); return R.ok(sysUserVO); } + + /** + * 新增SysUser + * @param storeVO 请求参数 + * @return 新增结果 + */ + @Override + public R addSysUser(ShopStoreVO storeVO){ + + SysUserDO sysUserDO = new SysUserDO(); + Long roleId = 888888888L; + if (roleId.intValue() == 999999999 || roleId.intValue() == 888888888) { + Long communityId = 0L; + //新增社区高级管理员角色 + SysRoleDO sysRoleDO = new SysRoleDO(); + if(roleId.intValue() == 999999999){ + sysRoleDO.setCommunityId(communityId); + sysRoleDO.setRoleName("超级管理员"); + sysRoleDO.setRoleKey(Constants.ADMIN_SHOP_ROLE_KEY + communityId); + }else{ + sysRoleDO.setCommunityId(0L); + sysRoleDO.setRoleName(storeVO.getName()); + sysRoleDO.setRoleKey(Constants.SHOP_ROLE_KEY + storeVO.getStoreAccount()); + } + sysRoleDO.setRoleSort(0); + sysRoleDO.setCreateBy(storeVO.getLoginUserId()); + int insert = roleDAO.insert(sysRoleDO); + if (insert > 0) { + SysRoleDO sysRoleDO1 = roleDAO.selectOne(new QueryWrapper<SysRoleDO>().lambda().eq(SysRoleDO::getRoleKey, sysRoleDO.getRoleKey())); + roleId = sysRoleDO1.getRoleId(); + //新角色设置所有权限 + MenuRoleVO menuRoleVO = new MenuRoleVO(); + menuRoleVO.setIsAll(1); + menuRoleVO.setCommunityId(communityId); + menuRoleVO.setRoleId(roleId); + this.putMenuRole(menuRoleVO); + } + } + + SysRoleDO roleDO = roleDAO.selectById(roleId); + if (ObjectUtils.isEmpty(roleDO)) { + return R.fail("角色不存在"); + } + String encode = new BCryptPasswordEncoder().encode(storeVO.getStorePassword()); + BeanUtils.copyProperties(storeVO, sysUserDO); + sysUserDO.setAccount(storeVO.getStoreAccount()); + sysUserDO.setType(5); + sysUserDO.setAreaId(null); + sysUserDO.setStatus(1); + sysUserDO.setPhone(storeVO.getPhone()); + sysUserDO.setName(storeVO.getContacts()); + sysUserDO.setPassword(encode); + int insert = 0; + try { + insert = userDao.insert(sysUserDO); + + //把SysUserId赋值给店铺 + if(sysUserDO.getUserId() != null){ + userDao.updateStoreByPhone(storeVO.getPhone(),sysUserDO.getUserId()); + } + } catch (Exception e) { + e.printStackTrace(); + log.error("新增后台用户报错【{}】", e.getMessage()); + if (e.getMessage().contains("union_phone_type")) { + throw new ServiceException("手机号已经存在"); + } else if (e.getMessage().contains("union_account_type")) { + throw new ServiceException("账户已经存在"); + } + } + if (insert > 0) { + SysUserDO sysUserDO1 = userDao.selectOne(new QueryWrapper<SysUserDO>().lambda().eq(SysUserDO::getType, 5).eq(SysUserDO::getAccount, storeVO.getStoreAccount())); + Long userId = sysUserDO1.getUserId(); + SysUserRoleDO sysUserRoleDO = new SysUserRoleDO(); + sysUserRoleDO.setUserId(userId); + sysUserRoleDO.setRoleId(roleDO.getRoleId()); + int insert1 = sysUserRoleDAO.insert(sysUserRoleDO); + if (insert1 > 0) { + return R.ok(); + } + } + return R.fail(); + } + + /** + * 修改SysUser用户信息 + * @param storeVO 请求参数 + * @return 修改结果 + */ + @Override + public R editSysUser(ShopStoreVO storeVO){ + SysUserDO sysUserDO1 = userDao.selectOne(new QueryWrapper<SysUserDO>().lambda().eq(SysUserDO::getPhone,storeVO.getPhone()) + .eq(SysUserDO::getType,5)); + if(sysUserDO1 == null){ + return R.fail("未查询到后台管理用户!"); + } + String encode = new BCryptPasswordEncoder().encode(storeVO.getStorePassword()); + sysUserDO1.setPassword(encode); + if (userDao.updateById(sysUserDO1) > 0) { + return R.ok(); + } + return R.fail("密码修改失败"); + } + + /** + * 修改用户小程序首页活动提示 + * @param userEditTipsDTO 请求参数 + * @return 修改结果 + */ + public R editUserTips(SysUserEditTipsDTO userEditTipsDTO){ + //查询用户信息 + SysUserDO userDO = userDao.selectById(userEditTipsDTO.getUserId()); + if(userDO == null){ + return R.fail("未查询到用户信息"); + } + //修改用户信息 + userDO.setIsTips(userEditTipsDTO.getIsTips()); + userDao.updateById(userDO); + if(userDao.updateById(userDO) > 0){ + return R.ok(); + }else{ + return R.fail(); + } + } } -- Gitblit v1.7.1