Explorar el Código

企业账户筛选

liangpeile hace 1 año
padre
commit
e538505021

+ 19 - 2
crmeb-admin/src/main/java/com/zbkj/admin/controller/platform/NewPlatformApi.java

@@ -3,6 +3,7 @@ package com.zbkj.admin.controller.platform;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -593,10 +594,17 @@ public class NewPlatformApi {
 
     public CommonResult<String> userSave(@RequestParam(value = "organizationId") String organizationId,
                                          @RequestParam(value = "departmentId") String departmentId,
-                                         @RequestParam(value = "name") String name,
+                                         @RequestParam(value = "name",required = false) String name,
                                          @RequestParam(value = "uid", required = false) String uid,
-                                         @RequestParam(value = "phone") String phone
+                                         @RequestParam(value = "phone",required = false) String phone
     ) {
+        if (StringUtils.isBlank(phone)){
+            return CommonResult.failed("手机号不能为空");
+        }
+        if (StringUtils.isBlank(name)){
+            return CommonResult.failed("用户名不能为空");
+        }
+
         OrganizationDepartmentUser request = new OrganizationDepartmentUser();
         SystemAdmin systemAdmin = SecurityUtil.getLoginUserVo().getUser();
         request.setId(UUID.randomUUID().toString().replace("-", ""));
@@ -754,6 +762,15 @@ public class NewPlatformApi {
     @ApiOperation(value = "企业账号编辑")
     @RequestMapping(value = "/enterpriseEdit", method = RequestMethod.POST)
     public CommonResult<UserEnterprise> organizationEdit(@RequestBody @Validated UserEnterprise request) {
+        LambdaQueryWrapper<OrganizationDepartment> departmentLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        departmentLambdaQueryWrapper.eq(OrganizationDepartment::getOrganizationId,request.getOrganizationId());
+        departmentLambdaQueryWrapper.eq(OrganizationDepartment::getName,request.getDepartment());
+        List<OrganizationDepartment> list = organizationDepartmentService.list(departmentLambdaQueryWrapper);
+        if (null!=list &&list.size()>0){
+            for (OrganizationDepartment organizationDepartment : list) {
+                request.setDepartId(organizationDepartment.getId());
+            }
+        }
         userEnterpriseService.updateById(request);
         return CommonResult.success("操作成功");
     }

+ 6 - 1
crmeb-common/src/main/java/com/zbkj/common/model/user/UserEnterprise.java

@@ -79,6 +79,11 @@ public class UserEnterprise implements Serializable {
     @ApiModelProperty(value = "是否已经删除0 正常  1删除")
     private Integer isDelete;
 
-    @ApiModelProperty(value = "是否已经删除0 正常  1删除")
+    @ApiModelProperty(value = "企业id")
     private String organizationId;
+
+    @ApiModelProperty(value = "部门Id")
+    private String departId;
+
+
 }

+ 78 - 84
crmeb-service/src/main/java/com/zbkj/service/service/impl/OrganizationDepartmentServiceImpl.java

@@ -1,29 +1,29 @@
 package com.zbkj.service.service.impl;
 
 
-
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
 import com.zbkj.common.model.organization.OrganizationDepartment;
 
+import com.zbkj.common.model.organization.OrganizationDepartmentUser;
 import com.zbkj.common.model.organization.VO.OrganizationDepartmentVO;
+import com.zbkj.common.model.user.User;
 import com.zbkj.common.model.user.UserBypassAccount;
 import com.zbkj.common.model.user.UserEnterprise;
 import com.zbkj.common.result.CommonResult;
 import com.zbkj.service.dao.OrganizationDeparementDao;
 import com.zbkj.service.dao.UserBypassAccountDao;
 import com.zbkj.service.dao.UserEnterpriseDao;
-import com.zbkj.service.service.OrganizationDepartmentService;
+import com.zbkj.service.service.*;
 
-import com.zbkj.service.service.UserBypassAccountService;
-import com.zbkj.service.service.UserEnterpriseService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 
 @Service
@@ -39,6 +39,12 @@ public class OrganizationDepartmentServiceImpl extends ServiceImpl<OrganizationD
     private UserBypassAccountService userBypassAccountService;
     @Autowired
     private UserEnterpriseService userEnterpriseService;
+    @Autowired
+    private OrganizationDepartmentUserService organizationDepartmentUserService;
+    @Autowired
+    private OrganizationDepartmentService organizationDepartmentService;
+    @Autowired
+    private UserService userService;
 
     @Override
     public List<OrganizationDepartmentVO> selectMain(String id) {
@@ -55,17 +61,17 @@ public class OrganizationDepartmentServiceImpl extends ServiceImpl<OrganizationD
         deparementDao.updateById(request);
         String id = request.getId();
         LambdaQueryWrapper<UserEnterprise> enterpriseLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        enterpriseLambdaQueryWrapper.eq(UserEnterprise::getOrganizationId,request.getOrganizationId());
+        enterpriseLambdaQueryWrapper.eq(UserEnterprise::getOrganizationId, request.getOrganizationId());
         UserEnterprise userEnterprise = userEnterpriseService.getOne(enterpriseLambdaQueryWrapper);
-        if (null!=userEnterprise){
+        if (null != userEnterprise) {
             userEnterprise.setDepartment(request.getName());
             userEnterpriseService.updateById(userEnterprise);
 
             LambdaQueryWrapper<UserBypassAccount> queryWrapper = new LambdaQueryWrapper<>();
-            queryWrapper.eq(UserBypassAccount::getDepartmentId,id);
-            queryWrapper.eq(UserBypassAccount::getEnterpriseId,userEnterprise.getId());
+            queryWrapper.eq(UserBypassAccount::getDepartmentId, id);
+            queryWrapper.eq(UserBypassAccount::getEnterpriseId, userEnterprise.getId());
             List<UserBypassAccount> list = userBypassAccountService.list(queryWrapper);
-            if (null!=list&&list.size()>0){
+            if (null != list && list.size() > 0) {
                 for (UserBypassAccount userBypassAccount : list) {
                     userBypassAccount.setDepartment(request.getName());
                     userBypassAccountService.updateById(userBypassAccount);
@@ -76,85 +82,73 @@ public class OrganizationDepartmentServiceImpl extends ServiceImpl<OrganizationD
 
     @Override
     public CommonResult<?> departUser(String departmentId, String organizationId) {
-        if (StringUtils.isNotBlank(departmentId)) {
-            List<UserBypassAccount> list = new ArrayList<>();
-            String[] split = departmentId.split(",");
-            LambdaQueryWrapper<OrganizationDepartment> queryWrapper = new LambdaQueryWrapper<>();
-            queryWrapper.in(OrganizationDepartment::getId, split);
-
-            List<OrganizationDepartment> departmentList = this.list(queryWrapper);
-            for (OrganizationDepartment organizationDepartment : departmentList) {
-
-                String organizationId1 = organizationDepartment.getOrganizationId();
-                String name = organizationDepartment.getName();
-
-                LambdaQueryWrapper<UserEnterprise> queryWrapper2 = new LambdaQueryWrapper<>();
-                queryWrapper2.eq(UserEnterprise::getOrganizationId, organizationId1);
-                UserEnterprise userEnterprise2 = userEnterpriseService.getOne(queryWrapper2);
-                if (null!=userEnterprise2){
-                    Integer id2 = userEnterprise2.getId();
-                    LambdaQueryWrapper<UserBypassAccount> queryWrapper3 = new LambdaQueryWrapper<>();
-                    queryWrapper3.eq(UserBypassAccount::getEnterpriseId, id2);
-                    queryWrapper3.eq(UserBypassAccount::getDepartment, name);
-                    queryWrapper3.eq(UserBypassAccount::getIsDelete, 0);
-                    List<UserBypassAccount> list1 = userBypassAccountService.list(queryWrapper3);
-                    for (UserBypassAccount userBypassAccount : list1) {
-                        list.add(userBypassAccount);
-                    }
-                    if (null == list1 || list1.size() == 0) {
-                        LambdaQueryWrapper<UserEnterprise> queryWrapper4 = new LambdaQueryWrapper<>();
-                        queryWrapper4.eq(UserEnterprise::getOrganizationId, organizationId);
-                        UserEnterprise userEnterprise4 = userEnterpriseService.getOne(queryWrapper4);
-                        if (null!=userEnterprise4){
-                            UserBypassAccount userBypassAccount = new UserBypassAccount();
-                            userBypassAccount.setId(userEnterprise4.getId());
-                            userBypassAccount.setEnterpriseId(userEnterprise4.getId());
-                            userBypassAccount.setUserId(userEnterprise4.getUserId());
-                            userBypassAccount.setRealName(userEnterprise4.getRealName());
-                            userBypassAccount.setNickname(userEnterprise4.getNickname());
-                            userBypassAccount.setPhone(userEnterprise4.getPhone());
-                            userBypassAccount.setAvatar(userEnterprise4.getAvatar());
-                            userBypassAccount.setIsDelete(userEnterprise4.getIsDelete());
-                            userBypassAccount.setDepartment(userEnterprise4.getDepartment());
-                            userBypassAccount.setDepartmentId(organizationDepartment.getId());
-                            list.add(userBypassAccount);
-                        }
-
-                    }
-                }
 
-            }
-            return CommonResult.success(list);
-        } else if (StringUtils.isNotBlank(organizationId)) {
-            LambdaQueryWrapper<UserEnterprise> queryWrapper = new LambdaQueryWrapper<>();
-            queryWrapper.eq(UserEnterprise::getOrganizationId, organizationId);
-            UserEnterprise userEnterprise = userEnterpriseService.getOne(queryWrapper);
-            Integer id = userEnterprise.getId();
-            LambdaQueryWrapper<UserBypassAccount> queryWrapper2 = new LambdaQueryWrapper<>();
-            queryWrapper2.eq(UserBypassAccount::getEnterpriseId, id);
-            queryWrapper2.eq(UserBypassAccount::getIsDelete, 0);
-            List<UserBypassAccount> list1 = userBypassAccountService.list(queryWrapper2);
-
-
-            LambdaQueryWrapper<UserEnterprise> queryWrapper4 = new LambdaQueryWrapper<>();
-            queryWrapper4.eq(UserEnterprise::getOrganizationId, organizationId);
-            UserEnterprise userEnterprise4 = userEnterpriseService.getOne(queryWrapper4);
-            UserBypassAccount userBypassAccount = new UserBypassAccount();
-            userBypassAccount.setId(userEnterprise4.getId());
-            userBypassAccount.setEnterpriseId(userEnterprise4.getId());
-            userBypassAccount.setUserId(userEnterprise4.getUserId());
-            userBypassAccount.setRealName(userEnterprise4.getRealName());
-            userBypassAccount.setNickname(userEnterprise4.getNickname());
-            userBypassAccount.setPhone(userEnterprise4.getPhone());
-            userBypassAccount.setAvatar(userEnterprise4.getAvatar());
-            userBypassAccount.setIsDelete(userEnterprise4.getIsDelete());
-            userBypassAccount.setDepartment(userEnterprise4.getDepartment());
-            userBypassAccount.setDepartmentId(departmentId);
-            list1.add(userBypassAccount);
+        String[] split = departmentId.split(",");
+        User user = userService.getInfo();
+        Integer isEnterpriseUser = user.getIsEnterpriseUser();
+        Integer isAllOrders = user.getIsAllOrders();
+
+        LambdaQueryWrapper<OrganizationDepartmentUser> queryWrapper1 = new LambdaQueryWrapper<>();
+        queryWrapper1.eq(OrganizationDepartmentUser::getOrganizationId, organizationId);
+        queryWrapper1.in(OrganizationDepartmentUser::getDepartmentId, split);
+        List<OrganizationDepartmentUser> list = organizationDepartmentUserService.list(queryWrapper1);
+        List<String> ids = list.stream().map(OrganizationDepartmentUser::getDepartmentId).collect(Collectors.toList());
+
+        LambdaQueryWrapper<UserBypassAccount> queryWrapper2 = new LambdaQueryWrapper<>();
+        queryWrapper2.eq(UserBypassAccount::getIsDelete, 0);
+        if (ids.size() > 0) {
+            queryWrapper2.in(UserBypassAccount::getDepartmentId, ids);
 
+        }
+        List<UserBypassAccount> list1 = userBypassAccountService.list(queryWrapper2);
+
+        LambdaQueryWrapper<UserEnterprise> queryWrapper3 = new LambdaQueryWrapper<>();
+        queryWrapper3.eq(UserEnterprise::getIsDelete, 0);
+        queryWrapper3.eq(UserEnterprise::getOrganizationId, organizationId);
+        queryWrapper3.eq(UserEnterprise::getOrganizationId, organizationId);
+        if (ids.size() > 0) {
+            queryWrapper3.in(UserEnterprise::getDepartId, ids);
+        }
+        List<UserEnterprise> list2 = userEnterpriseService.list(queryWrapper3);
+        if (2 == isEnterpriseUser) {
+            for (UserEnterprise userEnterprise : list2) {
+                UserBypassAccount userBypassAccount = new UserBypassAccount();
+                userBypassAccount.setId(userEnterprise.getId());
+                userBypassAccount.setEnterpriseId(userEnterprise.getId());
+                userBypassAccount.setUserId(userEnterprise.getUserId());
+                userBypassAccount.setRealName(userEnterprise.getRealName());
+                userBypassAccount.setNickname(userEnterprise.getNickname());
+                userBypassAccount.setPhone(userEnterprise.getPhone());
+                userBypassAccount.setAvatar(userEnterprise.getAvatar());
+                userBypassAccount.setIsDelete(userEnterprise.getIsDelete());
+                userBypassAccount.setDepartment(userEnterprise.getDepartment());
+                userBypassAccount.setDepartmentId(userEnterprise.getDepartId());
+                list1.add(userBypassAccount);
+            }
             return CommonResult.success(list1);
+        } else {
+            if (3 == isEnterpriseUser && 1 == isAllOrders) {
+                for (UserEnterprise userEnterprise : list2) {
+                    UserBypassAccount userBypassAccount = new UserBypassAccount();
+                    userBypassAccount.setId(userEnterprise.getId());
+                    userBypassAccount.setEnterpriseId(userEnterprise.getId());
+                    userBypassAccount.setUserId(userEnterprise.getUserId());
+                    userBypassAccount.setRealName(userEnterprise.getRealName());
+                    userBypassAccount.setNickname(userEnterprise.getNickname());
+                    userBypassAccount.setPhone(userEnterprise.getPhone());
+                    userBypassAccount.setAvatar(userEnterprise.getAvatar());
+                    userBypassAccount.setIsDelete(userEnterprise.getIsDelete());
+                    userBypassAccount.setDepartment(userEnterprise.getDepartment());
+                    userBypassAccount.setDepartmentId(userEnterprise.getDepartId());
+                    list1.add(userBypassAccount);
+                }
+                return CommonResult.success(list1);
+            } else {
+                return CommonResult.success(list1);
+            }
         }
-        return CommonResult.success("部门下用户为空");
+
+
     }
 }
 

+ 1 - 0
crmeb-service/src/main/java/com/zbkj/service/service/impl/UserEnterpriseServiceImpl.java

@@ -98,6 +98,7 @@ public class UserEnterpriseServiceImpl extends ServiceImpl<UserEnterpriseDao, Us
             userEnterprise.setDepartment(userEnterprise.getDepartment());
             OrganizationDepartmentUser organizationDepartmentUser = organizationDepartmentUserService.getById(userEnterprise.getRealName());
             userEnterprise.setRealName(organizationDepartmentUser.getName());
+            userEnterprise.setDepartId(organizationDepartmentUser.getDepartmentId());
             userEnterprise.setIsAuthentication(1);
             userEnterprise.setCreateTime(new Date());