public IList <DeliveryOrPickupOption> GetDeliveryOptions(DateTime dtStart, int nextDays, string area, int?distanceInMeters = null, decimal?orderAmount = null) { if (nextDays < 0 || nextDays > Setting.MaxAdvancedOrderDays) { //stall advanced order days nextDays = Setting.MaxAdvancedOrderDays; } var options = Setting.Delivery.GetOptions(dtStart, nextDays, Setting.OpeningHours); var result = new List <DeliveryOrPickupOption>(); foreach (var opt in options) { if (!Models.Area.IsApplicable(opt.Areas, area)) { continue; } var newOpt = DeliveryOrPickupOption.Parse(opt); newOpt.IsStoreDelivery = true; newOpt.Fee = opt.Calculator.Calculate(opt.From, area, distanceInMeters, orderAmount); if (newOpt.Fee != null) { result.Add(newOpt); } } return(result.Where(x => x.ReferenceTimePonit > dtStart).OrderBy(x => x.From).ToList()); }
private IList <DeliveryOrPickupOption> DivideOverNight(DeliveryOrPickupOption option) { var result = new List <DeliveryOrPickupOption>(); //overnight while (option.From.Date < option.To.Date) { var newTo = new DateTime(option.From.Year, option.From.Month, option.From.Day, 0, 0, 0).AddDays(1); var newOpt = new DeliveryOrPickupOption() { From = option.From, To = newTo, ReferenceTimePonit = ReferenceTimePonit, DivisionType = option.DivisionType, Areas = option.Areas, IsPickUp = option.IsPickUp, PickUpAddress = PickUpAddress, IsStoreDelivery = IsStoreDelivery, Fee = option.Fee }; result.Add(newOpt); option.From = newTo; } ; if (option.From != option.To) { result.Add(option); } return(result); }
public IList <DeliveryOrPickupOption> GetPickupOptions(DateTime dtStart, int nextDays) { if (nextDays < 0 || nextDays > Setting.MaxAdvancedOrderDays) { //stall advanced order days nextDays = Setting.MaxAdvancedOrderDays; } var options = Setting.Pickup.GetOptions(dtStart, nextDays, Setting.OpeningHours); var result = new List <DeliveryOrPickupOption>(); foreach (var opt in options) { var newOpt = DeliveryOrPickupOption.Parse(opt); //delivery fee is 0 newOpt.Fee = 0; result.Add(newOpt); } return(result.Where(x => x.ReferenceTimePonit > dtStart).OrderBy(x => x.PickUpAddress).ThenBy(x => x.From).ToList()); }