public static OrdersStatViewModel Get(IUnitOfWork db, MarketplaceKeeper marketplaceManager) { var model = new OrdersStatViewModel(); var today = DateHelper.GetAppNowTime().Date; var orders = db.Orders.GetUnshippedOrders(); model.TotalOrdersCount = orders.Count; var marketplaces = marketplaceManager.GetAll(); model.Marketplaces = marketplaces.Select(m => new OrdersByMarketplaceInfo() { Market = m.Market, MarketplaceId = m.MarketplaceId, OrderCount = orders.Count(o => o.Market == m.Market && (o.MarketplaceId == m.MarketplaceId || String.IsNullOrEmpty(m.MarketplaceId))), PaidExpeditedOrderCount = orders.Count(o => o.Market == m.Market && (o.MarketplaceId == m.MarketplaceId || String.IsNullOrEmpty(m.MarketplaceId)) && ShippingUtils.IsServiceExpedited(o.InitialServiceType)), SecondDayOrderCount = orders.Count(o => o.Market == m.Market && (o.MarketplaceId == m.MarketplaceId || String.IsNullOrEmpty(m.MarketplaceId)) && (ShippingUtils.IsServiceTwoDays(o.InitialServiceType) || ShippingUtils.IsServiceNextDay(o.InitialServiceType))), }).ToList(); model.OverdueOrdersCount = orders.Count(o => o.LatestShipDate.HasValue && ShippingUtils.AlignMarketDateByEstDayEnd(o.LatestShipDate.Value, (MarketType)o.Market) < today); return(model); }
public CheckResult Check(DTOOrder order, IList <ListingOrderDTO> orderItems) { if (order.Id == 0) { throw new ArgumentOutOfRangeException("order.Id", "Should be non zero"); } if (order.OrderStatus == OrderStatusEnumEx.Pending) { throw new ArgumentException("order.OrderStatus", "Not supported status Pending"); } CheckResult result = new CheckResult() { IsSuccess = false }; var serviceType = order.InitialServiceType; if (ShippingUtils.IsServiceTwoDays(serviceType) || ShippingUtils.IsServiceNextDay(serviceType)) { result = new CheckResult() { IsSuccess = true }; } return(result); }
public void ProcessResult(CheckResult result, Order dbOrder, DTOOrder order, IList <ListingOrderDTO> orderItems) { if (result.IsSuccess) { _log.Info("Send sign confirmation request order email, orderId=" + order.Id); var alreadySend = _db.OrderEmailNotifies.IsExist(order.OrderId, OrderEmailNotifyType.OutputSignConfirmationEmail); if (alreadySend) { return; } var emailInfo = new SignConfirmationRequestEmailInfo(_emailService.AddressService, null, order.OrderId, (MarketType)order.Market, orderItems, //NOTE: make sense only express or not ShippingUtils.IsServiceNextDay(order.InitialServiceType) ? ShippingTypeCode.PriorityExpress : ShippingTypeCode.Standard, order.BuyerName, order.BuyerEmail); _emailService.SendEmail(emailInfo, CallSource.Service); _db.OrderEmailNotifies.Add(new OrderEmailNotify() { OrderNumber = order.OrderId, Reason = "System emailed, request signconfirmation", Type = (int)OrderEmailNotifyType.OutputSignConfirmationEmail, CreateDate = _time.GetUtcTime(), }); _db.OrderComments.Add(new OrderComment() { OrderId = order.Id, Message = "[System] Sign Confirmation email sent", Type = (int)CommentType.Address, CreateDate = _time.GetAppNowTime(), UpdateDate = _time.GetAppNowTime() }); _db.Commit(); } }
public CheckResult Check(DTOMarketOrder order) { CheckResult result = new CheckResult() { IsSuccess = false }; var serviceType = order.InitialServiceType; if ((ShippingUtils.IsServiceTwoDays(serviceType) || ShippingUtils.IsServiceNextDay(serviceType)) && ShippingUtils.IsInternational(order.ShippingCountry)) { return(new CheckResult() { IsSuccess = true }); } return(result); }
public CheckResult Check(IUnitOfWork db, long orderId, IList <ListingOrderDTO> orderItems, IList <OrderShippingInfoDTO> shippings, DTOMarketOrder marketOrder) { if (!orderItems.Any() || !shippings.Any()) { return new CheckResult() { IsSuccess = false } } ; if (marketOrder.OrderType != (int)OrderTypeEnum.Prime) { return new CheckResult() { IsSuccess = false } } ; var serviceType = marketOrder.InitialServiceType; if (ShippingUtils.IsServiceTwoDays(serviceType) || ShippingUtils.IsServiceNextDay(serviceType)) { return new CheckResult() { IsSuccess = false } } ; if (shippings != null) { //NOTE: send notification when Prime order has only express service optionas (when it is has originally priority service) var activeShipping = shippings.FirstOrDefault(sh => sh.IsActive); if (activeShipping != null && activeShipping.ShippingMethod != null && (activeShipping.ShippingMethod.Id == ShippingUtils.AmazonExpressFlatShippingMethodId || activeShipping.ShippingMethod.Id == ShippingUtils.AmazonExpressRegularShippingMethodId)) { _emailService.SendSystemEmail("Prime order issue #" + marketOrder.OrderId, "Prime order hasn't priority rates", EmailHelper.RafiEmail, EmailHelper.SupportDgtexEmail); _log.Info("Send prime notification email, orderId=" + marketOrder.Id); db.OrderComments.Add(new OrderComment() { OrderId = marketOrder.Id, Message = "[System] Prime order hasn't priority rates", Type = (int)CommentType.OutputEmail, CreateDate = _time.GetAppNowTime(), UpdateDate = _time.GetAppNowTime() }); db.Commit(); return(new CheckResult() { IsSuccess = true }); } } return(new CheckResult() { IsSuccess = false }); } } }