示例#1
0
        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 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(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
            });
        }
    }
}