diff --git a/Mini.Common/Utility.cs b/Mini.Common/Utility.cs index 240405e..178f458 100644 --- a/Mini.Common/Utility.cs +++ b/Mini.Common/Utility.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Data; using System.IO; +using System.Linq; using System.Net; using System.Reflection; using System.Security.Cryptography; @@ -22,7 +23,46 @@ namespace Mini.Common { return ConfigHelper.GetSectionValue(key); } - + + /// + /// 获取时间戳 + /// + /// + public static Int64 GetTimeStamp(bool isMinseconds = false) + { + var ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); + long times = Convert.ToInt64(isMinseconds ? ts.TotalMilliseconds : ts.TotalSeconds); + return times; + } + + /// + /// 加密 + /// + /// + /// + /// + public static string encyptDataByConfig(string clientId, string paramData) + { + //if (!bWithEncypt) + // return paramData; + ClientKey client = ClientKey.GetClientKey(clientId); + if (client == null) + throw new Exception("非法客户端访问"); + return encyptData(paramData, client.AccessKey); + } + + public static string encyptData(string ciphertext, string accessKey) + { + SymmetricAlgorithm des = new DESCryptoServiceProvider(); + + Encoding utf = new UTF8Encoding(); + byte[] key = utf.GetBytes(accessKey); + byte[] iv = { 0x75, 0x70, 0x63, 0x68, 0x69, 0x6e, 0x61, 0x31 }; + ICryptoTransform encryptor = des.CreateEncryptor(key, iv); + byte[] data = utf.GetBytes(ciphertext); + byte[] encData = encryptor.TransformFinalBlock(data, 0, data.Length); + return Convert.ToBase64String(encData); + } /// /// DataTable 转list @@ -302,7 +342,11 @@ namespace Mini.Common } } } - + public static long ConvertDateTimeLong(System.DateTime time) + { + System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); + return (long)(time - startTime).TotalSeconds * 1000; + } /// /// 对DES加密后的字符串进行解密 /// @@ -971,4 +1015,52 @@ namespace Mini.Common catch { return null; } } } + + public sealed class ClientKey + { + private ClientKey(string _Id, string _Name, string _AccessKey) + { + Id = _Id; + Name = _Name; + AccessKey = _AccessKey; + } + + public string Id + { + get; + private set; + } + + public string Name + { + get; + private set; + } + + public string AccessKey + { + get; + private set; + } + + private static List clientList; + + static ClientKey() + { + clientList = new List(); + clientList.Add(new ClientKey("UPWEBSITE", "UP网站", "1622a92d")); + clientList.Add(new ClientKey("TDORDERSITE", "订单接口", "622a92d1")); + clientList.Add(new ClientKey("UPPRODUCT", "UP产品端", "c268a2cd")); + clientList.Add(new ClientKey("gd_crm", "UPCRM", "upchina.")); + clientList.Add(new ClientKey("nj_crm", "UPCRM", "pchina.1")); + clientList.Add(new ClientKey("AYCRM2_CTI", "CTI", "ac910f51")); + clientList.Add(new ClientKey("WX_EXT", "企微相关外部链接", "dwj5rc8x")); + clientList.Add(new ClientKey("saleclue", "线索专用", "dwddsj5d"));//线索专用,跨本系统 + } + + public static ClientKey GetClientKey(string clientId) + { + return clientList.FirstOrDefault(obj => obj.Id == clientId); + } + } } diff --git a/Mini.Model/DTO/saledsleadDesDto.cs b/Mini.Model/DTO/saledsleadDesDto.cs new file mode 100644 index 0000000..686597d --- /dev/null +++ b/Mini.Model/DTO/saledsleadDesDto.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Mini.Model.DTO +{ + public class saledsleadDesDto + { + public string appid { get; set; } + public string appuserid { get; set; } + public string deptid { get; set; } + public string eid { get; set; } + public string employee_id { get; set; } + public string employeeid { get; set; } + public string employee { get; set; } + public string ext_flag { get; set; } + } +} diff --git a/Mini.Web/Areas/Admin/Controllers/OutHHuserController.cs b/Mini.Web/Areas/Admin/Controllers/OutHHuserController.cs index e5c6235..8cd60eb 100644 --- a/Mini.Web/Areas/Admin/Controllers/OutHHuserController.cs +++ b/Mini.Web/Areas/Admin/Controllers/OutHHuserController.cs @@ -25,6 +25,7 @@ using Mini.Web.WebHelper; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Microsoft.AspNetCore.Http; +using System.Security.Cryptography; namespace Mini.Web.Areas.Admin.Controllers { public class OutHHuserController : Controller @@ -653,7 +654,7 @@ namespace Mini.Web.Areas.Admin.Controllers } [Area("Admin")] - public ActionResult User_extuserList(string exuserid, string isHg, string showstyle, string userIds, string companycode,string canLookComapyCode) + public ActionResult User_extuserList(string exuserid, string isHg, string showstyle, string userIds, string companycode, string canLookComapyCode, int eid, bool isChoose = false) { List list = new List(); try @@ -670,7 +671,7 @@ namespace Mini.Web.Areas.Admin.Controllers { if (!ids.Contains(item.userid)) { - item.isOutDept=1; + item.isOutDept = 1; } } } @@ -722,42 +723,43 @@ namespace Mini.Web.Areas.Admin.Controllers { LogHelper.Error("错误:" + e.ToString()); } - + ViewBag.isChoose = isChoose; ViewBag.data = Common.JsonHelper.ObjDivertToJson(list); ViewBag.roomData = Common.JsonHelper.ObjDivertToJson(roomeCList);//群的列表 ViewBag.isHg = isHg; + ViewBag.eid = eid; + return View(); + } + + [Area("Admin")] + public ActionResult User_extuserList2(string exuserid, string isHg, string showstyle, string userIds, string companycode, string canLookComapyCode) + { + List list = new List(); + try + { + if (!string.IsNullOrEmpty(exuserid)) + { + list = _iww_hhuser_service.Extuser_GetAllUser_check(exuserid, companycode).Where(p => p.isOutDept != 1).ToList(); + + foreach (var item in list) + { + item.name = ManagerPhoneHelper.FormatPhoneUserName(string.Format("{0}", item.name)); + } + } + } + catch (Exception e) + { + LogHelper.Error(e.ToString()); + } + + ViewBag.data = Common.JsonHelper.ObjDivertToJson(list); + //ViewBag.roomData = Common.JsonHelper.ObjDivertToJson(roomeCList);//群的列表 + ViewBag.isHg = isHg; return View(); } - [Area("Admin")] - public ActionResult User_extuserList2(string exuserid, string isHg, string showstyle, string userIds, string companycode, string canLookComapyCode) - { - List list = new List(); - try - { - if (!string.IsNullOrEmpty(exuserid)) - { - list = _iww_hhuser_service.Extuser_GetAllUser_check(exuserid, companycode).Where(p => p.isOutDept != 1).ToList(); - foreach (var item in list) - { - item.name = ManagerPhoneHelper.FormatPhoneUserName(string.Format("{0}", item.name)); - } - } - } - catch (Exception e) - { - LogHelper.Error(e.ToString()); - } - - ViewBag.data = Common.JsonHelper.ObjDivertToJson(list); - //ViewBag.roomData = Common.JsonHelper.ObjDivertToJson(roomeCList);//群的列表 - ViewBag.isHg = isHg; - return View(); - } - - - [Area("Admin")] + [Area("Admin")] public ActionResult OneMessage(string corpid, string name, string extuserid, string uname, string userid) { @@ -779,7 +781,116 @@ namespace Mini.Web.Areas.Admin.Controllers /// 定位的json信息 /// [Area("Admin")] - public ActionResult MessageDetial(string isgroup, string userid, string uname, string corp, string customer, string nickname, string isHg, string locationJson) + public ActionResult MessageDetial(string isgroup, string userid, string uname, string corp, string customer, string nickname, string isHg, string locationJson, string eid, string deptid, string ext_flag) + { + string[] ROLES = { "NONW" }; + ViewBag.IsHiddenEWM = MangerEWM.GetIsHiddenEWM(ROLES); + ViewBag.userid = userid; + ViewBag.uname = uname; + ViewBag.corp = corp; + ViewBag.customer = customer; + ViewBag.nickname = nickname; + ViewBag.isgroup = isgroup; + ViewBag.locationJson = string.IsNullOrEmpty(locationJson) ? "{\"NeedLocaltion\":0}" : locationJson; + + bool IsCanLoadKeyWords = false; + if (isHg != null && isHg == "True") + { + IsCanLoadKeyWords = true; + } + ViewBag.IsCanLoadKeyWords = IsCanLoadKeyWords; + if (IsCanLoadKeyWords) + ViewBag.KeyWrods = _bas_parameter.GetParameterValue(ParameterEnums.WeiXin_IllegalKewords); + else + ViewBag.KeyWrods = ""; + var content = ""; + var j = ""; + if (customer == null) + { + ViewBag.content = ""; + } + else + { + ext_flag = Utility.Decrypt(ext_flag); + j = JsonConvert.SerializeObject(new saledsleadDesDto { appid = $"{corp}_1", appuserid = customer, deptid = deptid, eid = eid, employeeid = eid, employee_id = eid, employee = eid, ext_flag = ext_flag }); + content = Utility.encyptDataByConfig("saleclue", Newtonsoft.Json.JsonConvert.SerializeObject + ( + new { account = "account", password = "password", appid = $"{corp}_1", appuserid = customer, employee_id = eid, time = Utility.GetTimeStamp() } + ) + ); + ViewBag.content = System.Web.HttpUtility.UrlEncode(content); + } + ViewBag.ShowSaleLine = _bas_parameter.GetParameterValue(ParameterEnums.ShowSaleLine); + ViewBag.SaleLineHttp = _bas_parameter.GetParameterValue(ParameterEnums.SaleLineHttp); + List list = new List(); + string zhi = _bas_parameter.GetParameterValue(ParameterEnums.ShowOtherSaleLT); + if (!string.IsNullOrEmpty(customer) && zhi == "true") + list = _iww_hhuser_service.Extuser_GetAllUser(customer);//外部联系人 + ViewBag.OtherKeFu = list.Where(m => m.userid != userid).ToList();//其他客服,排除掉当前客服 + + string folderName = string.Format("temp_{0}_{1}_{2}", corp, userid, customer); + string groupname = ""; + if (isgroup == "true") + { + Ww_MsgRoom model = _iww_hhuser_service.GetRoom(corp, customer); + ViewBag.roomInfo = model; + ViewBag.nickname = string.IsNullOrEmpty(model.roomname) ? "群:" + model.roomid : "群:" + model.roomname; + groupname = ViewBag.nickname; + + List info = _iww_hhuser_service.GetGroupUser(corp, model); + ViewBag.groupuser = Common.JsonHelper.ObjDivertToJson(info); + } + else + { + ViewBag.groupuser = "[]"; + } + if (MessagePack.GenerateDownFile.ContainsKey(folderName)) + { + ViewBag.IsPackNow = 1;//是不是正在下载 + } + else + { + ViewBag.IsPackNow = 0; + var webPath = FileUnit.GetBaseDirectory();//站点目录 + var tmpPath = Path.Combine(webPath, "temp");//临时文件目录 + string zipPath = Path.Combine(tmpPath, folderName + ".zip"); + ViewBag.folderName = folderName; + FileInfo info = new FileInfo(zipPath); + ViewBag.zipPathName = string.Format("{0} 与 {1} 的聊天记录", uname, nickname); + if (isgroup == "true") + { + ViewBag.zipPathName = string.Format("{0}的聊天记录", groupname); + } + if (info.Exists) + { + string name = info.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") + ".zip";//获取最后修改时间 + ViewBag.NowPathName = string.Format("{0} 与 {1} 的聊天记录{2}", uname, nickname, name); + if (isgroup == "true") + { + ViewBag.NowPathName = string.Format("{0}的聊天记录{1}", groupname, name); + } + } + else + { + ViewBag.NowPathName = ""; + } + } + return View(); + + } + + /// + /// + /// + /// 客服ID + /// 客服名称 + /// 公司ID + /// 客户ID + /// 客户名称 + /// 定位的json信息 + /// + [Area("Admin")] + public ActionResult MessageDetial10(string isgroup, string userid, string uname, string corp, string customer, string nickname, string isHg, string locationJson) { string[] ROLES = { "NONW" }; ViewBag.IsHiddenEWM = MangerEWM.GetIsHiddenEWM(ROLES); @@ -861,99 +972,6 @@ namespace Mini.Web.Areas.Admin.Controllers } - /// - /// - /// - /// 客服ID - /// 客服名称 - /// 公司ID - /// 客户ID - /// 客户名称 - /// 定位的json信息 - /// - [Area("Admin")] - public ActionResult MessageDetial10(string isgroup, string userid, string uname, string corp, string customer, string nickname, string isHg, string locationJson) - { - string[] ROLES = { "NONW" }; - ViewBag.IsHiddenEWM = MangerEWM.GetIsHiddenEWM(ROLES); - ViewBag.userid = userid; - ViewBag.uname = uname; - ViewBag.corp = corp; - ViewBag.customer = customer; - ViewBag.nickname = nickname; - ViewBag.isgroup = isgroup; - ViewBag.locationJson = string.IsNullOrEmpty(locationJson) ? "{\"NeedLocaltion\":0}" : locationJson; - - bool IsCanLoadKeyWords = false; - if (isHg != null && isHg == "True") - { - IsCanLoadKeyWords = true; - } - ViewBag.IsCanLoadKeyWords = IsCanLoadKeyWords; - if (IsCanLoadKeyWords) - ViewBag.KeyWrods = _bas_parameter.GetParameterValue(ParameterEnums.WeiXin_IllegalKewords); - else - ViewBag.KeyWrods = ""; - - ViewBag.ShowSaleLine = _bas_parameter.GetParameterValue(ParameterEnums.ShowSaleLine); - ViewBag.SaleLineHttp = _bas_parameter.GetParameterValue(ParameterEnums.SaleLineHttp); - List list = new List(); - string zhi = _bas_parameter.GetParameterValue(ParameterEnums.ShowOtherSaleLT); - if (!string.IsNullOrEmpty(customer) && zhi == "true") - list = _iww_hhuser_service.Extuser_GetAllUser(customer);//外部联系人 - ViewBag.OtherKeFu = list.Where(m => m.userid != userid).ToList();//其他客服,排除掉当前客服 - - string folderName = string.Format("temp_{0}_{1}_{2}", corp, userid, customer); - string groupname = ""; - if (isgroup == "true") - { - Ww_MsgRoom model = _iww_hhuser_service.GetRoom(corp, customer); - ViewBag.roomInfo = model; - ViewBag.nickname = string.IsNullOrEmpty(model.roomname) ? "群:" + model.roomid : "群:" + model.roomname; - groupname = ViewBag.nickname; - - List info = _iww_hhuser_service.GetGroupUser(corp, model); - ViewBag.groupuser = Common.JsonHelper.ObjDivertToJson(info); - } - else - { - ViewBag.groupuser = "[]"; - } - if (MessagePack.GenerateDownFile.ContainsKey(folderName)) - { - ViewBag.IsPackNow = 1;//是不是正在下载 - } - else - { - ViewBag.IsPackNow = 0; - var webPath = FileUnit.GetBaseDirectory();//站点目录 - var tmpPath = Path.Combine(webPath, "temp");//临时文件目录 - string zipPath = Path.Combine(tmpPath, folderName + ".zip"); - ViewBag.folderName = folderName; - FileInfo info = new FileInfo(zipPath); - ViewBag.zipPathName = string.Format("{0} 与 {1} 的聊天记录", uname, nickname); - if (isgroup == "true") - { - ViewBag.zipPathName = string.Format("{0}的聊天记录", groupname); - } - if (info.Exists) - { - string name = info.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") + ".zip";//获取最后修改时间 - ViewBag.NowPathName = string.Format("{0} 与 {1} 的聊天记录{2}", uname, nickname, name); - if (isgroup == "true") - { - ViewBag.NowPathName = string.Format("{0}的聊天记录{1}", groupname, name); - } - } - else - { - ViewBag.NowPathName = ""; - } - } - return View(); - - } - [Area("Admin")] [HttpGet] diff --git a/Mini.Web/Areas/Admin/Views/OutHHuser/MessageDetial.cshtml b/Mini.Web/Areas/Admin/Views/OutHHuser/MessageDetial.cshtml index 8bf4089..70606ae 100644 --- a/Mini.Web/Areas/Admin/Views/OutHHuser/MessageDetial.cshtml +++ b/Mini.Web/Areas/Admin/Views/OutHHuser/MessageDetial.cshtml @@ -604,9 +604,15 @@ }); } $(function () { + var content = "@Html.Raw(ViewBag.content)" + "&clientid=WK_EXT"; $("#saleline").click(function () { var url = "@Html.Raw(SaleLineHttp)"; - var saleurl = url.replace("{corp}", corp + "_1").replace("{appuserid}", cs_username);//http://sc.soft.dn8188.com/dev.html?appid={corp}&appuserid={appuserid} + //var saleurl = url.replace("{corp}", corp + "_1").replace("{appuserid}", cs_username);//http://sc.soft.dn8188.com/dev.html?appid={corp}&appuserid={appuserid} + if ("@Html.Raw(ViewBag.content)"== "") { + layer.msg('请选择微信好友!'); + return; + } + var saleurl = url.replace("{content}", content); layer.open({ type: 2, content: saleurl, diff --git a/Mini.Web/Areas/Admin/Views/OutHHuser/User_extuserList.cshtml b/Mini.Web/Areas/Admin/Views/OutHHuser/User_extuserList.cshtml index 852daf4..17082d7 100644 --- a/Mini.Web/Areas/Admin/Views/OutHHuser/User_extuserList.cshtml +++ b/Mini.Web/Areas/Admin/Views/OutHHuser/User_extuserList.cshtml @@ -75,6 +75,10 @@ }
+ @if (ViewBag.isChoose) + { + + }

@@ -96,7 +100,8 @@ }] , [ - { field: 'corpname', title: '企业号' } + { field: 'checkobj', type: 'checkbox', fixed: 'left' } + ,{ field: 'corpname', title: '企业号' } , { field: 'name', title: '客户姓名' } , { field: 'extuserid', title: '客户ID' } , { field: 'uname', title: '客服姓名' } @@ -154,14 +159,37 @@ ]], }); - + $('#userChoose').on('click', function () { + var checkdata = table.checkStatus('wxmessagelist'); + var uidata = checkdata.data; + if (uidata.length == 0) { + layer.msg("请至少选中一条记录!", { icon: 7 }); + return; + } + var list = []; + for (var i = 0; i < uidata.length; i++) + { + var item= uidata[i]; + var obj = { + corpid:item.corpid, + corpname:item.corpname, + extuserid:item.extuserid, + userid:item.userid, + ename:item.ename, + eid:item.eid + } + list.push(obj); + } + window.parent.postMessage({ type: "extuserInfo", list: list }, "*"); + }); }); function showMessage(corpid, name, extuserid, uname, userid) { //alert(username); //alert(jobwxusername); //alert(companycode); - var url = "MessageDetial?isgroup=false&corp=" + corpid + "&nickname=" + name + "&customer=" + extuserid + "&uname=" + uname + "&userid=" + userid + "&IsHg=@Html.Raw(ViewBag.isHg)"; + var ext_flag = "@Html.Raw($"&ext_flag={Mini.Common.Utility.EncryptUrlEncode(Mini.Common.Utility.ConvertDateTimeLong(DateTime.Now).ToString()).ToString()}")"; + var url = "MessageDetial?isgroup=false&corp=" + corpid + "&nickname=" + name + "&customer=" + extuserid + "&uname=" + uname + "&userid=" + userid + "&eid=@Html.Raw(ViewBag.eid)" + "&IsHg=@Html.Raw(ViewBag.isHg)" + ext_flag; layui.use('layer', function () { var layer = layui.layer; layer.open({