using System; using System.Collections.Generic; using System.Linq; using WX.CRM.Common; using WX.CRM.IBLL.QH; using WX.CRM.Model.Entity; namespace WX.CRM.BLL.QH { public class QH_PerformanceAudit_BL : DbContextRepository, IQH_PerformanceAudit { public void AuditPerformanceUser(decimal PKID, int sta, string remark, decimal auditid, string auditname) { using (var db = new crmContext()) { var info = db.QH_BALANCESALEUSERAUDIT.FirstOrDefault(p => p.PKID == PKID); if (info == null) { throw new Exception("未找到结算记录!"); } if (info.STATUS == "已确认") { throw new Exception("已经确认过了!"); } if (sta == 0) info.STATUS = "未确认"; else if (sta == 1) info.STATUS = "已确认"; else info.STATUS = "未知"; info.REMARK = remark; info.AUDITBYUSERID = auditid; info.AUDITBYUSERNAME = auditname; info.AUDITTIME = System.DateTime.Now; db.SaveChanges(); } } public IList GetAutitList(string gId, decimal uId, DateTime? balanceCode, string status) { using (var db = new crmContext()) { var where = PredicateExtensionses.True(); if (uId > 0) { where = where.And(p => p.INNERUSERID == uId); } else if (!string.IsNullOrEmpty(gId)) { decimal[] _groupids = OperationUtil.ConvertToDecimal(gId.Split(',')); var uIds = db.BAS_INNERUSERGROUP.Where(p => _groupids.Contains(p.GID.Value)).Select(p => p.INNERUSERID); var userEIds = db.BAS_INNERUSER.Where(d => uIds.Contains(d.PKID)).Select(p => p.EID).ToArray(); where = where.And(m => userEIds.Contains(m.EID)); } if (balanceCode.HasValue) { where = where.And(p => p.MONTH == balanceCode.Value); } if (!string.IsNullOrEmpty(status)) { where = where.And(p => p.STATUS == status); } var list = GetList(where); return list.ToList(); } } } }