private static Expression <Func <OPC_ShippingSale, bool> > Filter(ShippingOrderFilter filter) { var query = PredicateBuilder.True <OPC_ShippingSale>(); if (filter != null) { if (filter.Status != null) { query = PredicateBuilder.And(query, v => v.ShippingStatus == (int)filter.Status); } if (filter.StoreIds != null) { query = PredicateBuilder.And(query, v => filter.StoreIds.Contains(v.StoreId ?? -1)); } //订单号互斥 时间 if (filter.OrderNo != null) { query = PredicateBuilder.And(query, v => v.OrderNo == filter.OrderNo); return(query); } if (!String.IsNullOrWhiteSpace(filter.ExpressNo)) { query = PredicateBuilder.And(query, v => v.ShippingCode == filter.ExpressNo); return(query); } //发货时间 目前数据库中没这个字段 if (filter.ShipStartDate != null) { query = PredicateBuilder.And(query, v => v.CreateDate >= filter.ShipStartDate); } if (filter.ShipEndDate != null) { query = PredicateBuilder.And(query, v => v.CreateDate < filter.ShipEndDate); } if (!String.IsNullOrWhiteSpace(filter.CustomersPhoneNumber)) { query = PredicateBuilder.And(query, v => v.ShippingContactPhone == filter.CustomersPhoneNumber); } } return(query); }
private static Expression <Func <Order, bool> > Order4Filter(ShippingOrderFilter filter) { var query = PredicateBuilder.True <Order>(); if (filter != null) { if (filter.DateRange != null && String.IsNullOrWhiteSpace(filter.OrderNo)) { if (filter.DateRange.StartDateTime != null) { query = PredicateBuilder.And(query, v => v.CreateDate >= (filter.DateRange.StartDateTime)); } if (filter.DateRange.EndDateTime != null) { query = PredicateBuilder.And(query, v => v.CreateDate < (filter.DateRange.EndDateTime)); } } } return(query); }
public List <ShippingOrderModel> GetPagedList(PagerRequest pagerRequest, out int totalCount, ShippingOrderFilter filter, ShippingOrderSortOrder sortOrder) { return(_shippingOrderRepository.GetPagedList(pagerRequest, out totalCount, filter, sortOrder)); }
public List <ShippingOrderModel> GetPagedList(PagerRequest pagerRequest, out int totalCount, ShippingOrderFilter filter, ShippingOrderSortOrder sortOrder) { var shippingOrderFilter = Filter(filter); var orderFilter = Order4Filter(filter); var rst = Func(db => { var shippingOrders = db.Set <OPC_ShippingSale>(); var orders = db.Set <Order>(); var salesOrders = db.Set <OPC_Sale>(); var stores = db.Set <Store>(); var q1 = from ss in shippingOrders.AsExpandable().Where(shippingOrderFilter) from o in orders.AsExpandable().Where(orderFilter) from sale in salesOrders join store in stores on ss.StoreId equals store.Id where ss.Id == sale.ShippingSaleId && o.OrderNo == ss.OrderNo select new { Order = o, ShippingSale = ss, SaleOrders = sale, Store = store }; var t = q1.Count(); var q = q1.OrderByDescending(v => v.ShippingSale.CreateDate) .Skip(pagerRequest.SkipCount) .Take(pagerRequest.PageSize).Select(v => new ShippingOrderModel { Id = v.ShippingSale.Id, CustomerAddress = v.ShippingSale.ShippingAddress, CustomerName = v.ShippingSale.ShippingContactPerson, CustomerPhone = v.ShippingSale.ShippingContactPhone, ExpressCode = v.ShippingSale.ShippingCode, ExpressFee = v.ShippingSale.ShippingFee ?? 0, GoodsOutCode = String.Empty, GoodsOutDate = v.ShippingSale.CreateDate, GoodsOutType = String.Empty, //v.ShippingSale. OrderNo = v.ShippingSale.OrderNo, PrintTimes = v.ShippingSale.PrintTimes, RmaNo = v.ShippingSale.RmaNo, SaleOrderNo = v.SaleOrders.SaleOrderNo, ShipCompanyName = v.ShippingSale.ShipViaName, ShipManName = String.Empty, ShippingMethod = String.Empty, ShippingStatus = v.ShippingSale.ShippingStatus, ShippingZipCode = v.ShippingSale.ShippingZipCode, ShipViaExpressFee = v.ShippingSale.ShippingFee ?? 0, ShipViaId = v.ShippingSale.ShipViaId, RMAAddress = v.Store.RMAAddress, RMAPerson = v.Store.RMAPerson, RMAPhone = v.Store.RMAPhone, RMAZipCode = v.Store.RMAZipCode }).ToList(); return(new { total = t, data = q }); }); totalCount = rst.total; return(rst.data); }