fix 优化查询

This commit is contained in:
2024-03-25 10:16:23 +08:00
parent 287c844d05
commit af9c5a5749
3 changed files with 10 additions and 3 deletions

View File

@@ -16,8 +16,8 @@ public class OrderBookingPageRequest : PageDto
/// <summary>
/// 支付方式
/// </summary>
[EnumDataType(typeof(CanteenBusinessPlaceSourceEnumType))]
public CanteenBusinessPlaceSourceEnumType? Source { get; set; }
[EnumDataType(typeof(BalanceRecordSourceEnumType))]
public BalanceRecordSourceEnumType? Source { get; set; }
/// <summary>
/// 订餐日期区间

View File

@@ -34,6 +34,11 @@ public class OrderBookingResponse
/// 用户
/// </summary>
public string UserName { get; set; }
/// <summary>
/// 部门名称
/// </summary>
public string DepartmentName { get; set; }
/// <summary>
/// 餐次

View File

@@ -176,6 +176,7 @@ public class BookingOrderService : BaseOrderService, IBookingOrderService
var page = await DbContext.Queryable<CanteenOrderEntity>()
.LeftJoin<GainfoEntity>((x, ga) => x.UserNo == ga.No)
.LeftJoin<DepartmentEntity>((x, ga, dept) => dept.No == ga.DepartmentNo)
.Where(x => myCodes.Contains(x.BusinessPlaceCode))
.WhereIF(request.OrderStatus.HasValue, x => x.OrderStatus == request.OrderStatus)
.WhereIF(request.Search.IsPresent(), (x, ga) => x.UserCode == request.Search || ga.Name.Contains(request.Search))
@@ -187,7 +188,7 @@ public class BookingOrderService : BaseOrderService, IBookingOrderService
.Any()
)
.WhereIF(request.ShiftTpe.HasValue, x => x.ShiftType == request.ShiftTpe)
.Select((x, ga) => new OrderBookingResponse
.Select((x, ga, dept) => new OrderBookingResponse
{
No = x.No,
DeliveryAddress = x.DeliveryAddress,
@@ -199,6 +200,7 @@ public class BookingOrderService : BaseOrderService, IBookingOrderService
UserCode = x.UserCode,
UserName = ga.Name,
Source = x.Source,
DepartmentName = dept.Name
})
.ToPageListAsync(request);