using System.Collections.Generic; using System.Linq; using WX.CRM.BLL.Util; using WX.CRM.Common; using WX.CRM.DAL.weapp; using WX.CRM.IBLL.weapp; using WX.CRM.Model.Entity; using WX.CRM.Model.QueryMap; namespace WX.CRM.BLL.weapp { public class WEAPP_USERINFO_BL : DbContextRepository, IWEAPP_USERINFO { WX_UserInfo_DAL dal = new WX_UserInfo_DAL(); public List GetWeappUserInfoViews(ref Pager pager, string resId, decimal? eid, string nickName) { using (var db = new crmContext()) { var where = PredicateExtensionses.True(); if (!string.IsNullOrWhiteSpace(resId)) { where = where.And(p => p.RESID == resId); } if (eid.HasValue) { where = where.And(p => p.EID == eid.Value); } if (!string.IsNullOrWhiteSpace(nickName)) { where = where.And(p => p.NICKNAME == nickName); } var query = from q0 in db.WEAPP_USERINFO join q1 in db.WEAPP_FRIENDS on q0.OPENID equals q1.OPENID join q2 in db.WEAPP_USERINFO_ORDEREXT on q0.OPENID equals q2.OPENID into jointemp from q2 in jointemp.DefaultIfEmpty() select new WeappUserInfoView() { PKID = q0.PKID, OPENID = q0.OPENID, NICKNAME = q0.NICKNAME, GENDER = q0.GENDER, LANGUAGE = q0.LANGUAGE, CITY = q0.CITY, PROVINCE = q0.PROVINCE, COUNTRY = q0.COUNTRY, AVATARURL = q0.AVATARURL, INFOTYPE = q0.INFOTYPE, CTIME = q0.CTIME, UTIME = q0.UTIME, MD5 = q0.MD5, ISUPDATE = q0.ISUPDATE, UNIONID = q0.UNIONID, ISOK = q0.ISOK, FILENAME = q0.FILENAME, ACCOUNTNUM = q0.ACCOUNTNUM, SUBSCRIBE = q0.SUBSCRIBE, SUBSCRIBETIME = q0.SUBSCRIBETIME, UNSUBTIME = q0.UNSUBTIME, RESID = q0.RESID, EID = q1.EID, OPTIME = q1.OPTIME, SubProductName = q2.SUBPRODUCTNAME }; query = query.Where(where); query = query.OrderByDescending(p => p.CTIME); PagerUtil.SetPager(ref query, ref pager); return query.ToList(); } } public int BindResIdByOpenId(string openId, string resId, decimal resIdVerify, ref ValidationErrors errors) { return dal.BindResIdByOpenId(openId, resId, resIdVerify, ref errors); } public WEAPP_USERINFO_ORDEREXT GetUserInfoOrderExtByOpenId(string openId) { using (var db = new crmContext()) { var query = db.WEAPP_USERINFO_ORDEREXT.AsQueryable(); if (string.IsNullOrWhiteSpace(openId)) { return query.Where(m => m.OPENID == openId).OrderByDescending(m => m.ENDTIME).SingleOrDefault(); } return null; } } } }