using System; using System.Collections.Generic; using System.Data; using System.Linq; using WX.CRM.BLL.Util; using WX.CRM.Common; using WX.CRM.DAL.Wx; using WX.CRM.IBLL.Wx; using WX.CRM.Model.Entity; using WX.CRM.Model.MAP; using WX.CRM.Model.QueryMap; namespace WX.CRM.BLL.Wx { public class WX_RCONTACT_BL : DbContextRepository, IWX_RCONTACT { private WX_RCONTACT_DAL wx_Rcontact_DAL = new WX_RCONTACT_DAL(); public WX_RCONTACT GetModel(decimal pkid) { using (var db = new crmContext()) { return db.WX_RCONTACT.Where(m => m.PKID == pkid).FirstOrDefault(); } } public List GetList(ref Pager page, string jobWxUserName, string userName, string alias, string nickName, string conRemark, string stime, string etime) { using (var db = new crmContext()) { var queryData = db.WX_RCONTACT.AsQueryable(); if (!string.IsNullOrWhiteSpace(jobWxUserName)) { jobWxUserName = jobWxUserName.Trim(); queryData = queryData.Where(m => m.JOBWXUSERNAME == jobWxUserName); } if (!string.IsNullOrWhiteSpace(userName)) { userName = userName.Trim(); queryData = queryData.Where(m => m.USERNAME.Contains(userName)); } if (!string.IsNullOrWhiteSpace(alias)) { alias = alias.Trim(); queryData = queryData.Where(m => m.ALIAS.Contains(alias)); } if (!string.IsNullOrWhiteSpace(nickName)) { nickName = nickName.Trim(); queryData = queryData.Where(m => m.NICKNAME.Contains(nickName)); } if (!string.IsNullOrWhiteSpace(conRemark)) { conRemark = conRemark.Trim(); queryData = queryData.Where(m => m.CONREMARK.Contains(conRemark)); } if (!string.IsNullOrWhiteSpace(stime)) { DateTime time1 = Convert.ToDateTime(stime); queryData = queryData.Where(m => m.CTIME >= time1); } if (!string.IsNullOrWhiteSpace(etime)) { DateTime time2 = Convert.ToDateTime(etime).AddDays(1); queryData = queryData.Where(m => m.CTIME < time2); } queryData = queryData.OrderByDescending(m => m.CTIME); PagerUtil.SetPager(ref queryData, ref page); return queryData.ToList(); } } public List GetFilterList(ref Pager page, string jobWxUserName, string userName, string alias, string nickName, string conRemark, string stime, string etime) { using (var db = new crmContext()) { var queryData = db.WX_RCONTACT.Where(m => !m.USERNAME.StartsWith("fake_") && !m.USERNAME.StartsWith("gh_") && !m.USERNAME.Equals("weixin")).AsQueryable(); if (!string.IsNullOrWhiteSpace(jobWxUserName)) { jobWxUserName = jobWxUserName.Trim(); queryData = queryData.Where(m => m.JOBWXUSERNAME == jobWxUserName); } if (!string.IsNullOrWhiteSpace(userName)) { userName = userName.Trim(); queryData = queryData.Where(m => m.USERNAME.Contains(userName)); } if (!string.IsNullOrWhiteSpace(alias)) { alias = alias.Trim(); queryData = queryData.Where(m => m.ALIAS.Contains(alias)); } if (!string.IsNullOrWhiteSpace(nickName)) { nickName = nickName.Trim(); queryData = queryData.Where(m => m.NICKNAME.Contains(nickName)); } if (!string.IsNullOrWhiteSpace(conRemark)) { conRemark = conRemark.Trim(); queryData = queryData.Where(m => m.CONREMARK.Contains(conRemark)); } if (!string.IsNullOrWhiteSpace(stime)) { DateTime time1 = Convert.ToDateTime(stime); queryData = queryData.Where(m => m.CTIME >= time1); } if (!string.IsNullOrWhiteSpace(etime)) { DateTime time2 = Convert.ToDateTime(etime).AddDays(1); queryData = queryData.Where(m => m.CTIME < time2); } queryData = queryData.OrderByDescending(m => m.CTIME); PagerUtil.SetPager(ref queryData, ref page); return queryData.ToList(); } } public List GetListAndWorkAccount(ref Pager page, string jobWxUserName, string userName, string alias, string nickName, string conRemark, string stime, string etime, string resId) { using (var db = new crmContext()) { var queryData = db.WX_RCONTACT.AsQueryable(); //过滤非好友的,群里面的记录 List types = new List { 1, 3, 5, 7, 257, 259, 67, 65539 }; queryData = queryData.Where(m => m.TYPE > 11 || types.Contains(m.TYPE)); if (!string.IsNullOrWhiteSpace(jobWxUserName)) { jobWxUserName = jobWxUserName.Trim(); queryData = queryData.Where(m => m.JOBWXUSERNAME == jobWxUserName); } if (!string.IsNullOrWhiteSpace(userName)) { userName = userName.Trim(); queryData = queryData.Where(m => m.USERNAME == userName); } if (!string.IsNullOrWhiteSpace(alias)) { alias = alias.Trim(); queryData = queryData.Where(m => m.ALIAS.Contains(alias)); } if (!string.IsNullOrWhiteSpace(nickName)) { nickName = nickName.Trim(); queryData = queryData.Where(m => m.NICKNAME.Contains(nickName)); } if (!string.IsNullOrWhiteSpace(conRemark)) { conRemark = conRemark.Trim(); queryData = queryData.Where(m => m.CONREMARK.Contains(conRemark)); } if (!string.IsNullOrWhiteSpace(resId)) { resId = resId.Trim(); queryData = queryData.Where(m => m.RESID == resId); } if (!string.IsNullOrWhiteSpace(stime)) { DateTime time1 = Convert.ToDateTime(stime); queryData = queryData.Where(m => m.CTIME >= time1); } if (!string.IsNullOrWhiteSpace(etime)) { DateTime time2 = Convert.ToDateTime(etime).AddDays(1); queryData = queryData.Where(m => m.CTIME < time2); } var query = from r in queryData join o in db.WX_WORKACCOUNT on r.JOBWXUSERNAME equals o.USERNAME into tmp0 from ro in tmp0.DefaultIfEmpty() select new WX_RCONTACT_Extend() { wx_rcontact = r, inneruserId = ro.INNERUSERID, WorkAlias = ro.ALIAS }; query = query.OrderByDescending(m => m.wx_rcontact.CTIME); PagerUtil.SetPager(ref query, ref page); return query.ToList(); } } public List GetMyList(ref Pager pager, string resId, string userName, string alias, string conreMark, string nickName, string jobWxUser, string stime, string etime, decimal? userId, bool canSearchAll, decimal? orderId = null) { using (var db = new crmContext()) { var queryData = db.WX_RCONTACT.AsQueryable(); if (!string.IsNullOrWhiteSpace(resId)) { queryData = queryData.Where(p => p.RESID == resId); } if (!string.IsNullOrWhiteSpace(userName)) { queryData = queryData.Where(p => p.USERNAME.Contains(userName)); } if (!string.IsNullOrWhiteSpace(alias)) { queryData = queryData.Where(p => p.ALIAS.Contains(alias)); } if (!string.IsNullOrWhiteSpace(conreMark)) { queryData = queryData.Where(p => p.CONREMARK.Contains(conreMark)); } if (!string.IsNullOrWhiteSpace(nickName)) { queryData = queryData.Where(p => p.NICKNAME.Contains(nickName)); } if (!string.IsNullOrWhiteSpace(jobWxUser)) { queryData = queryData.Where(p => p.JOBWXUSERNAME == jobWxUser); } else { //var myWorkAccountList = new WX_WORKACCOUNT_BL().GetMyWorkAccountList(userId); //List jobWxList = new List(); //foreach (var workAccount in myWorkAccountList) //{ // if (!string.IsNullOrWhiteSpace(workAccount.USERNAME)) // { // jobWxList.Add(workAccount.USERNAME); // } //} //queryData = queryData.Where(p => jobWxList.Contains(p.JOBWXUSERNAME)); List jobWxList = new List(); if (orderId.HasValue) { //var orderUserIds = new WX_COMMISSIONRULE_BL().GetList(p => p.ORDERID == orderId.Value).Select(p => p.SALEUSERID).ToList(); //foreach (var item in orderUserIds) //{ // var myWorkAccountList = workAccountList.Where(p => p.INNERUSERID == item); // foreach (var workAccount in myWorkAccountList) // { // if (!string.IsNullOrWhiteSpace(workAccount.USERNAME)) // { // jobWxList.Add(workAccount.USERNAME); // } // } //} var orderUserIds = db.WX_COMMISSIONRULE.AsQueryable().Where(p => p.ORDERID == orderId.Value).Select(p => p.SALEUSERID).ToList(); var myWorkAccountList = db.WX_WORKACCOUNT.AsQueryable().Where(p => orderUserIds.Contains(p.INNERUSERID.Value)); if (!orderUserIds.Any()) { myWorkAccountList = db.WX_WORKACCOUNT.AsQueryable(); if (userId.HasValue) { myWorkAccountList = myWorkAccountList.Where(p => p.INNERUSERID == userId); } } foreach (var workAccount in myWorkAccountList) { if (!string.IsNullOrWhiteSpace(workAccount.USERNAME)) { jobWxList.Add(workAccount.USERNAME); } } } else { var myWorkAccountList = db.WX_WORKACCOUNT.AsQueryable(); if (userId.HasValue) { myWorkAccountList = myWorkAccountList.Where(p => p.INNERUSERID == userId); } foreach (var workAccount in myWorkAccountList) { if (!string.IsNullOrWhiteSpace(workAccount.USERNAME)) { jobWxList.Add(workAccount.USERNAME); } } } queryData = queryData.Where(p => jobWxList.Contains(p.JOBWXUSERNAME)); } if (!string.IsNullOrWhiteSpace(stime)) { DateTime dt = Convert.ToDateTime(stime); queryData = queryData.Where(p => p.CTIME >= dt); } if (!string.IsNullOrWhiteSpace(etime)) { DateTime dt = Convert.ToDateTime(etime).AddDays(1); queryData = queryData.Where(p => p.CTIME < dt); } queryData = queryData.OrderByDescending(m => m.CTIME); PagerUtil.SetPager(ref queryData, ref pager); return queryData.ToList(); } } public List GetWorkAliasRcontactList(ref Pager pager, string userName, string alias, string conreMark, string nickName, string workAlias) { using (var db = new crmContext()) { var queryData = db.WX_RCONTACT.AsQueryable(); if (!string.IsNullOrWhiteSpace(userName)) { queryData = queryData.Where(p => p.USERNAME.Contains(userName)); } if (!string.IsNullOrWhiteSpace(alias)) { queryData = queryData.Where(p => p.ALIAS.Contains(alias)); } if (!string.IsNullOrWhiteSpace(conreMark)) { queryData = queryData.Where(p => p.CONREMARK.Contains(conreMark)); } if (!string.IsNullOrWhiteSpace(nickName)) { queryData = queryData.Where(p => p.NICKNAME.Contains(nickName)); } if (!string.IsNullOrWhiteSpace(workAlias)) { var myWorkAccount = db.WX_WORKACCOUNT.AsQueryable().Where(p => p.ALIAS == workAlias).FirstOrDefault(); if (myWorkAccount != null) { queryData = queryData.Where(p => p.JOBWXUSERNAME == myWorkAccount.USERNAME); } else { queryData = queryData.Where(p => p.JOBWXUSERNAME == ""); } } queryData = queryData.OrderByDescending(m => m.CTIME); PagerUtil.SetPager(ref queryData, ref pager); return queryData.ToList(); } } public bool UpdateResId(ref ValidationErrors errors, decimal pkId, string resId) { try { using (var db = new crmContext()) { var model = db.WX_RCONTACT.Where(m => m.PKID == pkId).FirstOrDefault(); if (model != null) { model.RESID = resId; } return db.SaveChanges().GetResult(); } } catch (Exception ex) { errors.Add(ex.Message); LogHelper.Error(ex); return false; } } public DataSet ExportWeiXinResource(DateTime beginTime, DateTime endTime, decimal? inneruserid) { return new WX_RCONTACT_DAL().ExportWeiXinResource(beginTime, endTime, inneruserid); } public DataTable CountRcontactByWxJobUserName() { DataTable dt = wx_Rcontact_DAL.CountRcontactByWxJobUserName(); return dt; } public DataTable CountRcontactByInnerUserId() { return wx_Rcontact_DAL.CountRcontactByInnerUserId(); } public DataTable CountRcontactByUserGroup() { return wx_Rcontact_DAL.CountRcontactByUserGroup(); } /// /// 推送数据到推广 /// /// 用户名 /// 工作微信username /// 返回PICI public decimal pushRcontactToTG(string v_username, string v_jobusername) { return wx_Rcontact_DAL.pushRcontactToTG(v_username, v_jobusername); } /// /// 从message表中提取好友关系被加数据 /// /// 好友username /// 工作微信 /// msgSvrId /// 内容 /// 时间 /// 返回pici public decimal extractToBeFriendsDataFromMsg(decimal type, string v_username, string v_jobusername, DateTime v_createTime, ref bool ret) { return wx_Rcontact_DAL.extractToBeFriendsDataFromMsg(type, v_username, v_jobusername, v_createTime, ref ret); } public DataTable RcontactByDayReport(DateTime? beginTime, DateTime? endTime, decimal? type) { return wx_Rcontact_DAL.RcontactByDayReport(beginTime, endTime, type); } public DataTable RcontactByUserAndDay(DateTime beginTime, DateTime endTime, decimal? type) { return wx_Rcontact_DAL.RcontactByUserAndDay(beginTime, endTime, type); } public DataTable RcontactByTag(DateTime beginTime, DateTime endTime) { return wx_Rcontact_DAL.RcontactByTag(beginTime, endTime); } /// /// 获取微信信息配置 /// /// /// public Wx_MsgConfig GetMsgConfig(string username) { return wx_Rcontact_DAL.GetMsgConfig(username); } public bool WxDbUploadLog(WX_DBUPLOADLOG model, long createTime, DateTime createTimewin, string qunfaclientid) { return wx_Rcontact_DAL.WxDbUploadLog(model, createTime, createTimewin, qunfaclientid); } public IList GetWxResourceCheck(decimal? groupId, decimal? userId) { using (var db = new crmContext()) { var workAccountList = new WX_WORKACCOUNT_BL().GetList(); var where = PredicateExtensionses.True(); if (groupId.HasValue) { var userids = db.BAS_INNERUSERGROUP.Where(m => m.GID.Value == groupId.Value).Select(m => m.INNERUSERID); List jobWxList = new List(); foreach (var item in userids) { var myWorkAccountList = workAccountList.Where(p => p.INNERUSERID == item); foreach (var workAccount in myWorkAccountList) { if (!string.IsNullOrWhiteSpace(workAccount.USERNAME)) { jobWxList.Add(workAccount.USERNAME); } } } where = where.And(p => jobWxList.Contains(p.JobUserName)); } else if (userId.HasValue) { var myWorkAccountList = workAccountList.Where(p => p.INNERUSERID == userId.Value); List jobWxList = new List(); foreach (var workAccount in myWorkAccountList) { if (!string.IsNullOrWhiteSpace(workAccount.USERNAME)) { jobWxList.Add(workAccount.USERNAME); } } where = where.And(p => jobWxList.Contains(p.JobUserName)); } var afterSaleList = from w in db.WX_WORKACCOUNT join u in db.BAS_INNERUSER on w.INNERUSERID equals u.PKID join ug in db.BAS_INNERUSERGROUP on u.PKID equals ug.INNERUSERID join g in db.BAS_INNERGROUP on ug.GID equals g.GID where g.GNAME == "服务组" select w.USERNAME; var rList = (from rc in db.WX_RESOURCECHECK select new { rc.USERNAME, rc.JOBUSERNAME }).Distinct(); var list = from p in db.WX_RCONTACT join t in (from rc in db.WX_RESOURCECHECK select new { rc.USERNAME, rc.CTIME }).Distinct() on p.USERNAME equals t.USERNAME join w in (from ww in db.WX_WORKACCOUNT where !afterSaleList.Contains(ww.USERNAME) select ww) on p.JOBWXUSERNAME equals w.USERNAME where !rList.Any(r => r.JOBUSERNAME == p.JOBWXUSERNAME && r.USERNAME == p.USERNAME) && !db.WX_RESOURCECHECK_NOTE.Any(m => m.USERNAME == p.USERNAME) orderby t.CTIME descending select new WxResourceCheckView() { Eid = w.INNERUSERID.Value, alias = w.ALIAS, UserName = p.USERNAME, JobUserName = p.JOBWXUSERNAME, NickName = p.NICKNAME, ReMark = p.CONREMARK, InneruserId = w.INNERUSERID.Value }; list = list.Where(where); return list.ToList(); } } public IList GetMyWxCustomerList(Pager pager, string resId, string userName, string alias, string conreMark, string nickName, string jobWxUser, string stime, string etime, decimal userId, string isopen) { using (var db = new crmContext()) { var where = PredicateExtensionses.True(); if (!string.IsNullOrWhiteSpace(resId)) { where = where.And(p => p.RESID == resId); } if (!string.IsNullOrWhiteSpace(userName)) { where = where.And(p => p.USERNAME.Contains(userName)); } if (!string.IsNullOrWhiteSpace(alias)) { where = where.And(p => p.ALIAS.Contains(alias)); } if (!string.IsNullOrWhiteSpace(conreMark)) { where = where.And(p => p.CONREMARK.Contains(conreMark)); } if (!string.IsNullOrWhiteSpace(jobWxUser)) { where = where.And(p => p.JOBWXUSERNAME == jobWxUser); } else { var myWorkAccountList = new WX_WORKACCOUNT_BL().GetMyWorkAccountList(userId); List jobWxList = new List(); foreach (var workAccount in myWorkAccountList) { if (!string.IsNullOrWhiteSpace(workAccount.USERNAME)) { jobWxList.Add(workAccount.USERNAME); } } where = where.And(p => jobWxList.Contains(p.JOBWXUSERNAME)); } if (!string.IsNullOrWhiteSpace(stime)) { DateTime dt = Convert.ToDateTime(stime); where = where.And(p => p.CTIME >= dt); } if (!string.IsNullOrWhiteSpace(etime)) { DateTime dt = Convert.ToDateTime(etime).AddDays(1); where = where.And(p => p.CTIME < dt); } if (!string.IsNullOrEmpty(isopen)) { var letIsOpen = int.Parse(isopen); if (letIsOpen == 1) where = where.And(p => p.IsOpen == letIsOpen); else where = where.And(p => p.IsOpen == null); //where = where.And(p => p.IsOpen == letIsOpen); } var query = from r in db.WX_RCONTACT join c in db.RES_CUSTOMER on r.RESID equals c.RESID join o in (db.WX_SZZYORDER.Where(p => p.ISOPEN == 1).GroupBy(p => new { p.CUSTOMERUSERNAME, p.ISOPEN }).Select(g => new { g.Key.CUSTOMERUSERNAME, g.Key.ISOPEN })) on r.USERNAME equals o.CUSTOMERUSERNAME into tmp0 from ro in tmp0.DefaultIfEmpty() //join c in db.WX_COMMISSIONRULE.Where(p => p.SALEUSERID == userId) on ro.ORDERID equals c.ORDERID into tmp1 //from roc in tmp1.DefaultIfEmpty() select new WX_RCONTACT_VIEW() { PKID = r.PKID, JOBWXUSERNAME = r.JOBWXUSERNAME, USERNAME = r.USERNAME, ALIAS = r.ALIAS, RESID = c.UMID, NICKNAME = r.NICKNAME, CONREMARK = r.CONREMARK, CTIME = r.CTIME, IsOpen = ro.ISOPEN }; query = query.Where(where); query = query.OrderByDescending(p => p.CTIME); PagerUtil.SetPager(ref query, ref pager); return query.ToList(); } } public List GetJobWeiXinLastFriendList() { List list = new List(); DataSet ds = wx_Rcontact_DAL.GetJobWeiXinLastFriendList(); if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { list = ds.Tables[0].ToList(); } return list; } public decimal GetDistinctWeiXinFriendCount(string day, decimal? type, decimal? saleDeptId) { return wx_Rcontact_DAL.GetDistinctWeiXinFriendCount(day, type, saleDeptId); } public int ResourceByTagDistinctCount(DateTime beginTime, string tag) { return wx_Rcontact_DAL.ResourceByTagDistinctCount(beginTime, tag); } public int ResourceByNameDistinctCount(DateTime beginTime, string tag, decimal? groupid) { return wx_Rcontact_DAL.ResourceByNameDistinctCount(beginTime, tag, groupid); } public DataTable GetRcontactByResId(string resid) { return new WX_RCONTACT_DAL().GetRcontactList(resid); } public DataTable GetChatUserByResId(string resid) { return new WX_RCONTACT_DAL().GetChatUserByResId(resid); } public DataTable GetChatQwByResId(string resid) { return new WX_RCONTACT_DAL().GetChatQwByResId(resid); } public DataTable GetChatUser(string resid, string username, string alias, string nickname, string conremark, string jobusername, string workalias, decimal? eid) { return new WX_RCONTACT_DAL().GetChatUser(resid, username, alias, nickname, conremark, jobusername, workalias, eid); } public bool UpdateRcontactResId(ref ValidationErrors errors, string username, string resid, decimal inneruserid) { bool isSucced = true; try { new WX_RCONTACT_DAL().UpdateRcontactResId(username, resid, inneruserid); } catch (Exception ex) { errors.Add("出现错误:" + ex.ToString()); LogHelper.Error(ex.ToString()); isSucced = false; } return isSucced; } public WX_RCONTACT GetModel(string jobusername, string username) { using (crmContext db = new crmContext()) { return db.WX_RCONTACT.FirstOrDefault(m => m.USERNAME == username && m.JOBWXUSERNAME == jobusername); } } public DataSet GetWeixinFriendCount(decimal type) { return wx_Rcontact_DAL.GetWeixinFriendCount(type); } public int UpadteUserPoint(ref ValidationErrors errors, string eids, string points, decimal type) { try { if (string.IsNullOrWhiteSpace(eids) || string.IsNullOrWhiteSpace(eids) || string.IsNullOrWhiteSpace(points)) { return (int)WxUpdatePercentFlag.ParamsError; } string[] eidArry = eids.Split(','); string[] pointArry = points.Split(','); for (int i = 0; i < eidArry.Length; i++) { decimal eid = Convert.ToDecimal(eidArry[i]); decimal point = Convert.ToDecimal(pointArry[i]); wx_Rcontact_DAL.UpadteUserPoint(eid, point); } wx_Rcontact_DAL.ComputeToPushData(eids, type); return (int)WxUpdatePercentFlag.Success; } catch (Exception ex) { errors.Add(ex.Message); return (int)WxUpdatePercentFlag.Fail; } } public List CountSaleUserCommission() { return wx_Rcontact_DAL.CountSaleUserCommission().ToList(); } public List CountSaleGroupCommission() { return wx_Rcontact_DAL.CountSaleGroupCommission().ToList(); } public List GetRcontactUserNameCount(string stime, string etime, List usernameList) { var usernames = ""; if (string.IsNullOrEmpty(stime)) { stime = DateTime.Now.ToShortDateString(); } if (string.IsNullOrEmpty(etime)) { etime = DateTime.Now.AddDays(1).ToShortDateString(); } else { etime = Convert.ToDateTime(etime).AddDays(1).ToShortDateString(); } if (usernameList != null) { foreach (var m in usernameList) { usernames += "'" + m + "',"; } if (usernames != null) { usernames = usernames.TrimEnd(','); } } DataSet ds = wx_Rcontact_DAL.GetRcontactUserNameCount(stime, etime, usernames); if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { return ds.Tables[0].ToList(); } return new List(); ; } public DataSet GetWebChatResourceList(DateTime? beginTime, DateTime? endTime, decimal? type) { return wx_Rcontact_DAL.GetWebChatResourceList(beginTime, endTime, type); } public DataSet GetWebChatResourceDetail(DateTime? beginTime, DateTime? endTime, string jobUsername) { return wx_Rcontact_DAL.GetWebChatResourceDetail(beginTime, endTime, jobUsername); } //public List GetList(ref Pager page, string username, string jobwxusername, string inneruserId, string groupId, decimal salesId, string stime, string etime) //{ // using (var db = new crmContext()) // { // var queryData = db.WX_RCONTACT.AsQueryable(); // var inneruserJobNumData = db.WX_INNERUSERJOBNUM.AsEnumerable(); // if (!string.IsNullOrWhiteSpace(username)) // { // username = username.Trim(); // queryData = queryData.Where(m => m.USERNAME.Contains(username)); // } // if (!string.IsNullOrWhiteSpace(jobwxusername)) // { // jobwxusername = jobwxusername.Trim(); // queryData = queryData.Where(m => m.JOBWXUSERNAME.Contains(jobwxusername)); // } // if (!string.IsNullOrWhiteSpace(stime)) // { // DateTime time1 = Convert.ToDateTime(stime); // queryData = queryData.Where(m => m.CTIME >= time1); // } // if (!string.IsNullOrWhiteSpace(etime)) // { // DateTime time2 = Convert.ToDateTime(etime).AddDays(1); // queryData = queryData.Where(m => m.CTIME >= time2); // } // if (!string.IsNullOrWhiteSpace(inneruserId)) // { // decimal userid = Convert.ToDecimal(inneruserId); // inneruserJobNumData = inneruserJobNumData.Where(m => m.INNERUSERID == userid); // } // else if (!string.IsNullOrWhiteSpace(groupId)) // { // decimal[] _groupIds = OperationUtil.ConvertToDecimal(groupId.Split(',')); // var userids = db.BAS_INNERUSERGROUP.Where(m => _groupIds.Contains(m.GID.Value)).Select(m => m.INNERUSERID); // inneruserJobNumData = inneruserJobNumData.Where(m => userids.Contains(m.INNERUSERID.Value)); // } // if (salesId > 0) // inneruserJobNumData = inneruserJobNumData.Where(m => m.INNERUSERID == salesId); // var returnData = (from a in queryData // join b in inneruserJobNumData on a.JOBWXUSERNAME equals b.WXUSERNAME // join c in db.BAS_INNERUSER on b.INNERUSERID equals c.PKID // join d in db.BAS_INNERUSERGROUP on c.PKID equals d.INNERUSERID // join e in db.BAS_INNERGROUP on d.GID equals e.GID // select new WX_RCONTACT_Extend() // { // wx_rcontact = a, // groupid = d.GID.Value, // groupName = e.GNAME, // inneruserEid = c.EID, // inneruserName = c.TRUENAME, // inneruserId = c.PKID // }); // returnData = returnData.OrderBy(m => m.groupid).OrderBy(m => m.inneruserEid).OrderBy(m => m.wx_rcontact.JOBWXUSERNAME).OrderBy(m => m.wx_rcontact.USERNAME); // PagerUtil.SetPager(ref returnData, ref page); // return returnData.ToList(); // } /// /// 获取工作微信的订单客户 /// /// /// public DataTable GetOrderUserName(string jobusername) { return new WX_RCONTACT_DAL().GetOrderUserName(jobusername); } } }