From fe4cd9bce38617b24776e6637d28ea899235dd5c Mon Sep 17 00:00:00 2001
From: 101captain <237651143@qq.com>
Date: 星期一, 27 九月 2021 13:34:27 +0800
Subject: [PATCH] 修改新增用户信息

---
 springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/UserServiceImpl.java |  160 +++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 107 insertions(+), 53 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 268d340..5f45e24 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
@@ -14,6 +14,8 @@
 
 import javax.annotation.Resource;
 
+import com.panzhihua.service_user.dao.*;
+import com.panzhihua.service_user.model.dos.*;
 import org.apache.commons.lang.time.DateFormatUtils;
 import org.apache.commons.lang.time.DateUtils;
 import org.springframework.beans.BeanUtils;
@@ -81,34 +83,6 @@
 import com.panzhihua.common.utlis.StringUtils;
 import com.panzhihua.common.utlis.WxUtil;
 import com.panzhihua.common.utlis.WxXCXTempSend;
-import com.panzhihua.service_user.dao.ComMngFamilyInfoDAO;
-import com.panzhihua.service_user.dao.ComMngUserTagDAO;
-import com.panzhihua.service_user.dao.EventGridMemberBuildingRelationMapper;
-import com.panzhihua.service_user.dao.LcCompareMemberCodeMapper;
-import com.panzhihua.service_user.dao.RoleDAO;
-import com.panzhihua.service_user.dao.SysMenuDAO;
-import com.panzhihua.service_user.dao.SysOperLogDAO;
-import com.panzhihua.service_user.dao.SysRoleMenuDAO;
-import com.panzhihua.service_user.dao.SysUserAgreementDAO;
-import com.panzhihua.service_user.dao.SysUserFeedbackDAO;
-import com.panzhihua.service_user.dao.SysUserInputDAO;
-import com.panzhihua.service_user.dao.SysUserNoticeDAO;
-import com.panzhihua.service_user.dao.SysUserRoleDAO;
-import com.panzhihua.service_user.dao.UserDao;
-import com.panzhihua.service_user.model.dos.ComMngFamilyInfoDO;
-import com.panzhihua.service_user.model.dos.ComMngUserTagDO;
-import com.panzhihua.service_user.model.dos.EventGridMemberBuildingRelationDO;
-import com.panzhihua.service_user.model.dos.LcCompareCodeMemberDO;
-import com.panzhihua.service_user.model.dos.SysMenuDO;
-import com.panzhihua.service_user.model.dos.SysOperLogDO;
-import com.panzhihua.service_user.model.dos.SysRoleDO;
-import com.panzhihua.service_user.model.dos.SysRoleMenuDO;
-import com.panzhihua.service_user.model.dos.SysUserAgreementDO;
-import com.panzhihua.service_user.model.dos.SysUserDO;
-import com.panzhihua.service_user.model.dos.SysUserFeedbackDO;
-import com.panzhihua.service_user.model.dos.SysUserInputDO;
-import com.panzhihua.service_user.model.dos.SysUserNoticeDO;
-import com.panzhihua.service_user.model.dos.SysUserRoleDO;
 import com.panzhihua.service_user.model.dtos.DataKanbanDTO;
 import com.panzhihua.service_user.service.EventGridMemberBuildingRelationService;
 import com.panzhihua.service_user.service.UserService;
@@ -158,6 +132,8 @@
     private EventGridMemberBuildingRelationMapper eventGridMemberBuildingRelationMapper;
     @Resource
     private LcCompareMemberCodeMapper lcCompareMemberCodeMapper;
+    @Resource
+    private ComActFourMemberDao comActFourMemberDao;
     // @Resource
     // private GridService gridService;
 
@@ -308,6 +284,9 @@
         loginUserInfoVO.setAccount(name);
         loginUserInfoVO.setType(sysUserDO.getType());
         loginUserInfoVO.setIsRealNamed(sysUserDO.getIdCard() != null);// 暂时 身份证判断实名制
+        if(sysUserDO.getCommunityId()!=null){
+            loginUserInfoVO.setCommunityId(sysUserDO.getCommunityId());
+        }
         List<SysRoleDO> roleDOList = roleDAO.selectByUserId(sysUserDO.getUserId());
         Set<String> set = new HashSet<>();
         if (!ObjectUtils.isEmpty(roleDOList)) {
@@ -343,6 +322,7 @@
             loginUserInfoVO.setRoles(set);
         }
         loginUserInfoVO.setIsmemberrole(2);
+        loginUserInfoVO.setIsFourMember(2);
         // 志愿者状态
         String phone = sysUserDO.getPhone();
         Long userCommunityId = sysUserDO.getCommunityId();
@@ -359,6 +339,11 @@
             } else {
                 int state = comMngVolunteerMngVO.getState().intValue();
                 loginUserInfoVO.setVolunteerStatus(state);
+            }
+            //是否四长四员
+            Integer countFourMember=comActFourMemberDao.selectCount(new QueryWrapper<ComActFourMember>().lambda().eq(ComActFourMember::getUserId,sysUserDO.getUserId()));
+            if(countFourMember>0){
+                loginUserInfoVO.setIsFourMember(1);
             }
             // 是否是"管理员"或者 本社区 "社区团队"、"党委成员"
             Integer countTeam = userDao.selectCountTeam(phone, userCommunityId);
@@ -1087,6 +1072,8 @@
                     throw new ServiceException("手机号已经存在");
                 } else if (e.getMessage().contains("union_account_type")) {
                     throw new ServiceException("账户已经存在");
+                }else if(e.getMessage().contains("23000")){
+                    throw new ServiceException("手机号已存在");
                 }
 
             }
@@ -1101,7 +1088,47 @@
             sysUserRoleDO.setRoleId(roleDO.getRoleId());
             int insert1 = sysUserRoleDAO.insert(sysUserRoleDO);
             if (insert1 > 0) {
-                return R.ok();
+                return R.ok(userId);
+            }
+        }
+        return R.fail();
+    }
+
+    @Override
+    public R addUserBackstageProperty(AdministratorsUserVO administratorsUserVO) {
+        SysUserDO sysUserDO = new SysUserDO();
+        Long roleId = administratorsUserVO.getRoleId();
+        SysRoleDO roleDO = roleDAO.selectById(roleId);
+        if (ObjectUtils.isEmpty(roleDO)) {
+            return R.fail("角色不存在");
+        }
+        String encode = new BCryptPasswordEncoder().encode(administratorsUserVO.getPassword());
+        administratorsUserVO.setPassword(encode);
+        BeanUtils.copyProperties(administratorsUserVO, sysUserDO);
+        int insert = 0;
+        try {
+            insert = userDao.insert(sysUserDO);
+        } 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, administratorsUserVO.getType())
+                            .eq(SysUserDO::getAccount, administratorsUserVO.getAccount()));
+            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(userId);
             }
         }
         return R.fail();
@@ -2508,6 +2535,33 @@
         return R.ok(false);
     }
 
+    @Override
+    public R resetPassword(Long userId) {
+        SysUserDO sysUserDO = new SysUserDO();
+        sysUserDO.setUserId(userId);
+        String encode = new BCryptPasswordEncoder().encode("admin123456");
+        sysUserDO.setPassword(encode);
+        int update = userDao.updateById(sysUserDO);
+        if (update > 0) {
+            return R.ok();
+        }
+        return R.fail();
+    }
+
+    @Override
+    public R resetPasswordPatch(Long[] userId,String password) {
+        if(userId!=null){
+            for(Long user:userId){
+                SysUserDO sysUserDO = new SysUserDO();
+                sysUserDO.setUserId(user);
+                String encode = new BCryptPasswordEncoder().encode(password);
+                sysUserDO.setPassword(encode);
+                userDao.updateById(sysUserDO);
+            }
+        }
+        return R.ok();
+    }
+
     /**
      * 便民服务新增商家账号
      * @param convenientMerchantDTO
@@ -2572,34 +2626,34 @@
     }
 
     /**
-     * 修改便民服务商家绑定账号
-     * @param userId 用户id
-     * @param account 修改账户
-     * @return 修改结果
-     */
-    @Override
-    public R putUserAccount(Long userId, String account) {
-        SysUserDO sysUserDO = userDao.selectById(userId);
-        if (isNull(sysUserDO)) {
-            return R.fail("用户不存在");
-        }
-        String oldAccount = sysUserDO.getAccount();
-        sysUserDO.setAccount(account);
-        int result = userDao.updateById(sysUserDO);
-        if (result > 0) {
-            SysRoleDO sysRoleDO = roleDAO.selectOne(new QueryWrapper<SysRoleDO>()
-                    .lambda().eq(SysRoleDO::getRoleKey, Constants.CONVENIENT_MERCHANT_ROLE_KEY + oldAccount));
-            if (nonNull(sysRoleDO)) {
-                sysRoleDO.setRoleKey(Constants.CONVENIENT_MERCHANT_ROLE_KEY + account);
-                roleDAO.updateById(sysRoleDO);
-            }
-        }
-        return R.ok();
+ * 修改便民服务商家绑定账号
+ * @param userId 用户id
+ * @param account 修改账户
+ * @return 修改结果
+ */
+@Override
+public R putUserAccount(Long userId, String account) {
+    SysUserDO sysUserDO = userDao.selectById(userId);
+    if (isNull(sysUserDO)) {
+        return R.fail("用户不存在");
     }
+    String oldAccount = sysUserDO.getAccount();
+    sysUserDO.setAccount(account);
+    int result = userDao.updateById(sysUserDO);
+    if (result > 0) {
+        SysRoleDO sysRoleDO = roleDAO.selectOne(new QueryWrapper<SysRoleDO>()
+                .lambda().eq(SysRoleDO::getRoleKey, Constants.CONVENIENT_MERCHANT_ROLE_KEY + oldAccount));
+        if (nonNull(sysRoleDO)) {
+            sysRoleDO.setRoleKey(Constants.CONVENIENT_MERCHANT_ROLE_KEY + account);
+            roleDAO.updateById(sysRoleDO);
+        }
+    }
+    return R.ok();
+}
 
     @Override
     public R disableOrEnableMerchantUsers(DisableOrEnableConvenientMerchantDTO disableOrEnableConvenientMerchantDTO) {
-        userDao.disableOrEnableMerchantUsers(disableOrEnableConvenientMerchantDTO.getType(), disableOrEnableConvenientMerchantDTO.getIds());
+        userDao.disableOrEnableMerchantUsers(disableOrEnableConvenientMerchantDTO.getType(), disableOrEnableConvenientMerchantDTO.getUserIds());
         return R.ok();
     }
 }

--
Gitblit v1.7.1