Esempio n. 1
0
        private List <MyHLShoppingCartView> GetOrdersByOrderNumber(string memberId, string locale, string orderNumber,
                                                                   DateTime startDate, DateTime endDate)
        {
            var shoppingCartViews = new List <MyHLShoppingCartView>();

            if (!string.IsNullOrEmpty(orderNumber))
            {
                var customerProfileId =
                    DistributorOrderingProfileProvider.GetProfile(memberId, locale.Substring(3, 2)).CNCustomorProfileID;
                var shoppingCartView = new MyHLShoppingCartView();

                var proposedStartDate = DateTime.Now.AddMonths(-12);
                //DateTime startDate = new DateTime(proposedStartDate.Year, proposedStartDate.Month, proposedStartDate.Day); //ensure the time is the start of the day, which is 00:00:00
                //DateTime endDate = DateTime.Now;

                shoppingCartViews = shoppingCartView.GetOrdersWithDetail(memberId, customerProfileId, locale, startDate,
                                                                         endDate, OrderStatusFilterType.All, "", "", false, false, orderNumber);

                if (shoppingCartViews.Count > 0)
                {
                    return(shoppingCartViews.FindAll(oi => oi.OrderNumber == orderNumber));
                }
            }

            return(shoppingCartViews);
        }
Esempio n. 2
0
        private List <MyHLShoppingCartView> GetOrderList(string memberId, string locale, DateTime?from, DateTime?to,
                                                         bool check3Months = false)
        {
            var shoppingCartView  = new MyHLShoppingCartView();
            var customerProfileId =
                DistributorOrderingProfileProvider.GetProfile(memberId, locale.Substring(3, 2)).CNCustomorProfileID;
            var filterExpressions = string.Empty;
            var sortExpressions   = string.Empty;
            var countryCode       = locale.Substring(3, 2);
            var localNow          = DateUtils.GetCurrentLocalTime(countryCode);

            if (check3Months)
            {
                from = localNow.AddMonths(-3);
                to   = localNow;
            }
            else
            {
                if (!from.HasValue)
                {
                    if (to.HasValue)
                    {
                        from = to.Value.AddMonths(-3);
                    }
                    else
                    {
                        from = localNow.AddMonths(-3);
                    }
                }

                if (!to.HasValue)
                {
                    if (from.HasValue)
                    {
                        to = from.Value.AddMonths(3);
                    }
                    else
                    {
                        to = localNow;
                    }
                }
            }

            var result = shoppingCartView.GetOrdersWithDetail(memberId, customerProfileId, locale, from.Value, to.Value,
                                                              OrderStatusFilterType.All, "", "");

            return(result);
        }
Esempio n. 3
0
        public List <OrderViewModel> GetOrders(OrderSearchParameter request)
        {
            List <OrderViewModel> result = null;

            #region validation

            if (string.IsNullOrWhiteSpace(request.Locale) || string.IsNullOrWhiteSpace(request.MemberId))
            {
                return(result);
            }

            #endregion

            var countryCode = request.Locale.Substring(3, 2);
            var localNow    = DateUtils.GetCurrentLocalTime(countryCode);

            var defaultStartDate = localNow.AddMonths(-12);
            var defaultEndDate   = localNow;

            DateTime startDate = request.From ?? defaultStartDate;
            DateTime endDate   = request.To ?? defaultEndDate;

            if (!string.IsNullOrEmpty(request.OrderNumber))
            {
                var orderViewmodelsByOrderNumber = new List <OrderViewModel>();
                var orders = GetOrdersByOrderNumber(request.MemberId, request.Locale, request.OrderNumber, startDate,
                                                    endDate);
                var addressGuid = Guid.Empty;
                var country     = string.Empty;
                if (null != orders && orders.Any())
                {
                    if (orders.Count == 1)
                    {
                        var mobileQuoteHelper = new MobileQuoteHelper();
                        var shoppingCart      = mobileQuoteHelper.GetShoppingCart(request.OrderNumber, Guid.Empty);
                        if (null != shoppingCart && shoppingCart.DeliveryOption == DeliveryOptionType.Shipping)
                        {
                            var addressId = shoppingCart.ShippingAddressID;
                            if (addressId > 0)
                            {
                                var shippingProvider =
                                    ShippingProvider.GetShippingProvider(countryCode);
                                if (null != shippingProvider)
                                {
                                    var address = shippingProvider.GetShippingAddressFromAddressGuidOrId(Guid.Empty,
                                                                                                         addressId);
                                    addressGuid = null != address ? address.AddressId : Guid.Empty;
                                    country     = null != address && null != address.Address
                                        ? address.Address.Country
                                        : string.Empty;
                                }
                            }
                        }
                    }
                    orderViewmodelsByOrderNumber.AddRange(
                        orders.Select(
                            item => ModelConverter.ConvertShoppingCartViewToOrderViewModel(item, request.Locale)));
                    if (addressGuid != Guid.Empty && null != orderViewmodelsByOrderNumber &&
                        orderViewmodelsByOrderNumber.Any() && orderViewmodelsByOrderNumber.Count == 1 &&
                        null != orderViewmodelsByOrderNumber[0].Shipping &&
                        null != orderViewmodelsByOrderNumber[0].Shipping.Address)
                    {
                        orderViewmodelsByOrderNumber[0].Shipping.Address.CloudId = addressGuid;
                        orderViewmodelsByOrderNumber[0].Shipping.Address.Country = country;
                        if (request.Locale == "zh-CN")
                        {
                            orderViewmodelsByOrderNumber[0].Shipping.FreightVariant =
                                GetFreightVariant(orderViewmodelsByOrderNumber[0].Shipping.DeliveryType);
                        }
                    }
                }
                return(orderViewmodelsByOrderNumber);
            }
            List <MyHLShoppingCartView> orderList;
            var shoppingCartView  = new MyHLShoppingCartView();
            var customerProfileId =
                DistributorOrderingProfileProvider.GetProfile(request.MemberId, countryCode).CNCustomorProfileID;

            //var proposedStartDate = DateTime.Now.AddMonths(-6);
            //DateTime startDate = new DateTime(proposedStartDate.Year, proposedStartDate.Month, proposedStartDate.Day); //ensure the time is the start of the day, which is 00:00:00
            //DateTime endDate = DateTime.Now;

            orderList = shoppingCartView.GetOrdersWithDetail(request.MemberId, customerProfileId, request.Locale,
                                                             startDate, endDate, OrderStatusFilterType.All, "", "");

            if (orderList != null)
            {
                if (request.PageSize > 0 && orderList.Any())
                {
                    var paged = orderList.Skip((request.PageNumber) * request.PageSize).Take(request.PageSize);
                    if (null != paged && paged.Any())
                    {
                        orderList = paged.ToList();
                    }
                    else
                    {
                        orderList = new List <MyHLShoppingCartView>();
                    }
                }

                result = new List <OrderViewModel>();

                foreach (var itm in orderList)
                {
                    var newItem = ModelConverter.ConvertShoppingCartViewToOrderViewModel(itm, request.Locale);
                    result.Add(newItem);
                }
            }

            return(result);
        }