/// <summary> /// Gets the order. /// </summary> /// <param name="locale">The locale.</param> /// <param name="distributorID">The distributor ID.</param> /// <param name="shoppingCart">The shopping cart.</param> /// <returns></returns> public static Order_V01 GetOrder(string locale, string distributorID, MyHLShoppingCart shoppingCart) { var order = (Order_V01)OrderCreationHelper.CreateOrderObject(shoppingCart); OrderCreationHelper.FillOrderInfo(order, shoppingCart); return(order); }
protected void btnSubmit_Click(object sender, EventArgs e) { if (ShoppingCart != null) { ShoppingCart.CheckAPFShipping(); // Set the order var order = OrderCreationHelper.CreateOrderObject(ShoppingCart) as Order_V01; order.DistributorID = DistributorID; order.CountryOfProcessing = CountryCode; order.ReceivedDate = DateUtils.GetCurrentLocalTime(CountryCode); order.OrderMonth = GetOrderMonthShortString(); order.OrderCategory = (CountryCode == "GR") ? OrderCategoryType.APF : OrderCategoryType.RSO; //** RSO is just for testing (using other countries) and will always be APF order.Shipment = OrderProvider.CreateShippingInfo(CountryCode, ShoppingCart); order.Handling = OrderProvider.CreateHandlingInfo(CountryCode, string.Empty, ShoppingCart, order.Shipment as ShippingInfo_V01); List <Payment> payments = null; if (PaymentOptions != null) { if (PaymentOptions.ValidateAndGetPayments(ObjectMappingHelper.Instance.GetToOrder(ShoppingCart.DeliveryInfo.Address.Address), out payments)) { if (payments != null && payments.Count > 0) { order.Payments = new PaymentCollection(); order.Payments.AddRange((from p in payments select p).ToArray()); } order = OrderProvider.PopulateLineItems(CountryCode, order, ShoppingCart) as Order_V01; order.DiscountPercentage = (ShoppingCart.Totals as OrderTotals_V01).DiscountPercentage; var theOrder = OrderProvider.CreateOrder(order, ShoppingCart, CountryCode); List <FailedCardInfo> failedCards = null; string error = string.Empty; string orderID = OrderProvider.ImportOrder(theOrder, out error, out failedCards, ShoppingCart.ShoppingCartID); if (string.IsNullOrEmpty(error)) { // TODO: how to get auth token ShoppingCartProvider.UpdateShoppingCart(ShoppingCart, OrderProvider.SerializeOrder(theOrder, order, ShoppingCart, new Guid()), orderID, order.ReceivedDate); if (string.IsNullOrEmpty(order.OrderID)) { order.OrderID = orderID; order.Pricing = ShoppingCart.Totals; } if (!String.IsNullOrEmpty(ShoppingCart.EmailAddress)) { EmailHelper.SendEmail(ShoppingCart, order); } onHFFOrderPlaced(this, new EventArgs()); } } } } }
/// <summary> /// Gets the order. /// </summary> /// <param name="locale">The locale.</param> /// <param name="distributorID">The distributor ID.</param> /// <returns></returns> public static Order_V01 GetOrder(string locale, string distributorID) { var shoppingCart = MyHLShoppingCartGenerator.GetBasicShoppingCart(distributorID, locale); var order = (Order_V01)OrderCreationHelper.CreateOrderObject(shoppingCart); OrderCreationHelper.FillOrderInfo(order, shoppingCart); return(order); }
/// <summary> /// get inventory for china store /// </summary> /// <param name="storeID"></param> /// <returns></returns> public static Inventory_V01 GetInventory(string storeID) { string cachekey = string.Format("{0}{1}", INVENTORY_CACHE_PREFIX, storeID); CatalogInterfaceClient proxy = null; using (proxy = ServiceClientProvider.GetCatalogServiceProxy()) { try { var response = proxy.GetInventory(new GetInventoryRequest1(new GetInventoryRequest_V01 { CountryCode = "CN", StoreID = storeID })).GetInventoryResult as GetInventoryResponse_V01; // Check response for error. if (response == null || response.Status != ServiceResponseStatusType.Success || response.Inventory == null) { throw new ApplicationException( "CatalogProvider.GetInventory error. GetInventoryResponse indicates error. storeID : " + storeID); } HttpRuntime.Cache.Insert(cachekey, response.Inventory, null, DateTime.Now.AddMinutes(INVENTORY_CACHE_MINUTES), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null); if (Settings.GetRequiredAppSetting("LogCatalogCN", "false").ToLower() == "true") { LogRequest(string.Format("Store ID: {0}", storeID)); LogRequest(string.Format("GetInventory service response: {0}", OrderCreationHelper.Serialize(response.Inventory))); } return(response.Inventory); } catch (Exception ex) { LoggerHelper.Error( string.Format("ChinaGetInventory error, storeID: {0} {1}", storeID, ex)); } } return(null); }
protected void btnSubmit_Click(object sender, EventArgs e) { var _errors = new List <string>(); if (ShoppingCart != null) { if (ShoppingCart.Totals == null) { ShoppingCart.Calculate(); } // Set the order var order = OrderCreationHelper.CreateOrderObject(ShoppingCart) as Order_V01; order.DistributorID = DistributorID; order.CountryOfProcessing = CountryCode; order.ReceivedDate = DateUtils.GetCurrentLocalTime(CountryCode); order.OrderMonth = GetOrderMonthShortString(); order.OrderCategory = (OrderCategoryType) Enum.Parse(typeof(OrderCategoryType), HLConfigManager.Configurations.DOConfiguration.HFFModalOrderType); order.Shipment = OrderProvider.CreateShippingInfo(CountryCode, ShoppingCart); var provider = (Page as ProductsBase).GetShippingProvider(); (order.Shipment as ShippingInfo_V01).Address = ObjectMappingHelper.Instance.GetToOrder(provider.GetHFFDefaultAddress(ShoppingCart.DeliveryInfo.Address)); order.Handling = OrderProvider.CreateHandlingInfo(CountryCode, string.Empty, ShoppingCart, order.Shipment as ShippingInfo_V01); List <Payment> payments = null; if (PaymentOptions != null) { if (PaymentOptions.ValidateAndGetPayments(ObjectMappingHelper.Instance.GetToOrder(ShoppingCart.DeliveryInfo.Address.Address), out payments)) { if (payments != null && payments.Count > 0) { order.Payments = new PaymentCollection(); order.Payments.AddRange((from p in payments select p).ToArray()); } HLRulesManager.Manager.PerformTaxationRules(order, (Page as ProductsBase).Locale); if (PurchasingLimitProvider.RequirePurchasingLimits(DistributorID, CountryCode)) { if (order.PurchasingLimits == null) { var limits = PurchasingLimitProvider.GetCurrentPurchasingLimits(DistributorID); if (null != limits) { limits.PurchaseSubType = ShoppingCart.SelectedDSSubType; order.PurchasingLimits = limits; order.PurchaseCategory = limits.PurchaseType; } } } order = OrderProvider.PopulateLineItems(CountryCode, order, ShoppingCart) as Order_V01; order.DiscountPercentage = (ShoppingCart.Totals as OrderTotals_V01).DiscountPercentage; var theOrder = OrderProvider.CreateOrder(order, ShoppingCart, CountryCode); List <FailedCardInfo> failedCards = null; string error = string.Empty; string orderID = OrderProvider.ImportOrder(theOrder, out error, out failedCards, ShoppingCart.ShoppingCartID); if (string.IsNullOrEmpty(error)) { // TODO: how to get auth token ShoppingCartProvider.UpdateShoppingCart(ShoppingCart, OrderProvider.SerializeOrder(theOrder, order, ShoppingCart, new Guid()), orderID, order.ReceivedDate); if (string.IsNullOrEmpty(order.OrderID)) { order.OrderID = orderID; order.Pricing = ShoppingCart.Totals; } if (!String.IsNullOrEmpty(ShoppingCart.EmailAddress)) { EmailHelper.SendEmail(ShoppingCart, order); } OrderSubmitted(order, orderID); // Handling UI lbOrderNumValue.Text = orderID; divPayment.Attributes.Add("class", string.Format("{0} hide", divSubmitCommand.Attributes["class"])); divPaymentSummary.Attributes["class"] = divEmailNotification.Attributes["class"].Replace("hide", string.Empty); //hide the PaymentSummary if the Payment choice for HFF Order is Wire if (SessionInfo.SelectedPaymentChoice == "WireTransfer") { divPaymentSummary.Attributes["class"] = "hide"; } else { divPaymentSummary.Attributes["class"] = divEmailNotification.Attributes["class"].Replace("hide", string.Empty); } divOrderComplete.Attributes["class"] = divOrderComplete.Attributes["class"].Replace("hide", string .Empty); divEmailNotification.Attributes["class"] = divEmailNotification.Attributes["class"].Replace("hide", string.Empty); divSubmitCommand.Attributes.Add("class", string.Format("{0} hide", divSubmitCommand.Attributes["class"])); divEndCommand.Attributes["class"] = divEndCommand.Attributes["class"].Replace("hide", string.Empty); if (PurchasingLimitProvider.RequirePurchasingLimits(DistributorID, CountryCode)) { PurchasingLimitProvider.ReconcileAfterPurchase(ShoppingCart, DistributorID, CountryCode); } var currentSession = SessionInfo.GetSessionInfo(DistributorID, Locale); if (currentSession != null) { if (!String.IsNullOrEmpty(currentSession.OrderNumber)) { currentSession.OrderNumber = String.Empty; currentSession.OrderMonthShortString = string.Empty; currentSession.OrderMonthString = string.Empty; currentSession.ShippingMethodNameMX = String.Empty; currentSession.ShippingMethodNameUSCA = String.Empty; currentSession.ShoppingCart.CustomerOrderDetail = null; // currentSession.CustomerPaymentSettlementApproved = false; Commented out for Merge. Need to investigate currentSession.CustomerOrderNumber = String.Empty; currentSession.CustomerAddressID = 0; if (null != currentSession.ShippingAddresses) { var customerAddress = currentSession.ShippingAddresses.Find( p => p.ID == currentSession.CustomerAddressID); if (customerAddress != null) { currentSession.ShippingAddresses.Remove(customerAddress); } } } } //Clear the order month session... Session["OrderMonthDataSessionKey"] = null; SessionInfo.SetSessionInfo(DistributorID, Locale, currentSession); if (ShoppingCart != null) { // take out quantities from inventory ShoppingCartProvider.UpdateInventory(ShoppingCart, CountryCode, Locale, true); } ShoppingCart.CloseCart(); RecoverActiveCart(); onHFFOrderPlaced(this, new EventArgs()); } else { LoggerHelper.Error(error); if (error.Contains("AUTHORIZE PAYMENT")) { _errors.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "PaymenyFail")); } else if (error.Contains("TIMEOUT")) { _errors.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "Resubmit")); } else if (error.Contains("ORDER CANNOT BE FULFILLED FOR THE DISTRIBUTOR")) { _errors.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "CantOrder")); } else { _errors.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "TransactionFail")); } } } } } }
public FreightSimulationResult CalculateFreight(ServiceProvider.OrderChinaSvc.ShippingInfo_V01 shippingInfo, decimal weight) { var freightSimulationResult = new FreightSimulationResult(); if (shippingInfo == null || shippingInfo.Address == null || weight == 0) { return(freightSimulationResult); } if (Settings.GetRequiredAppSetting("LogShipping", "false").ToLower() == "true") { LogRequest(string.Format("ShippingInfo before CalculateFreight: {0}", OrderCreationHelper.Serialize(shippingInfo))); } if (!string.IsNullOrEmpty(shippingInfo.Address.StateProvinceTerritory) && !string.IsNullOrEmpty(shippingInfo.Address.City) && !string.IsNullOrEmpty(shippingInfo.Address.CountyDistrict)) { if (string.IsNullOrEmpty(shippingInfo.ShippingMethodID)) { var mappings = GetProvinceStoreMapping(); if (mappings != null) { var mapping = mappings.Find(m => m.ProvinceName == shippingInfo.Address.StateProvinceTerritory); if (mapping != null) { shippingInfo.ShippingMethodID = mapping.StoreID.ToString(); } } } if (string.IsNullOrEmpty(shippingInfo.WarehouseCode)) { shippingInfo.WarehouseCode = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultFreightCode; } var proxy = ServiceClientProvider.GetChinaOrderServiceProxy(); var result = proxy.GetFreightCharge(new ServiceProvider.OrderChinaSvc.GetFreightChargeRequest1(new ServiceProvider.OrderChinaSvc.GetFreightChargeRequest_V01() { ShippingInfo = shippingInfo, Weight = weight })).GetFreightChargeResult as ServiceProvider.OrderChinaSvc.GetFreightChargeResponse_V01; if (result != null && result.Status == ServiceProvider.OrderChinaSvc.ServiceResponseStatusType.Success) { freightSimulationResult.EstimatedFreight = result.Freight; freightSimulationResult.StoreName = result.StoreName; } } if (Settings.GetRequiredAppSetting("LogShipping", "false").ToLower() == "true") { LogRequest(string.Format("ShippingInfo after CalculateFreight: {0}", OrderCreationHelper.Serialize(shippingInfo))); } return(freightSimulationResult); }
public override ShippingInfo GetShippingInfoFromID(string distributorID, string locale, DeliveryOptionType type, int deliveryOptionID, int shippingAddressID) { if (type == DeliveryOptionType.Shipping) { var shippingAddresses = GetDSShippingAddresses(distributorID, locale); ShippingAddress_V02 shippingAddress = shippingAddresses.Find(s => s.ID == shippingAddressID); DeliveryOption deliveryOption = null; var freightCodeAndWarehouse = GetFreightCodeAndWarehouseFromAddress(shippingAddress, null); if (freightCodeAndWarehouse != null) { deliveryOption = new DeliveryOption(freightCodeAndWarehouse[1], freightCodeAndWarehouse[0], DeliveryOptionType.Shipping, string.Empty); } if (deliveryOption == null || shippingAddress == null) { return(null); } ShippingInfo shippingInfo = new ShippingInfo(deliveryOption, shippingAddress); shippingInfo.AddressType = "EXP"; // this is address type for shipping if (Settings.GetRequiredAppSetting("LogShipping", "false").ToLower() == "true") { LogRequest(string.Format("GetShippingInfoFromID for shipping option: {0}", OrderCreationHelper.Serialize(shippingInfo))); } return(shippingInfo); } else if (type == DeliveryOptionType.Pickup) { ShippingInfo shippingInfo = base.GetShippingInfoFromID(distributorID, locale, type, deliveryOptionID, shippingAddressID); if (shippingInfo != null) { shippingInfo.FreightCode = "0"; shippingInfo.AddressType = "SD"; // this is address type for pickup } //Stores Pickup Location phone in session and sets shippingInfo phone to DS phone //var sessionInfo = SessionInfo.GetSessionInfo(distributorID, locale); //sessionInfo.SelectedPickupLocationPhone = shippingInfo.Address.Phone; //shippingInfo.Address.Phone = String.Empty; return(shippingInfo); } if (type == DeliveryOptionType.PickupFromCourier) { string countryCode = locale.Substring(3, 2); var pickupLocationPreference = GetPickupLocationsPreferences(distributorID, countryCode); if (pickupLocationPreference != null && pickupLocationPreference.Count > 0) { var vPickupLocation = pickupLocationPreference.Find(p => p.ID == deliveryOptionID); if (vPickupLocation != null) { int pickupLocationID = vPickupLocation.PickupLocationID; var doList = GetDeliveryOptions(type, new ShippingAddress_V01 { Address = new Address_V01 { Country = "CN" } }); if (doList != null) { var deliveryOption = doList.Find(d => d.Id == pickupLocationID); if (deliveryOption != null) { var shippingInfo = new ShippingInfo(deliveryOption); shippingInfo.Id = deliveryOptionID; // this is ID field from PickUpStore shippingInfo.AddressType = "PUC" + deliveryOption.AddressType; return(shippingInfo); } } } } } return(null); }