From 0712acb55971528772dc42727b271f1d3a176c9c Mon Sep 17 00:00:00 2001 From: feng <279202647@qq.com> Date: Mon, 23 May 2022 22:04:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=B7=B2=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=97=A5=E6=9C=9F=E4=B8=BA=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HuiYan/teamitemsBusiness.cs | 15 +++-- src/Coldairarrow.Entity/DTO/TaskInfoDto.cs | 35 +++++++++++ .../Extention/Extention.Expression.cs | 61 +++++++++++-------- 3 files changed, 78 insertions(+), 33 deletions(-) diff --git a/src/Coldairarrow.Business/HuiYan/teamitemsBusiness.cs b/src/Coldairarrow.Business/HuiYan/teamitemsBusiness.cs index 4b6920f..94510db 100644 --- a/src/Coldairarrow.Business/HuiYan/teamitemsBusiness.cs +++ b/src/Coldairarrow.Business/HuiYan/teamitemsBusiness.cs @@ -320,7 +320,7 @@ namespace Coldairarrow.Business.HuiYan var q = from a in q_titem.AsExpandable() join b in Db.GetIQueryable() on a.Id equals b.TeamItemId into ab from b in ab.DefaultIfEmpty() - select @select.Invoke(b, a); + select @select.Invoke(b==null?new pricetasklog():b, a); var where = LinqHelper.True(); @@ -355,18 +355,19 @@ namespace Coldairarrow.Business.HuiYan } + public AjaxResult GetTjInfo(DateTime start, DateTime end) { Expression> select = (a, b) => new TaskInfoDto { - IsPass = b.IsQualified, + IsPass = b.IsQualified == null ? null : b.IsQualified.Value, TeamId = b.TeamId, TeamUserId = b.UserId, TeamDate = b.CreateTime, - TeamOverDate = b.UpdateDate, + TeamOverDate = b.UpdateDate==null?null:b.UpdateDate.Value, PriceTaskUserId = b.PriceTaskUserId, TeamItemState = (TeamItemState?)b.State, - PriceTaskCreateDate=b.PriceTaskCreateDate + PriceTaskCreateDate = b.PriceTaskCreateDate == null ? null : b.PriceTaskCreateDate.Value }; select = select.BuildExtendSelectExpre(); @@ -375,13 +376,15 @@ namespace Coldairarrow.Business.HuiYan var q = from a in q_titem.AsExpandable() join b in Db.GetIQueryable() on a.Id equals b.TeamItemId into ab from b in ab.DefaultIfEmpty() - select @select.Invoke(b, a); + select @select.Invoke(b==null?new pricetasklog():b, a); var where = LinqHelper.True(); start=new DateTime(start.Year, start.Month, start.Day); end = new DateTime(end.Year, end.Month, end.Day, 23, 59, 59); - where = where.And(c => c.PriceTaskCreateDate >= start && c.PriceTaskCreateDate <= end); + + where = where.And(c => c.PriceTaskCreateDate >= start && c.PriceTaskCreateDate <= end); + var list = q.Where(where).ToList(); diff --git a/src/Coldairarrow.Entity/DTO/TaskInfoDto.cs b/src/Coldairarrow.Entity/DTO/TaskInfoDto.cs index e7f2c0a..97ce02d 100644 --- a/src/Coldairarrow.Entity/DTO/TaskInfoDto.cs +++ b/src/Coldairarrow.Entity/DTO/TaskInfoDto.cs @@ -33,6 +33,41 @@ namespace Coldairarrow.Entity.DTO public DateTime? PriceTaskCreateDate { get; set; } } + public class PriceTaskInfoDto:HuiYan.teamitems + { + public String TaskId { get; set; } + + /// + /// 创建时间 + /// + public DateTime TaskCreateTime { get; set; } + + /// + /// 分配的团队用户ID + /// + public String TaskUserId { get; set; } + + /// + /// 团队商品的ID + /// + public String TeamItemId { get; set; } + + /// + /// 比价状态 + /// + public PriceTaskState TaskState { get; set; } + + /// + /// 审核提交时间,超过24小时将自动完成 + /// + public DateTime? WorkDate { get; set; } + + /// + /// 订单ID + /// + public string OrderId { get; set; } + } + public class PriceTaskInfo { diff --git a/src/Coldairarrow.Util/Extention/Extention.Expression.cs b/src/Coldairarrow.Util/Extention/Extention.Expression.cs index 92f2412..46584d5 100644 --- a/src/Coldairarrow.Util/Extention/Extention.Expression.cs +++ b/src/Coldairarrow.Util/Extention/Extention.Expression.cs @@ -235,41 +235,48 @@ namespace Coldairarrow.Util private static Expression GetExtendSelectExpre(Expression expression) { - NewExpression newBody = Expression.New(typeof(TResult)); - MemberInitExpression oldExpression = (MemberInitExpression)expression.Body; - - ParameterExpression[] oldParamters = expression.Parameters.ToArray(); - List existsProperties = new List(); - oldExpression.Bindings.ToList().ForEach(aBinding => + try { - existsProperties.Add(aBinding.Member.Name); - }); + NewExpression newBody = Expression.New(typeof(TResult)); + MemberInitExpression oldExpression = (MemberInitExpression)expression.Body; - List newBindings = new List(); - typeof(TBase).GetProperties().Where(x => !existsProperties.Contains(x.Name)).ToList().ForEach(aProperty => - { - if (typeof(TResult).GetMembers().Any(x => x.Name == aProperty.Name)) + ParameterExpression[] oldParamters = expression.Parameters.ToArray(); + List existsProperties = new List(); + oldExpression.Bindings.ToList().ForEach(aBinding => { - MemberBinding newMemberBinding = null; - var valueExpre = Expression.Property(oldParamters[0], aProperty.Name); - if (typeof(TBase).IsAssignableFrom(typeof(TResult))) - { - newMemberBinding = Expression.Bind(aProperty, valueExpre); - } - else + existsProperties.Add(aBinding.Member.Name); + }); + + List newBindings = new List(); + typeof(TBase).GetProperties().Where(x => !existsProperties.Contains(x.Name)).ToList().ForEach(aProperty => + { + if (typeof(TResult).GetMembers().Any(x => x.Name == aProperty.Name)) { - newMemberBinding = Expression.Bind(typeof(TResult).GetProperty(aProperty.Name), valueExpre); + MemberBinding newMemberBinding = null; + var valueExpre = Expression.Property(oldParamters[0], aProperty.Name); + if (typeof(TBase).IsAssignableFrom(typeof(TResult))) + { + newMemberBinding = Expression.Bind(aProperty, valueExpre); + } + else + { + newMemberBinding = Expression.Bind(typeof(TResult).GetProperty(aProperty.Name), valueExpre); + } + newBindings.Add(newMemberBinding); } - newBindings.Add(newMemberBinding); - } - }); + }); - newBindings.AddRange(oldExpression.Bindings); + newBindings.AddRange(oldExpression.Bindings); - var body = Expression.MemberInit(newBody, newBindings.ToArray()); - var resExpression = Expression.Lambda(body, oldParamters); + var body = Expression.MemberInit(newBody, newBindings.ToArray()); + var resExpression = Expression.Lambda(body, oldParamters); - return resExpression; + return resExpression; + } + catch(Exception ex) + { + return null; + } } #endregion