Exemple #1
0
        public static Order FillOrderInfo(Order _order, MyHLShoppingCart shoppingCart)
        {
            Order_V01 order = _order as Order_V01;

            order.DistributorID = shoppingCart.DistributorID;
            order.Shipment      = GetShippingInfoFromCart(shoppingCart);
            order.InputMethod   = InputMethodType.Internet;
            var recvdDate = DateUtils.GetCurrentLocalTime(shoppingCart.Locale.Substring(3, 2));

            order.ReceivedDate = recvdDate;

            // TODO : Order CATEGORY
            order.OrderCategory =
                (ServiceProvider.OrderSvc.OrderCategoryType)Enum.Parse(typeof(ServiceProvider.OrderSvc.OrderCategoryType), shoppingCart.OrderCategory.ToString());
            //OrderCategoryType.RSO;
            if (order.OrderCategory == ServiceProvider.OrderSvc.OrderCategoryType.ETO)
            {
                if (!String.IsNullOrEmpty(HLConfigManager.Configurations.CheckoutConfiguration.EventTicketOrderType))
                {
                    order.OrderCategory =
                        (ServiceProvider.OrderSvc.OrderCategoryType)
                        Enum.Parse(typeof(ServiceProvider.OrderSvc.OrderCategoryType),
                                   HLConfigManager.Configurations.CheckoutConfiguration.EventTicketOrderType);
                }
            }

            var orderMonth = new OrderMonth(shoppingCart.CountryCode);

            order.OrderMonth = orderMonth.OrderMonthShortString;
            //order.OrderMonth = DateTime.Now.ToString("yyMM");

            order.UseSlidingScale     = HLConfigManager.Configurations.CheckoutConfiguration.UseSlidingScale;
            order.CountryOfProcessing = shoppingCart.CountryCode;

            DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(shoppingCart.DistributorID, shoppingCart.CountryCode);

            if (null != distributorOrderingProfile)
            {
                //order.DiscountPercentage = order.UseSlidingScale && distributorOrderingProfile.StaticDiscount < 50
                //                               ? 0
                //                               : distributorOrderingProfile.StaticDiscount;
                order.DiscountPercentage = distributorOrderingProfile.StaticDiscount;  // always pass profile discount
            }
            if (HLConfigManager.Configurations.DOConfiguration.UsesDiscountRules)
            {
                HLRulesManager.Manager.PerformDiscountRules(shoppingCart, order, shoppingCart.Locale, ShoppingCartRuleReason.CartBeingCalculated);
            }
            if (HLConfigManager.Configurations.DOConfiguration.usesOrderManagementRules)
            {
                HLRulesManager.Manager.PerformOrderManagementRules(shoppingCart, order, shoppingCart.Locale, OrderManagementRuleReason.OrderFilled);
            }

            // some countries, like IT, need OrderSubType for correct Fusion pricing.
            // Added for User Story 226150
            if (HLConfigManager.Configurations.DOConfiguration.SaveDSSubType)
            {
                order.OrderSubType = shoppingCart.SelectedDSSubType;
            }
            return(order);
        }
Exemple #2
0
        /// <summary>
        /// China ShouldShowAPFModule
        /// </summary>
        /// <param name="distributorId"></param>
        /// <returns></returns>
        public static bool ShouldShowAPFModule(string distributorId)
        {
            bool shouldDisplay = false;
            DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(distributorId, "CN");

            try
            {
                if (distributorOrderingProfile != null)
                {
                    if (string.IsNullOrEmpty(distributorOrderingProfile.CNCustCategoryType))
                    {
                        return(false);
                    }
                    if (distributorOrderingProfile.CNCustCategoryType.ToLower() == "psr")
                    {
                        return(false);
                    }
                    //--0(normal DS) 1(overdue within next 3 month) 2(in grace period) 3(has renewed) 4(not DS) 5(overdue)
                    if (distributorOrderingProfile.CNAPFStatus == 2)
                    {
                        return(IsAPFDueAndNotPaid(distributorId));
                    }
                    if (distributorOrderingProfile.CNAPFStatus == 1) // if due in next 3 month, check if paid
                    {
                        DateTime annualProcessingFeeDue = distributorOrderingProfile.ApfDueDate;

                        // APF due
                        var hmsAPFDue = new DateTime(annualProcessingFeeDue.Year,
                                                     annualProcessingFeeDue.Month,
                                                     annualProcessingFeeDue.Day);
                        shouldDisplay = !GetAPFDuePaid(distributorId, annualProcessingFeeDue);
                    }
                    if (distributorOrderingProfile.CNAPFStatus == 0) // if normal, should show APF from Month 1 - Month 12
                    {
                        shouldDisplay = distributorOrderingProfile.ApfDueDate.AddYears(-1) <= DateTime.Today && DateTime.Today <= distributorOrderingProfile.ApfDueDate;
                    }
                }
            }
            catch (Exception ex)
            {
                if (distributorOrderingProfile != null)
                {
                    HL.Common.Logging.LoggerHelper.Error(
                        string.Format(
                            "there is an error in ShouldShowAPFModule DistributorId{0},CNCustCategoryType{1},CNAPFStatus{2},ApfDueDate{3}, error:{4}, stackTrace:{5}",
                            distributorId, distributorOrderingProfile.CNCustCategoryType,
                            distributorOrderingProfile.CNAPFStatus, distributorOrderingProfile.ApfDueDate, ex.Message, ex.StackTrace));
                }
                else
                {
                    HL.Common.Logging.LoggerHelper.Error(
                        string.Format(
                            "there is an error in ShouldShowAPFModule DistributorId{0},isdistributorOrderingProfile Null:{1}",
                            distributorId, "null"));
                }
            }
            return(shouldDisplay);
        }
 /// <summary>
 /// Returns the flag to display the limits based on any country rule.
 /// </summary>
 /// <returns></returns>
 public static bool DisplayLimits(string distributorId, string countryCode)
 {
     if (countryCode.Equals("BA"))
     {
         var tins = DistributorOrderingProfileProvider.GetTinList(distributorId, true);
         return(tins.All(t => t.IDType.Key != "BATX"));
     }
     return(true);
 }
Exemple #4
0
        private bool isPC()
        {
            var member = (MembershipUser <DistributorProfileModel>)Membership.GetUser();

            if (member != null)
            {
                var user = member.Value;
                if (user != null)
                {
                    DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(user.Id, _CountryCode);
                    return(distributorOrderingProfile == null ? false : distributorOrderingProfile.IsPC);
                }
            }
            return(false);
        }
        public bool SetFavouriteSKU(string distributorID, int productID, string productSKU, string locale, int DEL = 0)
        {
            bool result = false;

            try
            {
                return(DistributorOrderingProfileProvider.SetFavouriteSKU(distributorID, productID, productSKU, locale, DEL));
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(
                    string.Format("DistributorOrderingProfileProviderLoader.SetFavouriteSKU error calling service \n{0} \n ERR:{1}",
                                  ex.Message, ex.StackTrace));
                return(result);
            }
        }
        public bool SetFavouriteSKUList(string distributorID, string locale, string SKUList)
        {
            bool result = false;

            try
            {
                return(DistributorOrderingProfileProvider.SetFavouriteSKUList(distributorID, locale, SKUList));
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(
                    string.Format("DistributorOrderingProfileProviderLoader.SetFavouriteSKUList error calling service \n{0} \n ERR:{1}",
                                  ex.Message, ex.StackTrace));
                return(result);
            }
        }
Exemple #7
0
        public static bool IsAPFDueAndNotPaid(string distributorID)
        {
            var isDue = false;

            string level = GetDSLevel();

            if (string.IsNullOrEmpty(level))
            {
                DistributorProfileLoader loader = new DistributorProfileLoader();
                var profile = loader.Load(new GetDistributorProfileById()
                {
                    Id = distributorID
                });
                level = profile.TypeCode;
            }
            if (level == "SP")
            {
                return(isDue);
            }
            DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(distributorID, "CN");

            if (distributorOrderingProfile != null)
            {
                if (distributorOrderingProfile.CNAPFStatus != 1 && distributorOrderingProfile.CNAPFStatus != 2)
                {
                    return(isDue);
                }
                DateTime annualProcessingFeeDue = distributorOrderingProfile.ApfDueDate;

                // APF due
                var hmsAPFDue = new DateTime(annualProcessingFeeDue.Year,
                                             annualProcessingFeeDue.Month,
                                             annualProcessingFeeDue.Day);
                var currentDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                if (hmsAPFDue <= currentDate)
                {
                    isDue = true;
                }

                if (isDue)
                {
                    isDue = !GetAPFDuePaid(distributorID, annualProcessingFeeDue);
                }
            }

            return(isDue);
        }
        public List <FavouriteSKU> GetDistributorFavouriteSKU(string distributorID, string locale)
        {
            List <FavouriteSKU> SKUs = new List <FavouriteSKU>();

            try
            {
                SKUs = DistributorOrderingProfileProvider.GetDistributorFavouriteSKU(distributorID, locale);
                return(SKUs);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(
                    string.Format("DistributorOrderingProfileProviderLoader.GetDistributorFavouriteSKU error calling service \n{0} \n ERR:{1}",
                                  ex.Message, ex.StackTrace));

                return(SKUs);
            }
        }
Exemple #9
0
        public static DateTime GetAPFDueDate(string distributorID, string countryCode)
        {
            DistributorOrderingProfile distributorOrderingProfile = DistributorOrderingProfileProvider.GetProfile(distributorID, countryCode);

            return(distributorOrderingProfile.ApfDueDate);
        }
 public Address_V02 GetAddressV02(AddressType type, string distributorID, string countryCode)
 {
     return(DistributorOrderingProfileProvider.GetAddressV02(type, distributorID, countryCode));
 }
 public bool IsEventQualified(int eventId)
 {
     return(DistributorOrderingProfileProvider.IsEventQualified(eventId, Thread.CurrentThread.CurrentCulture.Name));
 }
 public List <TaxIdentification> GetTinList(string distributorID, bool getCurrentOnly, bool reload = false)
 {
     return(DistributorOrderingProfileProvider.GetTinList(distributorID, getCurrentOnly, reload));
 }
 public DistributorOrderingProfile GetProfile(string distributorID, string countryCode)
 {
     return(DistributorOrderingProfileProvider.GetProfile(distributorID, countryCode));
 }
 public string GetPhoneNumberForCN(string distributorID)
 {
     return(DistributorOrderingProfileProvider.GetPhoneNumberForCN(distributorID));
 }
 public List <EventQualifier_V01> GetEventQualifierList(int eventId)
 {
     return(DistributorOrderingProfileProvider.GetEventQualifierList(eventId));
 }
 public void GetDistributorNotes(DistributorOrderingProfile distributor, string noteType, string noteCode)
 {
     DistributorOrderingProfileProvider.GetDistributorNotes(distributor, noteType, noteCode);
 }
        /// <summary>
        /// The setup customer order data.
        /// </summary>
        /// <param name="customerOrderId">
        /// The customer order id.
        /// </param>
        /// <param name="distributorId"></param>
        /// <param name="countryCode"></param>
        /// <param name="locale"></param>
        /// <param name="isAddressValid"></param>
        /// <param name="customerAddressId"></param>
        public static void SetupCustomerOrderData(string customerOrderId, string distributorId, string countryCode, string locale, out bool isAddressValid, out int customerAddressId)
        {
            isAddressValid = false;
            var customerOrderV01 = CustomerOrderingProvider.GetCustomerOrderByOrderID(customerOrderId);

            // Close all carts for provided Customer Order ID
            if (customerOrderV01.OrderStatus == CustomerOrderStatusType.Cancelled)
            {
                ShoppingCartProvider.DeleteOldShoppingCartForCustomerOrder(
                    distributorId, customerOrderV01.OrderID);
            }

            var  existingCart                  = ShoppingCartProvider.GetShoppingCart(distributorId, locale);
            bool useAddressValidation          = ShippingProvider.GetShippingProvider(customerOrderV01.ProcessingCountry).AddressValidationRequired();
            bool useDsAddressAsShippingAddress = ShippingProvider.GetShippingProvider(customerOrderV01.ProcessingCountry).DSAddressAsShippingAddress();
            var  DShippingAddressForCustomer   = new List <DeliveryOption>();

            if (HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SetDSAddressforCashOnDelivery && customerOrderV01.PaymentMethodChoice == CustomerPaymentMethodChoice.CashOnDelivery) // Mappinf object error CustomerPaymentMethodChoice.CashOnDelivery)
            {
                var dsProfile = DistributorOrderingProfileProvider.GetProfile(distributorId,
                                                                              customerOrderV01.ProcessingCountry);

                var mailingAddress = DistributorOrderingProfileProvider.GetAddress(ServiceProvider.OrderSvc.AddressType.Mailing, distributorId, customerOrderV01.ProcessingCountry);
                if (string.IsNullOrWhiteSpace(mailingAddress.PostalCode) || string.IsNullOrWhiteSpace(mailingAddress.City) || string.IsNullOrWhiteSpace(mailingAddress.Line1) || string.IsNullOrWhiteSpace(mailingAddress.StateProvinceTerritory) || dsProfile.PhoneNumbers == null)
                {
                    HttpContext.Current.Response.Redirect("~/dswebadmin/customerorders.aspx?error=2", false);
                }
                useDsAddressAsShippingAddress = true;
                DShippingAddressForCustomer.Add(

                    new DeliveryOption
                {
                    Address     = ObjectMappingHelper.Instance.GetToShipping(mailingAddress),
                    Id          = -4,
                    AddressId   = new Guid(),
                    AddressType = "Shipping",
                    Alias       = "",
                    AltAreaCode = string.Empty,
                    AltPhone    = string.Empty,
                    AreaCode    = mailingAddress.PostalCode,
                    Recipient   = string.Empty,
                    PostalCode  = mailingAddress.PostalCode,
                    Phone       = dsProfile.PhoneNumbers != null
                                    ? dsProfile.PhoneNumbers.Find(x => x.IsPrimary) != null
                                          ? dsProfile.PhoneNumbers.FirstOrDefault(x => x.IsPrimary).CountryPrefix + dsProfile.PhoneNumbers.FirstOrDefault(x => x.IsPrimary).AreaCode + dsProfile.PhoneNumbers.FirstOrDefault(x => x.IsPrimary).Number
                                          : dsProfile.PhoneNumbers.FirstOrDefault().CountryPrefix + dsProfile.PhoneNumbers.FirstOrDefault().AreaCode + dsProfile.PhoneNumbers.FirstOrDefault().Number
                                    : string.Empty,
                    State       = mailingAddress.StateProvinceTerritory,
                    FreightCode = "NOF",         // DEFAULT FREIGHTCODE TO CALL retrieveFreightCode,
                    Name        = DistributorProfileModel.DistributorName(),
                }
                    );
            }
            int            temporaryEnteredAddressId = 0;
            DeliveryOption option           = null;
            var            custOrderAddress = GetCustomerAddress(customerOrderV01, useAddressValidation);

            if ((custOrderAddress != null) && (!useDsAddressAsShippingAddress))
            {
                ShippingProvider.GetShippingProvider(countryCode).GetShippingAddresses(
                    distributorId, customerOrderV01.ProcessingLocale);
                temporaryEnteredAddressId =
                    ShippingProvider.GetShippingProvider(countryCode).SaveShippingAddress(
                        distributorId, customerOrderV01.ProcessingLocale, custOrderAddress, true, true, false);

                isAddressValid = true;

                // Add address To Temporary Address and Insert customer order cart
                custOrderAddress.ID = temporaryEnteredAddressId;
                option = new DeliveryOption(custOrderAddress);
            }
            else
            {
                ShippingAddress_V02 shippingAddress = null;
                if (useDsAddressAsShippingAddress)
                {
                    List <DeliveryOption> shippingAddresses = DShippingAddressForCustomer.Count > 0 ? DShippingAddressForCustomer:
                                                              ShippingProvider.GetShippingProvider(countryCode).GetShippingAddresses(
                        distributorId, customerOrderV01.ProcessingLocale);
                    if (shippingAddresses != null && shippingAddresses.Count > 0)
                    {
                        if ((shippingAddress = shippingAddresses.Find(s => s.IsPrimary)) == null)
                        {
                            shippingAddress = shippingAddresses.First();
                        }
                    }
                }
                if (shippingAddress != null)
                {
                    ShippingAddress_V02 shippingAddressV2 = null;
                    if (DShippingAddressForCustomer.Count > 0)
                    {
                        shippingAddressV2           = DShippingAddressForCustomer[0];
                        shippingAddressV2.ID        = -4;
                        shippingAddressV2.Recipient = DistributorProfileModel.DistributorName();
                    }

                    option = new DeliveryOption(shippingAddress);
                    temporaryEnteredAddressId = DShippingAddressForCustomer.Count > 0 ?  ShippingProvider.GetShippingProvider(countryCode).SaveShippingAddress(
                        distributorId, customerOrderV01.ProcessingLocale, shippingAddressV2, true, true, false) : shippingAddress.ID;
                    if (DShippingAddressForCustomer.Count > 0)
                    {
                        DShippingAddressForCustomer[0].ID = temporaryEnteredAddressId;
                    }
                }
                else
                {
                    option = new DeliveryOption();
                }
            }

            customerAddressId = temporaryEnteredAddressId;

            if (existingCart != null)
            {
                if (existingCart.DeliveryInfo != null)
                {
                    existingCart.DeliveryInfo.Address.ID = temporaryEnteredAddressId;
                }
                ShoppingCartProvider.UpdateShoppingCart(existingCart);
            }
            else
            {
                var shippingInfo = new Shipping.ShippingInfo(ServiceProvider.ShippingSvc.DeliveryOptionType.Shipping, option);

                MyHLShoppingCart customerCart = ShoppingCartProvider.InsertShoppingCart(
                    distributorId,
                    customerOrderV01.ProcessingLocale,
                    ServiceProvider.CatalogSvc.OrderCategoryType.RSO,
                    shippingInfo,
                    getCustomerOrderDetails(customerOrderV01), false, string.Empty);

                if (customerCart != null)
                {
                    foreach (ShoppingCartItem_V01 item in
                             GetCustomerCartItems(customerCart.ShoppingCartID, customerOrderV01.OrderItems))
                    {
                        ShoppingCartProvider.InsertShoppingCartItem(
                            distributorId, item, customerCart.ShoppingCartID);
                    }

                    // Update Status of Order To In Progress In Azure
                    CustomerOrderingProvider.UpdateCustomerOrderStatus(
                        customerOrderV01.OrderID, customerOrderV01.OrderStatus, CustomerOrderStatusType.InProgress);
                }
                else
                {
                    throw new Exception("Unable to Convert Customer Order To DO Order");
                }
            }
        }
 public DRFraudStatusType CheckForDRFraud(string distributorID, string countryCode, string zipCode)
 {
     return(DistributorOrderingProfileProvider.CheckForDRFraud(distributorID, countryCode, zipCode));
 }