Sfoglia il codice sorgente

同主体转接可跨公司

xw 1 giorno fa
parent
commit
8c7a666f39

+ 36 - 10
fs-company/src/main/java/com/fs/company/controller/qw/QwUserController.java

@@ -486,18 +486,31 @@ public class QwUserController extends BaseController
     public TableDataInfo list(QwUserListParam qwUser)
     {
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
-        qwUser.setCompanyId(loginUser.getCompany().getCompanyId());
-        if (ObjectUtil.isNotEmpty(qwUser.getIsRemark())&&qwUser.getIsRemark().equals("1")){
-            qwUser.setCompanyUserId(loginUser.getUser().getUserId());
-        }else if (ObjectUtil.isNotEmpty(qwUser.getIsRemark())&&qwUser.getIsRemark().equals("2")){
-            qwUser.setDeptId(loginUser.getUser().getDeptId());
-            qwUser.setCorpId(null);
-        }
+        Long loginCompanyId = loginUser.getCompany().getCompanyId();
+        boolean forTransfer = !StringUtil.strIsNullOrEmpty(qwUser.getCorpId())
+                && StringUtil.strIsNullOrEmpty(qwUser.getIsRemark());
 
-        if (!StringUtil.strIsNullOrEmpty(qwUser.getCorpId())) {
+        if (forTransfer) {
             QwCompany qwCompany = qwCompanyMapper.selectQwCompanyByCorpId(qwUser.getCorpId());
-            if (qwCompany != null) {
-                qwUser.setAllowOfficial(qwCompany.getAllowOfficial());
+            if (qwCompany == null || !corpAccessibleByCompany(qwCompany, loginCompanyId)) {
+                return getDataTable(Collections.emptyList());
+            }
+            qwUser.setAllowOfficial(qwCompany.getAllowOfficial());
+            qwUser.setForTransfer(1);
+        } else {
+            qwUser.setCompanyId(loginCompanyId);
+            if (ObjectUtil.isNotEmpty(qwUser.getIsRemark()) && qwUser.getIsRemark().equals("1")) {
+                qwUser.setCompanyUserId(loginUser.getUser().getUserId());
+            } else if (ObjectUtil.isNotEmpty(qwUser.getIsRemark()) && qwUser.getIsRemark().equals("2")) {
+                qwUser.setDeptId(loginUser.getUser().getDeptId());
+                qwUser.setCorpId(null);
+            }
+
+            if (!StringUtil.strIsNullOrEmpty(qwUser.getCorpId())) {
+                QwCompany qwCompany = qwCompanyMapper.selectQwCompanyByCorpId(qwUser.getCorpId());
+                if (qwCompany != null) {
+                    qwUser.setAllowOfficial(qwCompany.getAllowOfficial());
+                }
             }
         }
 
@@ -506,6 +519,19 @@ public class QwUserController extends BaseController
         return getDataTable(list);
     }
 
+    private boolean corpAccessibleByCompany(QwCompany qwCompany, Long companyId) {
+        if (qwCompany == null || companyId == null || StringUtil.strIsNullOrEmpty(qwCompany.getCompanyIds())) {
+            return false;
+        }
+        String companyIdStr = String.valueOf(companyId);
+        for (String id : qwCompany.getCompanyIds().split(",")) {
+            if (companyIdStr.equals(id.trim())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     /**
      * 查询企微用户列表
      */

+ 9 - 5
fs-service/src/main/java/com/fs/qw/mapper/QwUserMapper.java

@@ -207,13 +207,17 @@ public interface QwUserMapper extends BaseMapper<QwUser>
      *  查询企微用户绑定了的列表
      */
     @Select({"<script> " +
-            "select qu.*, cu.nick_name, cu.user_name, qd.dept_name as departmentName from qw_user qu " +
+            "select qu.*, " +
+            "COALESCE(cu.nick_name, qu.qw_user_name) as nickName, " +
+            "COALESCE(cu.user_name, qu.qw_user_id) as userName, " +
+            "qd.dept_name as departmentName from qw_user qu " +
             "LEFT JOIN company_user cu ON cu.user_id=qu.company_user_id " +
-            "RIGHT JOIN qw_dept qd on qu.department=qd.dept_id and qd.corp_id=qu.corp_id " +
-            "where qu.is_del=0 and qu.company_user_id is not null"+
+            "LEFT JOIN qw_dept qd on qu.department=qd.dept_id and qd.corp_id=qu.corp_id " +
+            "where qu.is_del=0 " +
+            "<if test=\"forTransfer == null or forTransfer != 1\"> and qu.company_user_id is not null </if>" +
             "            <if test=\"qwUserId != null  and qwUserId != ''\"> and qu.qw_user_id = #{qwUserId}</if>\n" +
-            "            <if test=\"companyId != null \"> and qu.company_id = #{companyId}</if>\n" +
-            "            <if test=\"nickName != null  and nickName != ''\"> and cu.nick_name like concat('%', #{nickName}, '%') </if>\n" +
+            "            <if test=\"forTransfer == null or forTransfer != 1\"><if test=\"companyId != null \"> and qu.company_id = #{companyId}</if></if>\n" +
+            "            <if test=\"nickName != null  and nickName != ''\"> and (cu.nick_name like concat('%', #{nickName}, '%') or qu.qw_user_name like concat('%', #{nickName}, '%')) </if>\n" +
             "            <if test=\"qwUserName != null  and qwUserName != ''\"> and qu.qw_user_name like concat('%', #{qwUserName}, '%') </if>\n" +
             "            <if test=\"companyUserId != null \"> and qu.company_user_id = #{companyUserId}</if>\n" +
             "            <if test=\"corpId != null \"> and qu.corp_id = #{corpId}</if>\n" +

+ 6 - 0
fs-service/src/main/java/com/fs/qw/param/QwUserListParam.java

@@ -87,4 +87,10 @@ public class QwUserListParam {
      */
     private String isRemark;
 
+    /**
+     * 在职继承等接替员工选择:同主体下查询,不限本公司、不要求绑定销售账号
+     * 由后端写入,勿由前端传入
+     */
+    private Integer forTransfer;
+
 }