From 3b18a48485f7207438d9d0eb3038d979e069431d Mon Sep 17 00:00:00 2001 From: yzh <snbbt@21cn.com> Date: 星期四, 26 五月 2022 17:58:18 +0800 Subject: [PATCH] 优化产品及产品分类,订单,对称加密,IP转地区名称 --- web/web/GwClient.ashx | 204 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 197 insertions(+), 7 deletions(-) diff --git a/web/web/GwClient.ashx b/web/web/GwClient.ashx index ba332cc..70a909e 100644 --- a/web/web/GwClient.ashx +++ b/web/web/GwClient.ashx @@ -1,5 +1,6 @@ 锘�<%@ WebHandler Language="C#" Class="GwClientHandler" %> using System; +using System.Linq; using System.Web; using Dao; using Model; @@ -9,6 +10,7 @@ using System.Text; using System.Text.RegularExpressions; using System.IO; +using Newtonsoft.Json; @@ -19,9 +21,18 @@ private UserDao _SysUserDao = new UserDao(); private List<SysUser> _SysUserList; + private int _userId = -1; + private int _userType = -1; + private string _account = ""; + private string initPwd = ConfigurationManager.AppSettings["initPwd"]; + public override JsonPageResult ProcessRequestInternal(PageContext<Model.SysUser> context) { string action = context.GetString("action"); + + _userId = context.SessionObject.UserID; + _userType = context.SessionObject.UserType; + _account = context.SessionObject.Account; switch (action) { @@ -53,6 +64,12 @@ case "updateBlack": return UpdateBlack(context); + //鎵归噺鍒嗛厤瀹㈡埛鐨勪釜鎬т骇鍝� + case "batchUpdateClientProduct": + return BatchUpdateClientProduct(context); + //閲嶇疆瀵嗙爜 + case "resetPwd": + return ResetPwd(context); default: throw new Exception("Invalid Action=" + action); @@ -70,8 +87,12 @@ private JsonPageResult LoadGwClientPageList(PageContext<Model.SysUser> context) { string ClientID = context.GetString("ClientID"); + string Company = context.GetString("Company"); string ClientName = context.GetString("ClientName"); string Telephone = context.GetString("Telephone"); + string Salesman = context.GetString("Salesman"); + string SupportStaff = context.GetString("SupportStaff"); + string ProductId = context.GetString("ProductId"); int pageIndex = context.GetInt("pageIndex", 1); string Agent = context.GetString("Agent"); @@ -79,10 +100,12 @@ int pageSize = context.GetInt("pageSize", 20); string serverIp = ConfigurationManager.AppSettings["serverIp"]; string clientPort = ConfigurationManager.AppSettings["clientPort"]; + string str = ""; using (GwClientDao dao = new GwClientDao()) { - var list = dao.LoadInfoList(out recordCount, pageIndex, pageSize, ClientID, ClientName, Telephone, Agent); + string permissionsSQL = dao.GetClientPermissions(_userId, _userType, null); + var list = dao.LoadInfoList(out recordCount, pageIndex, pageSize, ClientID, ClientName, Telephone, Agent, Company, Salesman, SupportStaff, ProductId, permissionsSQL); if (list != null && list.Count > 0) { @@ -96,8 +119,8 @@ //edit:yangzh by 20220511 //str += @"<tr ><td>" + item.ClientID + "</td><td>" + item.Company + "</td><td>" + item.ClientName + "</td><td>" + item.Telephone + "</td><td>" + item.Top_up_Amount_Total + "鍏�</td><td>" + item.Agent + "</td><td>" + Certification_StatusResult + "</td>"; //str += @"<tr ><td>" + item.ClientID + "</td><td>" + item.Company + "</td><td>" + item.ClientName + "</td><td>" + item.Telephone + "</td><td>" + item.Balance/1000 + "鍏�</td><td>" + item.Top_up_Amount_Total/1000 + "鍏�</td><td>" + item.Agent + "</td><td>" + Certification_StatusResult + "</td>"; - str += @"<tr ><td>" + item.ClientID + "</td><td>" + item.Company + "</td><td>" + item.ClientName + "</td><td>" + item.Telephone + "</td><td>" + item.Balance/1000 + "鍏�</td><td>" + item.Top_up_Amount_Total/1000 + "鍏�</td><td>" + SysUserName(string.IsNullOrEmpty(item.Agent)? 0: int.Parse(item.Agent) ) + "</td><td>" + Certification_StatusResult + "</td>"; - + //str += @"<tr ><td rowspan='1' ><input type='checkbox' name='checkbox' value='" + item.ClientID + "'/></td><td>" + item.ClientID + "</td><td>" + item.Company + "</td><td>" + item.ClientName + "</td><td>" + item.Telephone + "</td><td>" + item.Balance/1000 + "鍏�</td><td>" + item.Top_up_Amount_Total/1000 + "鍏�</td><td>" + SysUserName(string.IsNullOrEmpty(item.Salesman)? 0: int.Parse(item.Salesman) ) + "</td><td>" + Certification_StatusResult + "</td>"; + str += @"<tr ><td rowspan='1' ><input type='checkbox' name='checkbox' value='" + item.ClientID + "'/></td><td>" + item.ClientID + "</td><td>" + item.Company + "</td><td>" + item.ClientName + "</td><td>" + item.Telephone + "</td><td>" + item.Balance/1000 + "</td><td>" + item.Top_up_Amount_Total/1000 + "</td><td>" + SysUserName(string.IsNullOrEmpty(item.Salesman)? 0: int.Parse(item.Salesman) ) + "</td></td>"; str += @"<td>"; string loginStr = "http://" + serverIp + ":" + clientPort + "/Attachedlogin.aspx?action=Attachedlogin&account=" + item.Account + "&password=" + item.Password; @@ -116,6 +139,10 @@ str += @"榛戝悕鍗�"; str += @"</a> "; + str += string.Format(@"<a class=""action-modal-resetPwd btn btn-xs btn-primary"" href=""javascript:;"" data-id=""{0}"">", item.ClientID); + str += @"閲嶇疆瀵嗙爜"; + str += @"</a> "; + str += string.Format(@"<a class=""action-delete btn btn-xs btn-default"" href=""javascript:;"" data-id=""{0}"">", item.ClientID); str += @"鍒犻櫎"; str += @"</a>"; @@ -125,7 +152,7 @@ } else { - str += @"<tr><td colspan=""8"">鏆傛棤淇℃伅</td></tr>"; + str += @"<tr><td colspan=""9"">鏆傛棤淇℃伅</td></tr>"; } } @@ -200,6 +227,20 @@ return new JsonPageResult(true, _Dao.GetBlackList(clientID)); } + //閲嶇疆瀵嗙爜 + private JsonPageResult ResetPwd(PageContext<Model.SysUser> context) + { + string clientID = context.GetString("clientID"); + string password = string.IsNullOrEmpty(initPwd ) ? "123456" : initPwd; + + //瀵嗙爜MD5鍔犲瘑锛� + password = DataHelper.MD5Hex(password); + + _Dao.UpdatePassword(clientID, password); + + return new JsonPageResult(true, "閲嶇疆瀵嗙爜鎴愬姛锛�"); + } + /// <summary> /// 閫氳繃璐﹀彿鍚嶈幏鍙栦唬鐞嗗晢淇℃伅 /// </summary> @@ -244,6 +285,13 @@ string telephone = context.GetString("telephone"); string remark = context.GetString("remark"); string agent = context.GetString("agent"); + string salesman = context.GetString("salesman"); + string customerManager = context.GetString("customerManager"); + string supportStaff = context.GetString("supportStaff"); + string financialStaff = context.GetString("financialStaff"); + string chargeType = context.GetString("chargeType"); + string smsStatusReport = context.GetString("smsStatusReport"); + string mmsStatusReport = context.GetString("mmsStatusReport"); string data = context.GetString("permissionData"); if(data.Contains("1")) { @@ -270,6 +318,41 @@ throw new ArgumentException("鑱旂郴浜�/鑱旂郴鐢佃瘽锛屼笉鑳戒负绌猴紒"); } + if (string.IsNullOrEmpty(customerManager)) + { + throw new ArgumentException("褰掑睘瀹㈡埛缁忕悊涓嶈兘涓虹┖锛岃閫夋嫨锛�"); + } + + if (string.IsNullOrEmpty(salesman)) + { + throw new ArgumentException("褰掑睘涓氬姟鍛樹笉鑳戒负绌猴紝璇烽�夋嫨锛�"); + } + + if (string.IsNullOrEmpty(supportStaff)) + { + throw new ArgumentException("褰掑睘瀹㈡湇浜哄憳涓嶈兘涓虹┖锛岃閫夋嫨锛�"); + } + + if (string.IsNullOrEmpty(financialStaff)) + { + throw new ArgumentException("褰掑睘璐㈠姟浜哄憳涓嶈兘涓虹┖锛岃閫夋嫨锛�"); + } + + if (string.IsNullOrEmpty(chargeType)) + { + throw new ArgumentException("璁¤垂鏂瑰紡涓嶈兘涓虹┖锛岃閫夋嫨锛�"); + } + + if (string.IsNullOrEmpty(smsStatusReport)) + { + throw new ArgumentException("鐭俊鏄惁鏀寔鏄剧ず鐘舵�佹姤鍛婁笉鑳戒负绌猴紝璇烽�夋嫨锛�"); + } + + if (string.IsNullOrEmpty(mmsStatusReport)) + { + throw new ArgumentException("褰╀俊鏄惁鏀寔鏄剧ず鐘舵�佹姤鍛婁笉鑳戒负绌猴紝璇烽�夋嫨锛�"); + } + string savePassword = ""; if (!string.IsNullOrEmpty(clientID)) { @@ -289,12 +372,20 @@ client.Company = company; //client.Password = password; client.Password = savePassword; - + client.ClientName = clientName; client.Address = address; client.Remark = remark; client.Telephone = telephone; client.Agent = agent; + + client.CustomerManager = customerManager; + client.Salesman = salesman; + client.SupportStaff = supportStaff; + client.FinancialStaff = financialStaff; + client.ChargeType = string.IsNullOrEmpty(chargeType) ? 0 : int.Parse(chargeType); + client.SmsStatusReport = string.IsNullOrEmpty(smsStatusReport) ? 0 : int.Parse(smsStatusReport); + client.MmsStatusReport = string.IsNullOrEmpty(mmsStatusReport) ? 0 : int.Parse(mmsStatusReport); client.PermissionData = permissionData; _Dao.Update(client); @@ -313,6 +404,13 @@ string remark = context.GetString("remark"); string agent = context.GetString("agent"); string company = context.GetString("company"); + string salesman = context.GetString("salesman"); + string customerManager = context.GetString("customerManager"); + string supportStaff = context.GetString("supportStaff"); + string financialStaff = context.GetString("financialStaff"); + string chargeType = context.GetString("chargeType"); + string smsStatusReport = context.GetString("smsStatusReport"); + string mmsStatusReport = context.GetString("mmsStatusReport"); string data = context.GetString("permissionData"); if(data.Contains("1")) { @@ -347,6 +445,41 @@ if (_Dao.IsIDExists(clientID)) { throw new ArgumentException("瀹㈡埛璐﹀彿宸茬粡瀛樺湪锛�"); + } + + if (string.IsNullOrEmpty(customerManager)) + { + throw new ArgumentException("褰掑睘瀹㈡埛缁忕悊涓嶈兘涓虹┖锛岃閫夋嫨锛�"); + } + + if (string.IsNullOrEmpty(salesman)) + { + throw new ArgumentException("褰掑睘涓氬姟鍛樹笉鑳戒负绌猴紝璇烽�夋嫨锛�"); + } + + if (string.IsNullOrEmpty(supportStaff)) + { + throw new ArgumentException("褰掑睘瀹㈡湇浜哄憳涓嶈兘涓虹┖锛岃閫夋嫨锛�"); + } + + if (string.IsNullOrEmpty(financialStaff)) + { + throw new ArgumentException("褰掑睘璐㈠姟浜哄憳涓嶈兘涓虹┖锛岃閫夋嫨锛�"); + } + + if (string.IsNullOrEmpty(chargeType)) + { + throw new ArgumentException("璁¤垂鏂瑰紡涓嶈兘涓虹┖锛岃閫夋嫨锛�"); + } + + if (string.IsNullOrEmpty(smsStatusReport)) + { + throw new ArgumentException("鐭俊鏄惁鏀寔鏄剧ず鐘舵�佹姤鍛婁笉鑳戒负绌猴紝璇烽�夋嫨锛�"); + } + + if (string.IsNullOrEmpty(mmsStatusReport)) + { + throw new ArgumentException("褰╀俊鏄惁鏀寔鏄剧ず鐘舵�佹姤鍛婁笉鑳戒负绌猴紝璇烽�夋嫨锛�"); } HttpFileCollection _file = HttpContext.Current.Request.Files; @@ -408,6 +541,14 @@ client.ParentId = context.OperatorID; client.Certification_Status = 1; client.Company = company; + client.CustomerManager = customerManager; + client.Salesman = salesman; + client.SupportStaff = supportStaff; + client.FinancialStaff = financialStaff; + client.ChargeType = string.IsNullOrEmpty(chargeType) ? 0 : int.Parse(chargeType); + client.SmsStatusReport = string.IsNullOrEmpty(smsStatusReport) ? 0 : int.Parse(smsStatusReport); + client.MmsStatusReport = string.IsNullOrEmpty(mmsStatusReport) ? 0 : int.Parse(mmsStatusReport); + _Dao.Add(client);//鎻掑叆鏁版嵁搴撱�傚垱寤鸿处鎴� //淇濆瓨浜у搧璁板綍 @@ -429,6 +570,55 @@ **/ return new JsonPageResult(true, "鍒涘缓璐︽埛鎴愬姛锛�"); + } + + //鍒嗛厤瀹㈡埛鐨勪釜鎬т骇鍝� + private JsonPageResult BatchUpdateClientProduct(PageContext<SysUser> context) + { + string productId = context.GetString("productId"); + string idArray = context.GetString("idArray"); + if (string.IsNullOrEmpty(productId)) + { + + throw new ArgumentException("涓�т骇鍝佷笉鑳戒负绌猴紝璇烽�夋嫨锛�"); + } + + Model.GwProduct gwProduct = new GwProductDao().Get(productId); + if (gwProduct == null) + { + throw new ArgumentException("鎸囧畾鐨勪釜鎬т骇鍝佷笉瀛樺湪锛岃閲嶆柊閫夋嫨锛�"); + } + string clientIds = gwProduct.ClientIds; + + List<string> tmpList = new List<string>(); + if(!string.IsNullOrEmpty(clientIds)) + { //瀛楃涓茶浆鏁扮粍锛屽啀鏁扮粍鍚堝苟 + tmpList.AddRange( clientIds.Split(',') ); + } + //鏁扮粍鍚堝苟 + tmpList.AddRange( JsonConvert.DeserializeObject<string[]>(context.GetString("idArray")) ); + + //鏁扮粍鍘婚噸 + string[] tmpArray = DelRepeatData(tmpList.ToArray() ); + clientIds = string.Join(",", tmpArray) ; + + if (!string.IsNullOrEmpty(clientIds)) + { + new GwProductDao().UpdateClientIds(clientIds, productId); + } + + + return new JsonPageResult(true, (object)"鎵归噺鍒嗛厤瀹㈡埛涓�т骇鍝佹垚鍔燂紒"); + } + + /// <summary> + /// 绉婚櫎鏁扮粍涓噸澶嶆暟鎹� + /// </summary> + /// <param name="array">闇�瑕侀櫎閲嶇殑鏁扮粍</param> + /// <returns>涓嶉噸澶嶆暟缁�</returns> + public static string[] DelRepeatData(string[] array) + { + return array.GroupBy(p => p).Select(p => p.Key).ToArray(); } @@ -453,14 +643,14 @@ } } - //绠$悊绔处鎴峰悕绉� + //绠$悊绔敤鎴稩D杞悕绉� private string SysUserName(int userId) { if (this.SysUserList == null) return string.Empty; SysUser sysUser = this._SysUserList.Find((Predicate<SysUser>)(bean => bean.UserID == userId)); if (sysUser != null) - return string.Format("{0}-{1}", (object)sysUser.UserID, (object)sysUser.UserName); + return string.Format("{0}", (object)sysUser.UserName); return string.Empty; } } -- Gitblit v1.9.1