From 94f6f81692eee7567e24be26e63bc30460307cbd Mon Sep 17 00:00:00 2001
From: yzh <snbbt@21cn.com>
Date: 星期一, 23 五月 2022 13:48:20 +0800
Subject: [PATCH] 客户归属权限优化

---
 web/Dao/GwClientDao.cs |   38 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/web/Dao/GwClientDao.cs b/web/Dao/GwClientDao.cs
index d2626d9..cae844f 100644
--- a/web/Dao/GwClientDao.cs
+++ b/web/Dao/GwClientDao.cs
@@ -107,7 +107,7 @@
         /**
          * 鏌ヨ缁熻鍔熻兘
          */
-        public List<GwClient> LoadInfoList(string clientID, string clientName, string company, string agent)
+        public List<GwClient> LoadInfoList(string clientID, string clientName, string company, string agent, string permissionsSQL)
         {
             
 
@@ -141,6 +141,10 @@
                     ((DbParameter)oracleParameterArray[3]).Value = (object)("%" + agent + "%");
                     stringBuilder.Append(" and Agent like :Agent");
                 }
+
+                //瀹㈡埛鏉冮檺SQL鑴氭湰
+                stringBuilder.Append(permissionsSQL);
+
                 stringBuilder.Append(" order by CREATE_TIME DESC,CLIENT_ID DESC");
                 using (OracleDataReader reader = OracleHelper.ExecuteReader("select * " + stringBuilder.ToString(), OracleHelper.Connection, oracleParameterArray))
                 {
@@ -426,6 +430,38 @@
 
             return sqlStr ;
         }
+
+        /**
+         * 鍑芥暟鎻忚堪锛� 鏍规嵁绯荤粺鐢ㄦ埛鑾峰彇鏈夋潈闄愬鎴疯处鍙�
+         * userId: 鐢ㄦ埛ID
+         * userType: 鐢ㄦ埛绫诲瀷锛�1-绠$悊鍛�;2-涓氬姟鍛�--鍏ㄥ憳;3-涓氬姟涓荤;4-涓氬姟鎬荤洃;5-瀹㈡湇浜哄憳;6-璐㈠姟浜哄憳;99-鍏朵粬
+         * return: SQL瀛楃涓�
+         * */
+        public string GetSpPermissions(int userId, int userType, string alias)
+        {
+            if (!string.IsNullOrEmpty(alias))
+            {
+                alias += ".";
+            }
+
+            string sqlStr = "";
+            //涓氬姟鍛樺拰鍏朵粬
+            if (userType == 2 || userType == 99)
+            {
+                sqlStr += " AND " + alias + "SP_ID IN (SELECT SP_ID from GW_SP where DEL_FLAG = 0 and CLIENT_ID IN (SELECT CLIENT_ID FROM GW_CLIENT WHERE IS_ENABLE=1 AND (SALESMAN='" + userId + "' ) ) ) ";
+            }
+            //涓氬姟涓荤
+            else if (userType == 3)
+            {
+                sqlStr += " AND " + alias + "SP_ID IN (SELECT SP_ID from GW_SP where DEL_FLAG = 0 and CLIENT_ID IN (SELECT CLIENT_ID FROM GW_CLIENT WHERE IS_ENABLE=1 AND (SALESMAN='" + userId + "' or CUSTOMER_MANAGER='" + userId + "' ) ) ) ";
+            }
+            else
+            {
+                //sqlStr += " AND CLIENT_ID IN (SELECT CLIENT_ID FROM GW_CLIENT WHERE IS_ENABLE=1 ) ";
+            }
+
+            return sqlStr;
+        }
     }
 }
 

--
Gitblit v1.9.1