Beispiel #1
0
        public bool IsAccept(OrderToTrackDTO orderToTrackInfo,
                             string status,
                             DateTime?statusDate,
                             IList <TrackingRecord> records)
        {
            var today = _time.GetAppNowTime().Date;

            if (orderToTrackInfo.LabelCanceled == true ||
                orderToTrackInfo.CancelLabelRequested == true)
            {
                return(false);
            }

            //почта после 60 дней за них не отвечает
            //старше 55 дней
            if (statusDate.HasValue &&
                statusDate.Value.AddDays(55) < today)
            {
                return(false);
            }

            if (orderToTrackInfo.LabelCanceled)
            {
                return(false);
            }

            if (orderToTrackInfo.ActualDeliveryDate.HasValue)
            {
                return(false);
            }

            if (status.IndexOf("Pre-Shipment Info Sent to USPS", StringComparison.InvariantCultureIgnoreCase) > 0)
            {
                return(false);
            }

            if (statusDate.HasValue && orderToTrackInfo.ShippingMethodId.HasValue)
            {
                var isInternational = ShippingUtils.IsInternationalShippingType(orderToTrackInfo.ShippingMethodId.Value);
                if (!isInternational)
                {
                    var shippingType = ShippingUtils.GetShippingType(orderToTrackInfo.ShippingMethodId.Value);

                    var periodDays = 4;
                    switch (shippingType)
                    {
                    case ShippingTypeCode.Standard:
                        periodDays = 4;
                        break;

                    case ShippingTypeCode.Priority:
                        periodDays = 2;
                        break;

                    case ShippingTypeCode.PriorityExpress:
                        periodDays = 1;
                        break;

                    case ShippingTypeCode.SameDay:
                        periodDays = 1;     //TODO: 0.5
                        break;
                    }

                    var dayCount = _time.GetBizDaysCount(statusDate.Value, today);
                    if (dayCount > periodDays)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }