protected override void SetOrderInternal(ShoppingCartInfo cartObj, bool generateInvoice)
    {
        // Create an order from the shopping cart data
        base.SetOrderInternal(cartObj, generateInvoice);

        // Init event attendees from the shopping cart data
        CustomEventHelper.SetAttendees(cartObj);
    }
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get order id
        orderId = QueryHelper.GetInteger("orderid", 0);

        if (!RequestHelper.IsPostBack())
        {
            if (!QueryHelper.GetBoolean("cartexist", false))
            {
                ShoppingCart = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderId);
            }
        }

        if (orderId > 0)
        {
            if (ShoppingCart == null)
            {
                RedirectToInformation("editedobject.notexists");
            }

            if (ShoppingCart.Order != null)
            {
                // Check order site ID
                CheckEditedObjectSiteID(ShoppingCart.Order.OrderSiteID);
            }

            Cart.LocalShoppingCart = ShoppingCart;
            Cart.EnableProductPriceDetail = true;
            Cart.ShoppingCartInfoObj.IsCreatedFromOrder = true;
            Cart.CheckoutProcessType = CheckoutProcessEnum.CMSDeskOrderItems;
            Cart.OnPaymentCompleted += Cart_OnPaymentCompleted;
            Cart.OnPaymentSkipped += Cart_OnPaymentSkipped;
            Cart.OnCheckPermissions += Cart_OnCheckPermissions;
            Cart.RequiredFieldsMark = CMS.EcommerceProvider.ShoppingCart.DEFAULT_REQUIRED_FIELDS_MARK;
        }

        if (!RequestHelper.IsPostBack())
        {
            // Display 'Changes saved' message
            if (QueryHelper.GetBoolean("saved", false))
            {
                // Show message
                ShowChangesSaved();
            }
            // Display 'Payment completed' message
            else if (QueryHelper.GetBoolean("paymentcompleted", false))
            {
                ShowInformation(GetString("PaymentGateway.CMSDeskOrderItems.PaymentCompleted"));
            }
        }
    }
    /// <summary>
    /// Ensures that the shipping option is applicable only if user is not purchasing one fo the excluded products
    /// </summary>
    /// <param name="cart">Shopping cart data.</param>
    /// <param name="shippingOption">Shipping option which is being checked for applicability.</param>
    /// <returns>True if the shipping option is allowed to be applied for the current cart items, otherwise returns false.</returns>
    protected override bool IsShippingOptionApplicableInternal(ShoppingCartInfo cart, ShippingOptionInfo shippingOption)
    {
        bool blnOptionAllowed = true;

        try
        {
            // Does not check availability if shopping cart or shipping option object is not available
            if ((cart == null) || (shippingOption == null))
            {
                return true;
            }

            // Gets data for the ShippingOptionExcludedProducts field
            var shippingOptionExcludedProducts = shippingOption.GetValue("ShippingOptionExcludedProducts");

            // Does not check availability if no products were permitted
            if (shippingOptionExcludedProducts == null)
            {
                return true;
            }

            // Parses retrieved data
            var excludedProducts = shippingOptionExcludedProducts.ToString().Split(';');

            // Loop through the cart to see if it contains any of the selected products.
            // If so, do not allow the shipping option
            foreach (ShoppingCartItemInfo sci in cart.CartItems)
            {
                if (excludedProducts.Contains(ValidationHelper.GetString(sci.SKUID, "")))
                {
                    //Set the flag to false so the option is not allowed
                    blnOptionAllowed = false;
                    break;
                }
            }
        }
        catch(Exception ex)
        {
            EventLogProvider.LogException("CustomShippingOptionInfoProvider - IsShippingOptionApplicableInternal", "EXCEPTION", ex);
        }

        return blnOptionAllowed;
    }
    /// <summary>
    /// Calculates discount which should be applied to the total items price.
    /// </summary>
    /// <param name="cart">Shopping cart</param>        
    protected override double CalculateOrderDiscountInternal(ShoppingCartInfo cart)
    {
        double result = base.CalculateOrderDiscountInternal(cart);

        // Example of order discount based on the time of shopping - Happy hours (4 PM - 7 PM)
        if ((DateTime.Now.Hour >= 16) && (DateTime.Now.Hour <= 19))
        {
            // 20% discount
            result = result + cart.TotalItemsPriceInMainCurrency * 0.2;
        }
        // Example of order discount based on the total price of all cart items
        else if (cart.TotalItemsPriceInMainCurrency > 500)
        {
            // 10% discount
            result = result + cart.TotalItemsPriceInMainCurrency * 0.1;
        }

        return result;
    }
    /// <summary>
    /// Returns catalogue price of the given product based on the SKU data and shopping cart data. 
    /// By default price is loaded from the SKUPrice field.
    /// </summary>
    /// <param name="sku">SKU dta</param>
    /// <param name="cart">Shopping cart data</param>
    protected override double GetSKUPriceInternal(SKUInfo sku, ShoppingCartInfo cart)
    {
        double price = 0;

        // 1) Get base SKU price according to the shopping cart data (current culture)
        if (cart != null)
        {
            switch (cart.ShoppingCartCulture.ToLower())
            {
                case "en-us":
                    // Get price form SKUEnUsPrice field
                    price = ValidationHelper.GetDouble(sku.GetValue("SKUEnUsPrice"), 0);
                    break;

                case "cs-cz":
                    // Get price form SKUCsCzPrice field
                    price = ValidationHelper.GetDouble(sku.GetValue("SKUCsCzPrice"), 0);
                    break;
            }
        }

        //// 2) Get base SKU price according to the product properties (product status)
        //PublicStatusInfo status = PublicStatusInfoProvider.GetPublicStatusInfo(sku.SKUPublicStatusID);
        //if ((status != null) && (status.PublicStatusName.ToLower() == "discounted"))
        //{
        //    // Get price form SKUDiscountedPrice field
        //    price = ValidationHelper.GetDouble(sku.GetValue("SKUDiscountedPrice"), 0);
        //}

        if (price == 0)
        {
            // Get price from the SKUPrice field by default
            return base.GetSKUPriceInternal(sku, cart);
        }
        else
        {
            // Return custom price
            return price;
        }
    }
    /// <summary>
    /// Calculates shipping charge for the given shopping cart.
    /// Shipping taxes are not included. Result is in site main currency.
    /// </summary>
    /// <param name="cartObj">Shopping cart data</param>
    protected override double CalculateShippingInternal(ShoppingCartInfo cart)
    {
        // Calculates shipping based on customer's billing address country
        if (cart != null)
        {
            // Get site name
            string siteName = cart.SiteName;

            if ((cart.UserInfoObj != null) && (cart.UserInfoObj.IsInRole("VIP", siteName)))
            {
                // Free shipping for VIP customers
                return 0;
            }
            else
            {
                // Get shipping address details
                AddressInfo address = AddressInfoProvider.GetAddressInfo(cart.ShoppingCartShippingAddressID);
                if (address != null)
                {
                    // Get shipping address country
                    CountryInfo country = CountryInfoProvider.GetCountryInfo(address.AddressCountryID);
                    if ((country != null) && (country.CountryName.ToLower() != "usa"))
                    {
                        // Get extra shipping for non-usa customers from 'ShippingExtraCharge' custom setting
                        double extraCharge = SettingsKeyProvider.GetDoubleValue("ShippingExtraCharge");

                        // Add an extra charge to standard shipping price for non-usa customers
                        return base.CalculateShippingInternal(cart) + extraCharge;
                    }
                }
            }
        }

        // Calculate shipping option without tax in default way
        return base.CalculateShippingInternal(cart);
    }
        public bool Add(ShoppingCartInfo shoppingcartinfo)
        {
            Parameters cmdParams = GetParameters(shoppingcartinfo);

            return(DBHelper.ExecuteProc("PR_Shop_ShoppingCarts_Add", cmdParams));
        }
Beispiel #8
0
        private void Login()
        {
            string userid    = Request["userid"];
            string userdata  = Request["userdata"];
            string timestamp = Request["timestamp"];
            string source    = Request["source"];

            if (string.IsNullOrWhiteSpace(userid) ||
                string.IsNullOrWhiteSpace(userdata) ||
                string.IsNullOrWhiteSpace(timestamp) ||
                string.IsNullOrWhiteSpace(source))
            {
                Response.Write("fail,缺少必要参数");
                Response.End();
            }

            string key = ConfigurationManager.AppSettings["Key_CCB"];
            string iv  = ConfigurationManager.AppSettings["IV_CCB"];

            string dataKey     = Cryptographer.DESDecrypt(userdata, key, iv);
            string deUserId    = Cryptographer.DESDecrypt(userid, dataKey, iv);
            string deTimestamp = Cryptographer.DESDecrypt(timestamp, dataKey, iv);

            if (string.IsNullOrWhiteSpace(dataKey) ||
                string.IsNullOrWhiteSpace(deUserId) ||
                string.IsNullOrWhiteSpace(deTimestamp))
            {
                Response.Write("fail,请求参数无效");
                Response.End();
            }

            DateTime time = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).Add(new TimeSpan(long.Parse(deTimestamp + "0000000")));
            TimeSpan span = DateTime.Now - time;

            if (span.TotalSeconds > 60)
            {
                Response.Write("fail,请求已过期");
                Response.End();
            }

            Member member = Users.GetUserByCcbOpenId(deUserId) as Member;

            if (member == null)
            {
                // fail,返回原因
                Response.Write("fail,用户不存在");
                Response.End();
            }

            System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
            IUserCookie           userCookie = member.GetUserCookie();

            userCookie.WriteCookie(authCookie, 30, false);
            ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();

            HiContext.Current.User = member;
            if (cookieShoppingCart != null)
            {
                ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                ShoppingCartProcessor.ClearCookieShoppingCart();
            }

            // 登录成功跳转到海美生活用户中心
            Response.Redirect("/User/UserDefault.aspx");
        }
Beispiel #9
0
        private OrderInfo GetOrderInfo(ShoppingCartInfo shoppingCartInfo)
        {
            OrderInfo orderInfo = ShoppingProcessor.ConvertShoppingCartToOrder(shoppingCartInfo, this.isGroupBuy, this.isCountDown, this.isSignBuy);
            OrderInfo result;

            if (orderInfo == null)
            {
                result = null;
            }
            else
            {
                if (this.chkTax.Checked)
                {
                    orderInfo.Tax = orderInfo.GetTotal() * decimal.Parse(this.litTaxRate.Text) / 100m;
                    if (this.isBundling)
                    {
                        BundlingInfo bundlingInfo = ProductBrowser.GetBundlingInfo(this.bundlingid);
                        orderInfo.Tax = bundlingInfo.Price * decimal.Parse(this.litTaxRate.Text) / 100m;
                    }
                }
                orderInfo.InvoiceTitle = this.txtInvoiceTitle.Text;
                if (this.isGroupBuy)
                {
                    GroupBuyInfo productGroupBuyInfo = ProductBrowser.GetProductGroupBuyInfo(shoppingCartInfo.LineItems[this.productSku].ProductId);
                    orderInfo.GroupBuyId = productGroupBuyInfo.GroupBuyId;
                    orderInfo.NeedPrice  = productGroupBuyInfo.NeedPrice;
                }
                if (this.isCountDown)
                {
                    CountDownInfo countDownInfo = ProductBrowser.GetCountDownInfo(this.shoppingCart.LineItems[this.productSku].ProductId);
                    orderInfo.CountDownBuyId = countDownInfo.CountDownId;
                }
                if (this.isBundling)
                {
                    BundlingInfo bundlingInfo = ProductBrowser.GetBundlingInfo(this.bundlingid);
                    orderInfo.BundlingID    = bundlingInfo.BundlingID;
                    orderInfo.BundlingPrice = bundlingInfo.Price;
                    orderInfo.Points        = this.shoppingCart.GetPoint(bundlingInfo.Price);
                }
                orderInfo.OrderId   = this.GenerateOrderId();
                orderInfo.OrderDate = System.DateTime.Now;
                Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.HiContext.Current.User;
                orderInfo.UserId   = user.UserId;
                orderInfo.Username = user.Username;
                if (!user.IsAnonymous)
                {
                    Hidistro.Membership.Context.Member member = user as Hidistro.Membership.Context.Member;
                    orderInfo.EmailAddress = member.Email;
                    orderInfo.RealName     = member.RealName;
                    orderInfo.QQ           = member.QQ;
                    orderInfo.Wangwang     = member.Wangwang;
                    orderInfo.MSN          = member.MSN;
                }
                orderInfo.Remark       = Globals.HtmlEncode(this.txtMessage.Text);
                orderInfo.OrderStatus  = OrderStatus.WaitBuyerPay;
                orderInfo.RefundStatus = RefundStatus.None;
                this.FillOrderCoupon(orderInfo);
                this.FillOrderShippingMode(orderInfo, shoppingCartInfo);
                this.FillOrderPaymentMode(orderInfo);
                result = orderInfo;
            }
            return(result);
        }
 /// <summary>
 /// On prerender.
 /// </summary>
 protected override void OnPreRender(EventArgs e)
 {
     this.ShoppingCart = this.Cart.LocalShoppingCart;
     base.OnPreRender(e);
 }
 /// <summary>
 /// Logs activity "purchase" for all items.
 /// </summary>
 /// <param name="shoppingCartInfoObj">Shopping cart</param>
 /// <param name="contactId">Contact ID</param>
 private void TrackActivityPurchasedProducts(ShoppingCartInfo shoppingCartInfoObj, int contactId)
 {
     // Check if shopping contains any items
     if ((shoppingCartInfoObj == null) || (shoppingCartInfoObj.IsEmpty))
     {
         return;
     }
     // Loop through all products and log activity
     var variables = AnalyticsContext.ActivityEnvironmentVariables;
     foreach (ShoppingCartItemInfo cartItem in shoppingCartInfoObj.CartProducts)
     {
         string skuName = ResHelper.LocalizeString(cartItem.SKU.SKUName) + " (ID#:" + cartItem.SKUID + ")";
         Activity activity = new ActivityPurchasedProduct(skuName, cartItem, variables);
         if (activity.Data != null)
         {
             activity.Data.ContactID = contactId;
             activity.CheckViewMode = false;
             activity.Log();
         }
     }
 }
    private bool CreateOrder(ShoppingCartInfo shoppingCart)
    {
        try
        {
            // Set order culture
            shoppingCart.ShoppingCartCulture = LocalizationContext.PreferredCultureCode;
            // Update customer preferences
            CustomerInfoProvider.SetCustomerPreferredSettings(shoppingCart);
            // Create order
            ShoppingCartInfoProvider.SetOrder(shoppingCart);
        }
        catch (Exception ex)
        {
            // Log exception
            loggedExceptions.Add(ex);
            return false;
        }

        if (shoppingCart.OrderId > 0)
        {
            // Track order conversion
            var name = ECommerceSettings.OrderConversionName(shoppingCart.SiteName);
            ECommerceHelper.TrackOrderConversion(shoppingCart, name);
            ECommerceHelper.TrackOrderItemsConversions(shoppingCart);
            // Log purchase activity
            if (ActivitySettingsHelper.ActivitiesEnabledForThisUser(MembershipContext.AuthenticatedUser))
            {
                var totalPriceInMainCurrency = shoppingCart.TotalPriceInMainCurrency;
                var formattedPrice = CurrencyInfoProvider.GetFormattedPrice(totalPriceInMainCurrency, CurrencyInfoProvider.GetMainCurrency(shoppingCart.ShoppingCartSiteID));

                TrackActivityPurchasedProducts(shoppingCart, ContactID);
                TrackActivityPurchase(shoppingCart.OrderId,
                                      ContactID,
                                      totalPriceInMainCurrency,
                                      formattedPrice);
            }

            return true;
        }

        LogError("Save order action failed", EVENT_CODE_SAVING);
        return false;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!RequestHelper.IsPostBack())
        {
            ShoppingCart = GetNewCart();
        }

        Cart.LocalShoppingCart = ShoppingCart;
        Cart.EnableProductPriceDetail = true;
        Cart.OnPaymentCompleted += new EventHandler(Cart_OnPaymentCompleted);
        Cart.OnPaymentSkipped += new EventHandler(Cart_OnPaymentSkipped);
        Cart.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(Cart_OnCheckPermissions);
        Cart.RequiredFieldsMark = CMS.EcommerceProvider.ShoppingCart.DEFAULT_REQUIRED_FIELDS_MARK;

        if (customerId > 0)
        {
            Cart.CheckoutProcessType = CheckoutProcessEnum.CMSDeskCustomer;
            AddMenuButtonSelectScript("Customers", "");
        }
        else
        {
            Cart.CheckoutProcessType = CheckoutProcessEnum.CMSDeskOrder;
        }
    }
Beispiel #14
0
        private void btnRegister_Click(object sender, System.EventArgs e)
        {
            if (!this.chkAgree.Checked)
            {
                this.ShowMessage("您必须先阅读并同意注册协议", false);
            }
            else
            {
                if (string.Compare(this.txtUserName.Text.Trim().ToLower(System.Globalization.CultureInfo.InvariantCulture), "anonymous", false, System.Globalization.CultureInfo.InvariantCulture) == 0)
                {
                    this.ShowMessage("已经存在相同的用户名", false);
                }
                else
                {
                    if (this.txtUserName.Text.Trim().Length < 2 || this.txtUserName.Text.Trim().Length > 20)
                    {
                        this.ShowMessage("用户名不能为空,且在2-20个字符之间", false);
                    }
                    else
                    {
                        if (string.Compare(this.txtPassword.Text, this.txtPassword2.Text) != 0)
                        {
                            this.ShowMessage("两次输入的密码不相同", false);
                        }
                        else
                        {
                            if (this.txtPassword.Text.Length == 0)
                            {
                                this.ShowMessage("密码不能为空", false);
                            }
                            else
                            {
                                if (this.txtPassword.Text.Length < System.Web.Security.Membership.Provider.MinRequiredPasswordLength || this.txtPassword.Text.Length > HiConfiguration.GetConfig().PasswordMaxLength)
                                {
                                    this.ShowMessage(string.Format("密码的长度只能在{0}和{1}个字符之间", System.Web.Security.Membership.Provider.MinRequiredPasswordLength, HiConfiguration.GetConfig().PasswordMaxLength), false);
                                }
                                else
                                {
                                    Hidistro.Membership.Context.Member member;
                                    if (Hidistro.Membership.Context.HiContext.Current.SiteSettings.IsDistributorSettings)
                                    {
                                        member = new Hidistro.Membership.Context.Member(Hidistro.Membership.Core.Enums.UserRole.Underling);
                                        member.ParentUserId = Hidistro.Membership.Context.HiContext.Current.SiteSettings.UserId;
                                    }
                                    else
                                    {
                                        member = new Hidistro.Membership.Context.Member(Hidistro.Membership.Core.Enums.UserRole.Member);
                                    }
                                    if (Hidistro.Membership.Context.HiContext.Current.ReferralUserId > 0)
                                    {
                                        member.ReferralUserId = new int?(Hidistro.Membership.Context.HiContext.Current.ReferralUserId);
                                    }
                                    member.GradeId             = MemberProcessor.GetDefaultMemberGrade();
                                    member.Username            = Globals.HtmlEncode(this.txtUserName.Text.Trim());
                                    member.Email               = this.txtEmail.Text;
                                    member.Password            = this.txtPassword.Text;
                                    member.PasswordFormat      = System.Web.Security.MembershipPasswordFormat.Hashed;
                                    member.TradePasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
                                    member.TradePassword       = this.txtPassword.Text;
                                    if (this.txtCellPhone != null)
                                    {
                                        member.CellPhone = this.txtCellPhone.Text;
                                    }
                                    member.IsApproved = true;
                                    member.RealName   = string.Empty;
                                    member.Address    = string.Empty;
                                    if (this.ValidationMember(member))
                                    {
                                        if (!Hidistro.Membership.Context.HiContext.Current.CheckVerifyCode(this.txtNumber.Text))
                                        {
                                            this.ShowMessage("验证码输入错误", false);
                                        }
                                        else
                                        {
                                            switch (MemberProcessor.CreateMember(member))
                                            {
                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure:
                                                this.ShowMessage("未知错误", false);
                                                break;

                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.Created:
                                            {
                                                Messenger.UserRegister(member, this.txtPassword.Text);
                                                member.OnRegister(new Hidistro.Membership.Context.UserEventArgs(member.Username, this.txtPassword.Text, null));
                                                Hidistro.Membership.Core.IUser user           = Hidistro.Membership.Context.Users.GetUser(0, member.Username, false, true);
                                                ShoppingCartInfo       shoppingCart           = ShoppingCartProcessor.GetShoppingCart();
                                                CookieShoppingProvider cookieShoppingProvider = CookieShoppingProvider.Instance();
                                                cookieShoppingProvider.ClearShoppingCart();
                                                Hidistro.Membership.Context.HiContext.Current.User = user;
                                                if (shoppingCart != null)
                                                {
                                                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart);
                                                }
                                                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
                                                Hidistro.Membership.Core.IUserCookie userCookie = user.GetUserCookie();
                                                userCookie.WriteCookie(authCookie, 30, false);
                                                this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("registerUserSave") + "?UserId=" + user.UserId);
                                                break;
                                            }

                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.DuplicateUsername:
                                                this.ShowMessage("已经存在相同的用户名", false);
                                                break;

                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.DuplicateEmailAddress:
                                                this.ShowMessage("电子邮件地址已经存在", false);
                                                break;

                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.DisallowedUsername:
                                                this.ShowMessage("用户名禁止注册", false);
                                                break;

                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidPassword:
                                                this.ShowMessage("无效的密码", false);
                                                break;

                                            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidEmail:
                                                this.ShowMessage("无效的电子邮件地址", false);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #15
0
        protected void RptShoppingCart_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            ShopConfig shopConfig = SiteConfig.ShopConfig;
            bool       isPaymentShowProducdtThumb = true;
            int        paymentThumbsWidth         = 0;
            int        paymentThumbsHeight        = 0;
            bool       isShowPaymentProductType   = true;
            bool       isShowPaymentSaleType      = true;
            bool       isShowPaymentMarkPrice     = true;

            if (this.IsPreview == 0)
            {
                isPaymentShowProducdtThumb = shopConfig.IsPaymentShowProducdtThumb;
                isShowPaymentProductType   = shopConfig.IsShowPaymentProductType;
                isShowPaymentSaleType      = shopConfig.IsShowPaymentSaleType;
                isShowPaymentMarkPrice     = shopConfig.IsShowPaymentMarkPrice;
                paymentThumbsWidth         = shopConfig.PaymentThumbsWidth;
                paymentThumbsHeight        = shopConfig.PaymentThumbsHeight;
            }
            else if (this.IsPreview == 1)
            {
                isPaymentShowProducdtThumb = shopConfig.IsPreviewShowProducdtThumb;
                isShowPaymentProductType   = shopConfig.IsShowPreviewProductType;
                isShowPaymentSaleType      = shopConfig.IsShowPreviewSaleType;
                isShowPaymentMarkPrice     = shopConfig.IsShowPreviewMarkPrice;
                paymentThumbsWidth         = shopConfig.PreviewThumbsWidth;
                paymentThumbsHeight        = shopConfig.PreviewThumbsHeight;
            }
            if ((e.Item.ItemType != ListItemType.Item) && (e.Item.ItemType != ListItemType.AlternatingItem))
            {
                if (e.Item.ItemType == ListItemType.Footer)
                {
                    PresentProjectInfo presentProInfo = new PresentProjectInfo(true);
                    if (this.m_IsPreview != 3)
                    {
                        presentProInfo            = PresentProject.GetPresentProjectByTotalMoney(this.total);
                        this.presentExpInfomation = this.ShowPresentExp(presentProInfo).ToString();
                    }
                    if (this.m_IsPreview == 1)
                    {
                        int         presentId = DataConverter.CLng(this.PresentId);
                        PlaceHolder holder    = (PlaceHolder)e.Item.FindControl("PlhPresentInfo");
                        holder.Visible = false;
                        if (((presentId > 0) && !presentProInfo.IsNull) && (presentProInfo.PresentContent.Contains("1") && (presentId > 0)))
                        {
                            holder.Visible = true;
                            AbstractItemInfo info7 = new ConcretePresentProject(presentId, presentProInfo);
                            info7.GetItemInfo();
                            Label label2 = (Label)e.Item.FindControl("LblProductName");
                            Label label3 = (Label)e.Item.FindControl("LblUnit");
                            Label label4 = (Label)e.Item.FindControl("LblPresentPriceMarket");
                            Label label5 = (Label)e.Item.FindControl("LblPresentPrice");
                            Label label6 = (Label)e.Item.FindControl("LblPresentPrice1");
                            label2.Text  = info7.ProductName;
                            label3.Text  = info7.Unit;
                            label4.Text  = info7.PriceMarket.ToString("0.00");
                            label5.Text  = info7.Price.ToString("0.00");
                            label6.Text  = info7.Price.ToString("0.00");
                            this.weight += info7.TotalWeight;
                            this.total  += info7.Price;
                        }
                        ((PlaceHolder)e.Item.FindControl("PlhMoneyInfo")).Visible = true;
                        Label       label7  = (Label)e.Item.FindControl("LblDeliverCharge");
                        Label       label8  = (Label)e.Item.FindControl("LblTaxRate");
                        Label       label9  = (Label)e.Item.FindControl("LblIncludeTax");
                        Label       label10 = (Label)e.Item.FindControl("LblCoupon");
                        Label       label11 = (Label)e.Item.FindControl("LblTotalMoney");
                        Label       label12 = (Label)e.Item.FindControl("LblTrueTotalMoney");
                        PackageInfo packageByGoodsWeight = Package.GetPackageByGoodsWeight(this.weight);
                        if (!packageByGoodsWeight.IsNull)
                        {
                            this.weight += packageByGoodsWeight.PackageWeight;
                        }
                        decimal         num7            = DeliverCharge.GetDeliverCharge(this.m_DeliverType, this.weight, this.m_ZipCode, this.total, this.m_NeedInvoice);
                        DeliverTypeInfo deliverTypeById = EasyOne.Shop.DeliverType.GetDeliverTypeById(this.m_DeliverType);
                        label7.Text = num7.ToString("0.00");
                        label8.Text = deliverTypeById.TaxRate.ToString();
                        if ((deliverTypeById.IncludeTax == TaxRateType.IncludeTaxNoInvoiceFavourable) || (deliverTypeById.IncludeTax == TaxRateType.IncludeTaxNoInvoiceNoFavourable))
                        {
                            label9.Text = "是";
                        }
                        else
                        {
                            label9.Text = "否";
                        }
                        decimal num8 = this.total + num7;
                        if (this.m_CouponMoney > 0M)
                        {
                            label10.Visible = true;
                            decimal num9 = this.total - this.m_CouponMoney;
                            if (num9 < 0M)
                            {
                                num9 = 0M;
                            }
                            num8         = num9 + num7;
                            label10.Text = "使用优惠券,面值为:" + this.m_CouponMoney.ToString("0.00") + "元,商品实际价格为:" + num9.ToString("0.00") + "元 <br>";
                            label11.Text = num9.ToString("0.00") + "+" + num7.ToString("0.00") + "=" + num8.ToString("0.00") + "元";
                            label12.Text = num8.ToString("0.00");
                        }
                        else
                        {
                            label10.Visible = false;
                            label11.Text    = this.total.ToString("0.00") + "+" + num7.ToString("0.00") + "=" + num8.ToString("0.00") + "元";
                            label12.Text    = num8.ToString("0.00");
                        }
                        this.ViewState["TrueTotalMoney"] = num8;
                    }
                    else
                    {
                        ((PlaceHolder)e.Item.FindControl("PlhMoneyInfo")).Visible = false;
                    }
                    ExtendedImage image3    = (ExtendedImage)e.Item.FindControl("presentImage");
                    Control       control9  = e.Item.FindControl("footerPresentImage");
                    Control       control10 = e.Item.FindControl("footerTdThemeImage");
                    Control       control11 = e.Item.FindControl("footerTdProductType");
                    Control       control12 = e.Item.FindControl("footerTdSaleType");
                    Control       control13 = e.Item.FindControl("footerTdMarkPrice");
                    Control       control14 = e.Item.FindControl("footerTdThemeImage");
                    Control       control15 = e.Item.FindControl("footerTdMoneyInfoSaleType");
                    Control       control16 = e.Item.FindControl("footerTdMoneyInfoMarkPrice");
                    Control       control17 = e.Item.FindControl("footerPresentType");
                    Control       control18 = e.Item.FindControl("footerPresentSaleType");
                    Control       control19 = e.Item.FindControl("footerPresentMarkPrice");
                    if (!isPaymentShowProducdtThumb)
                    {
                        control10.Visible = false;
                        control9.Visible  = false;
                    }
                    else
                    {
                        PresentInfo presentById = Present.GetPresentById(DataConverter.CLng(this.PresentId));
                        if (!string.IsNullOrEmpty(presentById.PresentThumb))
                        {
                            image3.Src = presentById.PresentThumb;
                        }
                        else
                        {
                            image3.Src = SiteConfig.SiteInfo.VirtualPath + "Images/nopic.gif";
                        }
                        image3.Width  = paymentThumbsWidth;
                        image3.Height = paymentThumbsHeight;
                    }
                    if (!isShowPaymentProductType)
                    {
                        control11.Visible = false;
                        control14.Visible = false;
                        control17.Visible = false;
                    }
                    if (!isShowPaymentSaleType)
                    {
                        control12.Visible = false;
                        control15.Visible = false;
                        control18.Visible = false;
                    }
                    if (!isShowPaymentMarkPrice)
                    {
                        control13.Visible = false;
                        control16.Visible = false;
                        control19.Visible = false;
                        return;
                    }
                }
                else if (e.Item.ItemType == ListItemType.Header)
                {
                    Control control20 = e.Item.FindControl("ProductImageTitle");
                    Control control21 = e.Item.FindControl("tdProductTypeTitle");
                    Control control22 = e.Item.FindControl("tdSaleTypeTitle");
                    Control control23 = e.Item.FindControl("tdMarkPriceTitle");
                    if (!isPaymentShowProducdtThumb)
                    {
                        control20.Visible = false;
                    }
                    if (!isShowPaymentProductType)
                    {
                        control21.Visible = false;
                    }
                    if (!isShowPaymentSaleType)
                    {
                        control22.Visible = false;
                    }
                    if (!isShowPaymentMarkPrice)
                    {
                        control23.Visible = false;
                    }
                }
                return;
            }
            int              productNum = 0;
            string           str        = "";
            string           str2       = "";
            decimal          subTotal   = 0M;
            ShoppingCartInfo dataItem   = (ShoppingCartInfo)e.Item.DataItem;

            if (dataItem == null)
            {
                return;
            }
            productNum = dataItem.Quantity;
            bool haveWholesalePurview = Convert.ToBoolean(this.ViewState["HaveWholesalePurview"]);

            str2 = ShoppingCart.GetSaleType(dataItem.ProductInfomation, productNum, haveWholesalePurview);
            str  = ShoppingCart.GetProductType(dataItem.ProductInfomation, productNum, haveWholesalePurview);
            AbstractItemInfo info2 = new ConcreteProductInfo(productNum, dataItem.Property, dataItem.ProductInfomation, this.m_UserInfo, false, false, haveWholesalePurview);

            info2.GetItemInfo();
            subTotal         = info2.SubTotal;
            this.total      += subTotal;
            this.totalExp   += dataItem.ProductInfomation.PresentExp * productNum;
            this.totalMoney += dataItem.ProductInfomation.PresentMoney * productNum;
            this.totalPoint += dataItem.ProductInfomation.PresentPoint * productNum;
            this.weight     += info2.TotalWeight;
            if (!string.IsNullOrEmpty(dataItem.Property))
            {
                ((Literal)e.Item.FindControl("LitProperty")).Text = "(" + info2.Property + ")";
            }
            InsideStaticLabel label = new InsideStaticLabel();
            string            str3  = "<a href='";

            str3 = (str3 + label.GetInfoPath(info2.ProductId.ToString())) + "' Target='_blank'>" + info2.ProductName + "</a>";
            ((Literal)e.Item.FindControl("LitProductName")).Text = str3;
            ((Literal)e.Item.FindControl("LitProductUnit")).Text = info2.Unit;
            ((Literal)e.Item.FindControl("LitTruePrice")).Text   = info2.Price.ToString("0.00");
            ((Literal)e.Item.FindControl("LitSubTotal")).Text    = subTotal.ToString("0.00");
            ExtendedImage image    = (ExtendedImage)e.Item.FindControl("extendedImage");
            ExtendedImage image2   = (ExtendedImage)e.Item.FindControl("extendedPresentImage");
            Control       control  = e.Item.FindControl("ProductImage");
            Control       control2 = e.Item.FindControl("presentImage");

            if (!isPaymentShowProducdtThumb)
            {
                image.Visible    = false;
                control.Visible  = false;
                control2.Visible = false;
            }
            else
            {
                if (!string.IsNullOrEmpty(dataItem.ProductInfomation.ProductThumb))
                {
                    image.Src = dataItem.ProductInfomation.ProductThumb;
                }
                else
                {
                    image.Src = SiteConfig.SiteInfo.VirtualPath + "Images/nopic.gif";
                }
                image.ImageHeight = paymentThumbsHeight;
                image.ImageWidth  = paymentThumbsWidth;
                if (dataItem.ProductInfomation.PresentId > 0)
                {
                    PresentInfo info3 = Present.GetPresentById(dataItem.ProductInfomation.PresentId);
                    if (!string.IsNullOrEmpty(info3.PresentThumb))
                    {
                        image2.Src = info3.PresentThumb;
                    }
                    else
                    {
                        image2.Src = SiteConfig.SiteInfo.VirtualPath + "Images/nopic.gif";
                    }
                    image2.ImageHeight = paymentThumbsHeight;
                    image2.ImageWidth  = paymentThumbsWidth;
                }
            }
            if (!isShowPaymentProductType)
            {
                e.Item.FindControl("tdProductType").Visible = false;
            }
            else
            {
                ((Literal)e.Item.FindControl("LitProductType")).Text = str;
            }
            if (!isShowPaymentSaleType)
            {
                e.Item.FindControl("tdSaleType").Visible = false;
            }
            else
            {
                ((Literal)e.Item.FindControl("LitSaleType")).Text = str2;
            }
            if (!isShowPaymentMarkPrice)
            {
                e.Item.FindControl("tdMarkPrice").Visible = false;
            }
            else
            {
                ((Literal)e.Item.FindControl("LitPriceMarket")).Text = info2.PriceMarket.ToString("0.00");
            }
            int         num5        = Order.CountBuyNum(PEContext.Current.User.UserName, dataItem.ProductId);
            ProductInfo productById = Product.GetProductById(dataItem.ProductId);

            if ((productById.LimitNum > 0) && ((dataItem.Quantity + num5) > productById.LimitNum))
            {
                BaseUserControl.WriteErrMsg(string.Concat(new object[] { "您订购了", num5, productById.Unit, productById.ProductName, ",曾经购买了", num5, productById.Unit, ",而此商品每人限购数量为", productById.LimitNum, productById.Unit, ",请重新调整您的购物车!" }), "ShoppingCart.aspx");
            }
            if ((dataItem.ProductInfomation.SalePromotionType <= 0) || (productNum < dataItem.ProductInfomation.MinNumber))
            {
                return;
            }
            e.Item.FindControl("PresentInfomation").Visible = true;
            string           str4  = "";
            string           str5  = "";
            string           str6  = "";
            AbstractItemInfo info5 = new ConcreteSalePromotionType(productNum, dataItem.ProductInfomation, false, null);

            info5.GetItemInfo();
            switch (dataItem.ProductInfomation.SalePromotionType)
            {
            case 1:
            case 3:
                str5 = "<font color=red>(赠品)</font>";
                str4 = "赠送礼品";
                str6 = "赠送";
                goto Label_06A1;

            case 2:
            case 4:
                if (info5.Price <= 0M)
                {
                    str5 = "<font color=red>(赠送赠品)</font>";
                    str6 = "赠送";
                    break;
                }
                str5 = "<font color=red>(换购赠品)</font>";
                str6 = "换购";
                break;

            default:
                goto Label_06A1;
            }
            str4 = "促销礼品";
Label_06A1:
            if (this.PresentExist(this.m_CartId, info5.Id))
            {
                ((HiddenField)e.Item.FindControl("HdnPresentId")).Value = info5.Id.ToString();
                ExtendedLiteral literal = (ExtendedLiteral)e.Item.FindControl("LitPresentName");
                literal.Text   = info5.ProductName;
                literal.EndTag = str5;
                ((Literal)e.Item.FindControl("LitPresentUnit")).Text      = info5.Unit;
                ((Literal)e.Item.FindControl("LitPresentNum")).Text       = info5.Amount.ToString();
                ((Literal)e.Item.FindControl("LitPresentTruePrice")).Text = info5.Price.ToString("0.00");
                ((Literal)e.Item.FindControl("LitPresentSubtotal")).Text  = info5.SubTotal.ToString("0.00");
                this.total  += info5.SubTotal;
                this.weight += info5.TotalWeight;
            }
            if (!isShowPaymentProductType)
            {
                e.Item.FindControl("tdPresentType").Visible = false;
            }
            else
            {
                ((Literal)e.Item.FindControl("LitPresentType")).Text = str4;
            }
            if (!isShowPaymentSaleType)
            {
                e.Item.FindControl("tdPresentSaleType").Visible = false;
            }
            else
            {
                ((Literal)e.Item.FindControl("LitPresentSaleType")).Text = str6;
            }
            if (!isShowPaymentMarkPrice)
            {
                e.Item.FindControl("tdPresentMarkPrice").Visible = false;
            }
            else
            {
                ((Literal)e.Item.FindControl("LitPresentPriceOriginal")).Text = info5.PriceMarket.ToString("0.00");
            }
        }
Beispiel #16
0
 protected override void OnInit(EventArgs e)
 {
     if (this.SkinName == null)
     {
         this.SkinName = "Skin-OrderStoresSet.html";
     }
     this.from                 = this.Page.Request.QueryString["from"].ToNullString().ToLower();
     this.productSku           = this.Page.Request.QueryString["productSku"].ToNullString();
     this.buyAmount            = this.Page.Request.QueryString["buyAmount"].ToInt(0);
     this.shippingModeId       = this.Page.Request.QueryString["ShippingModeId"].ToInt(0);
     this.storeId              = this.Page.Request.QueryString["ChooseStoreId"].ToInt(0);
     this.paymentModeId        = this.Page.Request.QueryString["paymentModeId"].ToInt(0);
     this.deliveryTime         = this.Page.Request.QueryString["deliveryTime"].ToNullString();
     this.fightGroupActivityId = this.Page.Request.QueryString["fightGroupActivityId"].ToInt(0);
     if (this.deliveryTime != "任意时间" && this.deliveryTime != "工作日" && this.deliveryTime != "节假日")
     {
         this.deliveryTime = "任意时间";
     }
     if (this.shippingModeId != 0 && this.shippingModeId != -2)
     {
         this.shippingModeId = 0;
     }
     if (string.IsNullOrEmpty(this.productSku))
     {
         HttpCookie httpCookie = HiContext.Current.Context.Request.Cookies["ckids"];
         if (httpCookie != null && !string.IsNullOrEmpty(httpCookie.Value))
         {
             this.productSku = Globals.UrlDecode(httpCookie.Value);
         }
     }
     if (!string.IsNullOrEmpty(this.productSku))
     {
         string[] array = this.productSku.Split(',');
         for (int i = 0; i < array.Length; i++)
         {
             string[] array2 = array[i].Split('|');
             if (!string.IsNullOrEmpty(this.newProductSku))
             {
                 this.newProductSku += ",";
             }
             this.newProductSku += array2[0];
         }
     }
     if (this.from == "combinationbuy")
     {
         this.combinaid    = this.Page.Request.QueryString["combinaid"].ToInt(0);
         this.shoppingCart = ShoppingCartProcessor.GetCombinationShoppingCart(this.combinaid, this.productSku, this.buyAmount, true);
     }
     else
     {
         this.shoppingCart = ShoppingCartProcessor.GetShoppingCart(this.from, this.productSku, this.buyAmount, 0, true, this.storeId, this.fightGroupActivityId);
     }
     if (this.shoppingCart == null)
     {
         base.GotoResourceNotFound("购物车中没有任何商品");
     }
     else
     {
         base.OnInit(e);
     }
 }
Beispiel #17
0
        private void Notify_Authenticated(object sender, AuthenticatedEventArgs e)
        {
            this.parameters.Add("CurrentOpenId", e.OpenId);
            HiContext current            = HiContext.Current;
            string    usernameWithOpenId = UserHelper.GetUsernameWithOpenId(e.OpenId, this.openIdType);

            if (!string.IsNullOrEmpty(usernameWithOpenId))
            {
                Member member = Users.GetUser(0, usernameWithOpenId, false, true) as Member;
                if (member == null)
                {
                    base.Response.Write("登录失败,信任登录只能用于会员登录。");
                    return;
                }
                if (member.ParentUserId.HasValue && member.ParentUserId.Value != 0)
                {
                    base.Response.Write("账号已经与本平台的其它子站绑定,不能在此域名上登录。");
                    return;
                }
                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
                IUserCookie           userCookie = member.GetUserCookie();
                userCookie.WriteCookie(authCookie, 30, false);
                HiContext.Current.User = member;
                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                current.User = member;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                if (!string.IsNullOrEmpty(this.parameters["token"]))
                {
                    System.Web.HttpCookie httpCookie = new System.Web.HttpCookie("Token_" + HiContext.Current.User.UserId.ToString());
                    httpCookie.Expires = System.DateTime.Now.AddMinutes(30.0);
                    httpCookie.Value   = this.parameters["token"];
                    System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
                }
            }
            else
            {
                string a;
                if ((a = this.openIdType.ToLower()) != null)
                {
                    if (a == "Ecdev.plugins.openid.alipay.alipayservice")
                    {
                        this.SkipAlipayOpenId();
                        goto IL_1EF;
                    }
                    if (a == "Ecdev.plugins.openid.qq.qqservice")
                    {
                        this.SkipQQOpenId();
                        goto IL_1EF;
                    }
                    if (a == "Ecdev.plugins.openid.taobao.taobaoservice")
                    {
                        this.SkipTaoBaoOpenId();
                        goto IL_1EF;
                    }
                    if (a == "Ecdev.plugins.openid.sina.sinaservice")
                    {
                        this.SkipSinaOpenId();
                        goto IL_1EF;
                    }
                }
                this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
            }
IL_1EF:
            string a2 = this.parameters["HITO"];

            if (a2 == "1")
            {
                this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("submitOrder"));
                return;
            }
            this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
        }
Beispiel #18
0
        protected void SkipSinaOpenId()
        {
            Member member = new Member(UserRole.Member);

            if (HiContext.Current.ReferralUserId > 0)
            {
                member.ReferralUserId = new int?(HiContext.Current.ReferralUserId);
            }
            member.GradeId  = MemberProcessor.GetDefaultMemberGrade();
            member.Username = this.parameters["CurrentOpenId"];
            if (string.IsNullOrEmpty(member.Username))
            {
                member.Username = "******" + this.GenerateUsername(8);
            }
            member.Email = this.GenerateUsername() + "@localhost.com";
            string text = this.GeneratePassword();

            member.Password            = text;
            member.PasswordFormat      = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePassword       = text;
            member.IsApproved          = true;
            member.RealName            = string.Empty;
            member.Address             = string.Empty;
            if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
            {
                member.Username = "******" + this.GenerateUsername(9);
                member.Password = (member.TradePassword = text);
                if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
                {
                    member.Username = this.GenerateUsername();
                    member.Email    = this.GenerateUsername() + "@localhost.com";
                    member.Password = (member.TradePassword = text);
                    if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
                    {
                        base.Response.Write("为您创建随机账户时失败,请重试。");
                        return;
                    }
                }
            }
            UserHelper.BindOpenId(member.Username, this.parameters["CurrentOpenId"], this.parameters["HIGW"]);
            System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
            IUserCookie           userCookie = member.GetUserCookie();

            userCookie.WriteCookie(authCookie, 30, false);
            ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();

            HiContext.Current.User = member;
            if (cookieShoppingCart != null)
            {
                ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                ShoppingCartProcessor.ClearCookieShoppingCart();
            }
            if (!string.IsNullOrEmpty(this.parameters["token"]))
            {
                System.Web.HttpCookie httpCookie = new System.Web.HttpCookie("Token_" + HiContext.Current.User.UserId.ToString());
                httpCookie.Expires = System.DateTime.Now.AddMinutes(30.0);
                httpCookie.Value   = this.parameters["token"];
                System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
            }
            this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
        }
Beispiel #19
0
        public static ShoppingCartInfo GetShoppingCartInfoBySkus(Member member, string skuIds) //获取顾客选择的待下单的购物车信息
        {
            string[] skuIdsArray = skuIds.Split(',');

            HashSet <string> hsSkuIds = new HashSet <string>();

            for (int i = 0; i < skuIdsArray.Length; i++)
            {
                if (skuIdsArray[i].Trim().Length == 0)
                {
                    continue;
                }
                hsSkuIds.Add(skuIdsArray[i]);
            }

            ShoppingCartInfo result = GetShoppingCart(member);

            //判断购物车是否为空
            if (result == null)
            {
                return(result);
            }

            if (hsSkuIds.Count == result.LineItems.Count)    //如果传进来的Sku个数与数据库一致,则返回所有
            {
                return(result);
            }

            if (result != null)
            {
                List <ShoppingCartItemInfo> listShoppingCartItemInfo = new List <ShoppingCartItemInfo>();

                int count = result.LineItems.Count;
                for (int i = 0; i < count; i++)
                {
                    if (!hsSkuIds.Contains(result.LineItems[i].SkuId))
                    {
                        listShoppingCartItemInfo.Add(result.LineItems[i]);
                    }
                }

                foreach (ShoppingCartItemInfo item in listShoppingCartItemInfo)
                {
                    result.LineItems.Remove(item);
                }

                if (member != null)
                {
                    if (result.LineItems.Count == 0 && result.LineGifts.Count == 0)
                    {
                        result = null;
                    }
                    else
                    {
                        decimal       reducedPromotionAmount = 0m;
                        PromotionInfo reducedPromotion       = new PromotionDao().GetReducedPromotion(member, result.GetAmount(), result.GetQuantity(), out reducedPromotionAmount);
                        if (reducedPromotion != null)
                        {
                            result.ReducedPromotionId     = reducedPromotion.ActivityId;
                            result.ReducedPromotionName   = reducedPromotion.Name;
                            result.ReducedPromotionAmount = reducedPromotionAmount;
                            result.IsReduced = true;
                        }
                        else
                        {
                            result.IsReduced = false;
                        }
                        PromotionInfo sendPromotion = new PromotionDao().GetSendPromotion(member, result.GetTotal(), PromoteType.FullAmountSentGift);
                        if (sendPromotion != null)
                        {
                            result.SendGiftPromotionId   = sendPromotion.ActivityId;
                            result.SendGiftPromotionName = sendPromotion.Name;
                            result.IsSendGift            = true;
                        }
                        else
                        {
                            result.IsSendGift = false;
                        }
                        PromotionInfo sendPromotion2 = new PromotionDao().GetSendPromotion(member, result.GetTotal(), PromoteType.FullAmountSentTimesPoint);
                        if (sendPromotion2 != null)
                        {
                            result.SentTimesPointPromotionId   = sendPromotion2.ActivityId;
                            result.SentTimesPointPromotionName = sendPromotion2.Name;
                            result.IsSendTimesPoint            = true;
                            result.TimesPoint = sendPromotion2.DiscountValue;
                        }
                        else
                        {
                            result.IsSendTimesPoint = false;
                        }
                        PromotionInfo sendPromotion3 = new PromotionDao().GetSendPromotion(member, result.GetTotal(), PromoteType.FullAmountSentFreight);
                        if (sendPromotion3 != null)
                        {
                            result.FreightFreePromotionId   = sendPromotion3.ActivityId;
                            result.FreightFreePromotionName = sendPromotion3.Name;
                            result.IsFreightFree            = true;
                        }
                        else
                        {
                            result.IsFreightFree = false;
                        }
                    }
                }
            }

            return(result);
        }
    private bool EnsureCartCustomer(ShoppingCartInfo shoppingCart)
    {
        CustomerInfo customer = shoppingCart.Customer;
        customer.CustomerSiteID = shoppingCart.ShoppingCartSiteID;
        customer.CustomerUserID = shoppingCart.ShoppingCartUserID;

        CustomerInfoProvider.SetCustomerInfo(customer);
        shoppingCart.ShoppingCartCustomerID = customer.CustomerID;

        if (customer.CustomerID > 0)
        {
            // Track successful registration conversion
            string name = ECommerceSettings.RegistrationConversionName(shoppingCart.SiteName);
            ECommerceHelper.TrackRegistrationConversion(shoppingCart.SiteName, name);
            // Log customer registration activity
            var activityCustomerRegistration = new ActivityCustomerRegistration(customer, MembershipContext.AuthenticatedUser, AnalyticsContext.ActivityEnvironmentVariables);
            if (activityCustomerRegistration.Data != null)
            {
                if ((ContactID <= 0) && (customer.CustomerUser != null))
                {
                    activityCustomerRegistration.Data.ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(customer.CustomerUser);
                }
                else
                {
                    activityCustomerRegistration.Data.ContactID = ContactID;
                }

                activityCustomerRegistration.Log();
            }

            return true;
        }
        else
        {
            LogError("Save customer action failed", EVENT_CODE_SAVING);
            return false;
        }
    }
Beispiel #21
0
        public static ShoppingCartInfo GetPartShoppingCartInfo(string skuIds) //获取顾客选择的待下单的购物车信息
        {
            if (!string.IsNullOrEmpty(skuIds))
            {
                skuIds = EcShop.Core.Globals.UrlDecode(skuIds);
            }

            string[]         skuIdsArray = skuIds.Split(',');
            HashSet <string> hsSkuIds    = new HashSet <string>();

            for (int i = 0; i < skuIdsArray.Length; i++)
            {
                if (skuIdsArray[i].Trim().Length == 0)
                {
                    continue;
                }
                hsSkuIds.Add(skuIdsArray[i]);
            }
            ShoppingCartInfo result = GetShoppingCart();

            if (hsSkuIds.Count == 0)
            {
                return(result);
            }
            List <ShoppingCartItemInfo> listShoppingCartItemInfo = new List <ShoppingCartItemInfo>();

            if (result != null)
            {
                int count = result.LineItems.Count;
                for (int i = 0; i < count; i++)
                {
                    if (hsSkuIds.Contains(result.LineItems[i].SkuId))
                    {
                        listShoppingCartItemInfo.Add(result.LineItems[i]);
                    }
                }
                foreach (ShoppingCartItemInfo item in listShoppingCartItemInfo)
                {
                    result.LineItems.Remove(item);
                }
                Member member = HiContext.Current.User as Member;
                if (member != null)
                {
                    if (result.LineItems.Count == 0 && result.LineGifts.Count == 0)
                    {
                        result = null;
                    }
                    else
                    {
                        decimal       reducedPromotionAmount = 0m;
                        PromotionInfo reducedPromotion       = new PromotionDao().GetReducedPromotion(member, result.GetAmount(), result.GetQuantity(), out reducedPromotionAmount);
                        if (reducedPromotion != null)
                        {
                            result.ReducedPromotionId     = reducedPromotion.ActivityId;
                            result.ReducedPromotionName   = reducedPromotion.Name;
                            result.ReducedPromotionAmount = reducedPromotionAmount;
                            result.IsReduced = true;
                        }
                        else
                        {
                            result.ReducedPromotionId     = 0;
                            result.ReducedPromotionName   = "";
                            result.ReducedPromotionAmount = 0m;
                            result.IsReduced = false;
                        }
                        PromotionInfo sendPromotion = new PromotionDao().GetSendPromotion(member, result.GetTotal(), PromoteType.FullAmountSentGift);
                        if (sendPromotion != null)
                        {
                            result.SendGiftPromotionId   = sendPromotion.ActivityId;
                            result.SendGiftPromotionName = sendPromotion.Name;
                            result.IsSendGift            = true;
                        }
                        else
                        {
                            result.SendGiftPromotionId   = 0;
                            result.SendGiftPromotionName = "";
                            result.IsSendGift            = false;
                        }
                        PromotionInfo sendPromotion2 = new PromotionDao().GetSendPromotion(member, result.GetTotal(), PromoteType.FullAmountSentTimesPoint);
                        if (sendPromotion2 != null)
                        {
                            result.SentTimesPointPromotionId   = sendPromotion2.ActivityId;
                            result.SentTimesPointPromotionName = sendPromotion2.Name;
                            result.IsSendTimesPoint            = true;
                            result.TimesPoint = sendPromotion2.DiscountValue;
                        }
                        else
                        {
                            result.SentTimesPointPromotionId   = 0;
                            result.SentTimesPointPromotionName = "";
                            result.IsSendTimesPoint            = false;
                            result.TimesPoint = 0m;
                        }
                        PromotionInfo sendPromotion3 = new PromotionDao().GetSendPromotion(member, result.GetTotal(), PromoteType.FullAmountSentFreight);
                        if (sendPromotion3 != null)
                        {
                            result.FreightFreePromotionId   = sendPromotion3.ActivityId;
                            result.FreightFreePromotionName = sendPromotion3.Name;
                            result.IsFreightFree            = true;
                        }
                        else
                        {
                            result.FreightFreePromotionId   = 0;
                            result.FreightFreePromotionName = "";
                            result.IsFreightFree            = false;
                        }
                    }
                }
            }
            return(result);
        }
    private void HandleAutomaticSelections(ShoppingCartInfo currentShoppingCart)
    {
        if ((currentShoppingCart.ShippingOption == null) && currentShoppingCart.IsShippingNeeded)
        {
            // Try to select shipping option if there is only one in system
            var query = ShippingOptionInfoProvider.GetShippingOptions(currentShoppingCart.ShoppingCartSiteID, true).Column("ShippingOptionID");
            if (query.Count == 1)
            {
                currentShoppingCart.ShoppingCartShippingOptionID = DataHelper.GetIntegerValues(query.Tables[0], "ShippingOptionID").FirstOrDefault();
            }
        }

        if (currentShoppingCart.PaymentOption == null)
        {
            // Try to select payment option if there is only one in system
            var query = PaymentOptionInfoProvider.GetPaymentOptions(currentShoppingCart.ShoppingCartSiteID, true).Column("PaymentOptionID");
            if (query.Count == 1)
            {
                int paymentOptionId = DataHelper.GetIntegerValues(query.Tables[0], "PaymentOptionID").FirstOrDefault();
                // Check if payment is allowed for shipping, or shipping is not set
                if (CheckPaymentIsAllowedForShipping(currentShoppingCart, paymentOptionId))
                {
                    currentShoppingCart.ShoppingCartPaymentOptionID = paymentOptionId;
                }
            }
        }
    }
 private static void HandleOrderNotification(ShoppingCartInfo shoppingCart)
 {
     if (ECommerceSettings.SendOrderNotification(shoppingCart.SiteName))
     {
         // Send order notification emails
         OrderInfoProvider.SendOrderNotificationToAdministrator(shoppingCart);
         OrderInfoProvider.SendOrderNotificationToCustomer(shoppingCart);
     }
 }
Beispiel #24
0
        private void Notify_Authenticated(object sender, AuthenticatedEventArgs e)
        {
            bool flag = false;

            if (this.hidToken != null)
            {
                this.hidToken.Value = Globals.StripAllTags(this.parameters["token"]);
            }
            if (this.hidUserId != null)
            {
                this.hidUserId.Value = Globals.StripAllTags(this.parameters["user_id"]);
            }
            if (this.hidEmail != null)
            {
                this.hidEmail.Value = Globals.StripAllTags(this.parameters["email"]);
            }
            string text = "";

            switch (this.openIdType.ToLower())
            {
            case "hishop.plugins.openid.alipay.alipayservice":
                text = (string.IsNullOrEmpty(this.parameters["real_name"]) ? string.Empty : this.parameters["real_name"].ToNullString().Trim());
                break;

            case "hishop.plugins.openid.qq.qqservice":
            {
                HttpCookie httpCookie3 = HttpContext.Current.Request.Cookies["NickName"];
                if (httpCookie3 != null)
                {
                    text = HttpUtility.UrlDecode(httpCookie3.Value).Trim();
                }
                break;
            }

            case "hishop.plugins.openid.taobao.taobaoservice":
            {
                HttpCookie httpCookie4 = HttpContext.Current.Request.Cookies["NickName"];
                if (httpCookie4 != null)
                {
                    text = HttpUtility.UrlDecode(httpCookie4.Value).Trim();
                }
                break;
            }

            case "hishop.plugins.openid.sina.sinaservice":
            {
                HttpCookie httpCookie2 = HttpContext.Current.Request.Cookies["SinaNickName"];
                if (httpCookie2 != null)
                {
                    text = HttpUtility.UrlDecode(httpCookie2.Value).Trim();
                }
                break;
            }

            case "hishop.plugins.openid.weixin.weixinservice":
            {
                HttpCookie httpCookie = HttpContext.Current.Request.Cookies["NickName"];
                if (text != null)
                {
                    text = HttpUtility.UrlDecode(httpCookie.Value).Trim();
                }
                break;
            }

            default:
                this.Page.Response.Redirect("/", true);
                break;
            }
            this.hidRealName.Value = text;
            this.labNickName.Text  = text;
            this.labNickName1.Text = text;
            this.labNickName2.Text = text;
            string text2 = this.Page.Request.QueryString["headimage"].ToNullString();

            if (string.IsNullOrEmpty(text2))
            {
                text2 = "/Templates/common/images/headerimg.png";
            }
            this.userPicture.Src = text2;
            this.parameters.Add("CurrentOpenId", e.OpenId);
            HiContext current = HiContext.Current;

            this.openId = e.OpenId;
            if (!string.IsNullOrEmpty(this.openId))
            {
                HttpCookie httpCookie5 = new HttpCookie("openId");
                httpCookie5.HttpOnly = true;
                httpCookie5.Value    = this.openId;
                httpCookie5.Expires  = DateTime.MaxValue;
                HttpContext.Current.Response.Cookies.Add(httpCookie5);
            }
            MemberInfo memberByOpenId = MemberProcessor.GetMemberByOpenId(this.openIdType, this.openId);

            if (memberByOpenId != null)
            {
                Users.SetCurrentUser(memberByOpenId.UserId, 1, true, false);
                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                current.User = memberByOpenId;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                if (!string.IsNullOrEmpty(this.parameters["token"]))
                {
                    HttpCookie httpCookie6 = new HttpCookie("Token_" + HiContext.Current.UserId.ToString());
                    httpCookie6.HttpOnly = true;
                    httpCookie6.Expires  = DateTime.Now.AddMinutes(30.0);
                    httpCookie6.Value    = Globals.StripAllTags(this.parameters["token"]);
                    HttpContext.Current.Response.Cookies.Add(httpCookie6);
                }
            }
            else
            {
                this.AuthMsg = "Auth_Sucess";
            }
        }
    private bool EnsureCustomerAddresses(ShoppingCartInfo shoppingCart)
    {
        // Billing
        if (shoppingCart.ShoppingCartBillingAddress != null)
        {
            shoppingCart.ShoppingCartBillingAddress = SaveAddress(shoppingCart.ShoppingCartBillingAddress, shoppingCart.Customer);

            if (shoppingCart.ShoppingCartBillingAddress.AddressID < 1)
            {
                LogError("Save billing address action failed", EVENT_CODE_SAVING);
                return false;
            }

            // Update current contact's address
            MapContactAddress(shoppingCart.ShoppingCartBillingAddress);
        }

        // Shipping
        if (shoppingCart.ShoppingCartShippingAddress != null)
        {
            shoppingCart.ShoppingCartShippingAddress = SaveAddress(shoppingCart.ShoppingCartShippingAddress, shoppingCart.Customer);

            if (shoppingCart.ShoppingCartShippingAddress.AddressID < 1)
            {
                LogError("Save shipping address action failed", EVENT_CODE_SAVING);
                return false;
            }
        }

        // Company
        if (shoppingCart.ShoppingCartCompanyAddress != null)
        {
            shoppingCart.ShoppingCartCompanyAddress = SaveAddress(shoppingCart.ShoppingCartCompanyAddress, shoppingCart.Customer);

            if (shoppingCart.ShoppingCartCompanyAddress.AddressID < 1)
            {
                LogError("Save company address action failed", EVENT_CODE_SAVING);
                return false;
            }
        }

        return true;
    }
Beispiel #26
0
        public static OrderInfo ConvertShoppingCartToOrder(ShoppingCartInfo shoppingCart, bool isCountDown, bool isSignBuy, bool isAgent)
        {
            if (shoppingCart.LineItems.Count == 0 && shoppingCart.LineGifts.Count == 0)
            {
                return(null);
            }
            OrderInfo info = new OrderInfo
            {
                Points                      = shoppingCart.GetPoint(),
                ReducedPromotionId          = shoppingCart.ReducedPromotionId,
                ReducedPromotionName        = shoppingCart.ReducedPromotionName,
                ReducedPromotionAmount      = shoppingCart.ReducedPromotionAmount,
                IsReduced                   = shoppingCart.IsReduced,
                SentTimesPointPromotionId   = shoppingCart.SentTimesPointPromotionId,
                SentTimesPointPromotionName = shoppingCart.SentTimesPointPromotionName,
                IsSendTimesPoint            = shoppingCart.IsSendTimesPoint,
                TimesPoint                  = shoppingCart.TimesPoint,
                FreightFreePromotionId      = shoppingCart.FreightFreePromotionId,
                FreightFreePromotionName    = shoppingCart.FreightFreePromotionName,
                IsFreightFree               = shoppingCart.IsFreightFree
            };
            string str = string.Empty;

            if (shoppingCart.LineItems.Count > 0)
            {
                foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems)
                {
                    str = str + string.Format("'{0}',", info2.SkuId);
                }
            }
            if (shoppingCart.LineItems.Count > 0)
            {
                foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems)
                {
                    decimal      costprice = new SkuDao().GetSkuItem(info2.SkuId).CostPrice;
                    LineItemInfo info3     = new LineItemInfo
                    {
                        SkuId             = info2.SkuId,
                        ProductId         = info2.ProductId,
                        SKU               = info2.SKU,
                        Quantity          = info2.Quantity,
                        ShipmentQuantity  = info2.ShippQuantity,
                        ItemCostPrice     = costprice,
                        ItemListPrice     = isAgent ? costprice : info2.MemberPrice,
                        ItemAdjustedPrice = isAgent ? costprice : info2.AdjustedPrice,
                        ItemDescription   = info2.Name,
                        ThumbnailsUrl     = info2.ThumbnailUrl40,
                        ItemWeight        = info2.Weight,
                        SKUContent        = info2.SkuContent,
                        PromotionId       = info2.PromotionId,
                        PromotionName     = info2.PromotionName,
                        MainCategoryPath  = info2.MainCategoryPath,
                        GiveQuantity      = info2.GiveQuantity,
                        HalfPriceQuantity = info2.HalfPriceQuantity
                    };
                    info.LineItems.Add(info3.SkuId, info3);
                }
            }
            //如果有礼品在购物车内,增加礼品到订单
            if (shoppingCart.LineGifts.Count > 0)
            {
                foreach (ShoppingCartGiftInfo info4 in shoppingCart.LineGifts)
                {
                    OrderGiftInfo item = new OrderGiftInfo
                    {
                        GiftId        = info4.GiftId,
                        GiftName      = info4.Name,
                        Quantity      = info4.Quantity,
                        ThumbnailsUrl = info4.ThumbnailUrl100,
                        CostPrice     = info4.CostPrice,
                        costPoint     = info4.NeedPoint * info4.Quantity
                    };
                    info.Gifts.Add(item);
                }
            }
            //如果当前订单内商品数量为零的话,则订单状态为已付款
            if ((info.GetTotal() == 0M) && (info.LineItems.Count == 0))
            {
                info.OrderStatus = OrderStatus.BuyerAlreadyPaid;
            }
            info.Tax          = 0.00M;
            info.InvoiceTitle = "";
            return(info);
        }
Beispiel #27
0
 public static bool Add(ShoppingCartInfo shoppingcartinfo)
 {
     return(dal.Add(shoppingcartinfo));
 }
Beispiel #28
0
        protected void RptShoppingCart_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            ShopConfig shopConfig = SiteConfig.ShopConfig;

            if ((e.Item.ItemType != ListItemType.Item) && (e.Item.ItemType != ListItemType.AlternatingItem))
            {
                goto Label_07BA;
            }
            int     productNum = 0;
            string  str        = "";
            string  str2       = "";
            decimal subTotal   = 0M;

            ((CheckBox)e.Item.FindControl("ChkProductId")).Checked = true;
            ShoppingCartInfo dataItem = e.Item.DataItem as ShoppingCartInfo;

            if (dataItem == null)
            {
                goto Label_07BA;
            }
            productNum = dataItem.Quantity;
            ((TextBox)e.Item.FindControl("TxtProductAmount")).Text = productNum.ToString();
            bool haveWholesalePurview = false;

            if (PEContext.Current.User.PurviewInfo != null)
            {
                haveWholesalePurview = PEContext.Current.User.PurviewInfo.Enablepm;
            }
            str2 = ShoppingCart.GetSaleType(dataItem.ProductInfomation, productNum, haveWholesalePurview);
            str  = ShoppingCart.GetProductType(dataItem.ProductInfomation, productNum, haveWholesalePurview);
            AbstractItemInfo info2 = new ConcreteProductInfo(productNum, dataItem.Property, dataItem.ProductInfomation, PEContext.Current.User.UserInfo, false, false, haveWholesalePurview);

            info2.GetItemInfo();
            subTotal    = info2.SubTotal;
            this.total += subTotal;
            if (!string.IsNullOrEmpty(dataItem.Property))
            {
                ((Literal)e.Item.FindControl("LitProperty")).Text = "(" + info2.Property + ")";
            }
            ProductInfo productById = Product.GetProductById(dataItem.ProductId);

            if (productById.Minimum > 0)
            {
                ((Literal)e.Item.FindControl("LblMark")).Text = "(<font color=\"red\">最低购买量" + productById.Minimum.ToString() + "</font>)";
            }
            InsideStaticLabel label = new InsideStaticLabel();
            string            str3  = "<a href='";

            str3 = (str3 + label.GetInfoPath(info2.ProductId.ToString())) + "' Target='_blank'>" + info2.ProductName + "</a>";
            ((Literal)e.Item.FindControl("LitProductName")).Text = str3;
            ((Literal)e.Item.FindControl("LitProductUnit")).Text = info2.Unit;
            ((Literal)e.Item.FindControl("LitTruePrice")).Text   = info2.Price.ToString("0.00");
            ((Literal)e.Item.FindControl("LitSubTotal")).Text    = subTotal.ToString("0.00");
            ExtendedImage image    = (ExtendedImage)e.Item.FindControl("extendedImage");
            ExtendedImage image2   = (ExtendedImage)e.Item.FindControl("extendedPresentImage");
            Control       control  = e.Item.FindControl("ProductImage");
            Control       control2 = e.Item.FindControl("presentImage");

            if (!shopConfig.IsGwcShowProducdtThumb)
            {
                image.Visible    = false;
                control.Visible  = false;
                control2.Visible = false;
            }
            else
            {
                if (!string.IsNullOrEmpty(dataItem.ProductInfomation.ProductThumb))
                {
                    image.Src = dataItem.ProductInfomation.ProductThumb;
                }
                else
                {
                    image.Src = SiteConfig.SiteInfo.VirtualPath + "Images/nopic.gif";
                }
                image.ImageHeight = shopConfig.GwcThumbsHeight;
                image.ImageWidth  = shopConfig.GwcThumbsWidth;
                if (dataItem.ProductInfomation.PresentId > 0)
                {
                    PresentInfo presentById = Present.GetPresentById(dataItem.ProductInfomation.PresentId);
                    if (!string.IsNullOrEmpty(presentById.PresentThumb))
                    {
                        image2.Src = presentById.PresentThumb;
                    }
                    else
                    {
                        image2.Src = SiteConfig.SiteInfo.VirtualPath + "Images/nopic.gif";
                    }
                    image2.ImageHeight = shopConfig.GwcThumbsHeight;
                    image2.ImageWidth  = shopConfig.GwcThumbsWidth;
                }
            }
            if (!shopConfig.IsShowGwcProductType)
            {
                e.Item.FindControl("tdProductType").Visible = false;
            }
            else
            {
                ((Literal)e.Item.FindControl("LitProductType")).Text = str;
            }
            if (!shopConfig.IsShowGwcSaleType)
            {
                e.Item.FindControl("tdSaleType").Visible = false;
            }
            else
            {
                ((Literal)e.Item.FindControl("LitSaleType")).Text = str2;
            }
            if (!shopConfig.IsShowGwcMarkPrice)
            {
                e.Item.FindControl("tdMarkPrice").Visible = false;
            }
            else
            {
                ((Literal)e.Item.FindControl("LitPriceMarket")).Text = info2.PriceMarket.ToString("0.00");
            }
            if (((dataItem.ProductInfomation.SalePromotionType <= 0) || (productNum < dataItem.ProductInfomation.MinNumber)) || dataItem.IsPresent)
            {
                goto Label_07BA;
            }
            e.Item.FindControl("PresentInfomation").Visible = true;
            string           str4      = "";
            string           str5      = "";
            string           str6      = "";
            int              productId = 0;
            AbstractItemInfo info5     = new ConcreteSalePromotionType(productNum, dataItem.ProductInfomation, false, null);

            info5.GetItemInfo();
            switch (dataItem.ProductInfomation.SalePromotionType)
            {
            case 1:
            case 3:
                str5      = "<font color=red>(赠品)</font>";
                str4      = "赠送礼品";
                str6      = "赠送";
                productId = info5.Id;
                goto Label_05B2;

            case 2:
            case 4:
                if (info5.Price <= 0M)
                {
                    str5 = "<font color=red>(赠送赠品)</font>";
                    str6 = "赠送";
                    break;
                }
                str5 = "<font color=red>(换购赠品)</font>";
                str6 = "换购";
                break;

            default:
                goto Label_05B2;
            }
            str4      = "促销礼品";
            productId = info5.Id;
Label_05B2:
            ((HiddenField)e.Item.FindControl("HdnPresentId")).Value   = productId.ToString();
            ((Literal)e.Item.FindControl("LitPresentName")).Text      = info5.ProductName + str5;
            ((Literal)e.Item.FindControl("LitPresentUnit")).Text      = info5.Unit;
            ((Literal)e.Item.FindControl("LitPresentNum")).Text       = info5.Amount.ToString();
            ((Literal)e.Item.FindControl("LitPresentTruePrice")).Text = info5.Price.ToString("0.00");
            ((Literal)e.Item.FindControl("LitPresentSubtotal")).Text  = info5.SubTotal.ToString("0.00");
            if (this.PresentExist(this.cartId, productId))
            {
                ((CheckBox)e.Item.FindControl("ChkPresentId")).Checked = true;
                this.total += info5.SubTotal;
            }
            if (!shopConfig.IsShowGwcProductType)
            {
                e.Item.FindControl("tdPresentType").Visible = false;
            }
            else
            {
                ((Literal)e.Item.FindControl("LitPresentType")).Text = str4;
            }
            if (!shopConfig.IsShowGwcSaleType)
            {
                e.Item.FindControl("tdPresentSaleType").Visible = false;
            }
            else
            {
                ((Literal)e.Item.FindControl("LitPresentSaleType")).Text = str6;
            }
            if (!shopConfig.IsShowGwcMarkPrice)
            {
                e.Item.FindControl("tdPresentMarkPrice").Visible = false;
            }
            else
            {
                ((Literal)e.Item.FindControl("LitPresentPriceMarket")).Text = info5.PriceMarket.ToString("0.00");
            }
Label_07BA:
            if (e.Item.ItemType == ListItemType.Header)
            {
                Control control9  = e.Item.FindControl("ProductImageTitle");
                Control control10 = e.Item.FindControl("tdProductTypeTitle");
                Control control11 = e.Item.FindControl("tdSaleTypeTitle");
                Control control12 = e.Item.FindControl("tdMarkPriceTitle");
                if (!shopConfig.IsGwcShowProducdtThumb)
                {
                    control9.Visible = false;
                }
                if (!shopConfig.IsShowGwcProductType)
                {
                    control10.Visible = false;
                }
                if (!shopConfig.IsShowGwcSaleType)
                {
                    control11.Visible = false;
                }
                if (!shopConfig.IsShowGwcMarkPrice)
                {
                    control12.Visible = false;
                }
            }
            if (e.Item.ItemType == ListItemType.Footer)
            {
                Control control13 = e.Item.FindControl("footerTdThemeImage");
                Control control14 = e.Item.FindControl("footerTdProductType");
                Control control15 = e.Item.FindControl("footerTdSaleType");
                Control control16 = e.Item.FindControl("footerTdMarkPrice");
                if (!shopConfig.IsGwcShowProducdtThumb)
                {
                    control13.Visible = false;
                }
                if (!shopConfig.IsShowGwcProductType)
                {
                    control14.Visible = false;
                }
                if (!shopConfig.IsShowGwcSaleType)
                {
                    control15.Visible = false;
                }
                if (!shopConfig.IsShowGwcMarkPrice)
                {
                    control16.Visible = false;
                }
            }
        }
        /// <summary>
        /// Returns sum of all units of the specified SKU in the shopping cart. 
        /// </summary>
        /// <param name="skuId">SKU ID.</param>        
        private static int GetSKUShoppingCartUnits(ShoppingCartInfo cart, int skuId)
        {
            if (cart == null)
            {
                return 0;
            }
            
            int result = 0;

            // Calculate units
            foreach (ShoppingCartItemInfo cartItem in cart.CartItems)
            {
                if (cartItem.SKUID == skuId)
                {
                    // Add units
                    result += cartItem.CartItemUnits;
                }
            }

            return result;
        }
Beispiel #30
0
 protected override void OnInit(System.EventArgs eventArgs_0)
 {
     if (int.TryParse(this.Page.Request.QueryString["buyAmount"], out this.buyAmount) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"]) && !string.IsNullOrEmpty(this.Page.Request.QueryString["from"]) && this.Page.Request.QueryString["from"] == "groupBuy")
     {
         this.productSku   = this.Page.Request.QueryString["productSku"];
         this.isGroupBuy   = true;
         this.shoppingCart = ShoppingCartProcessor.GetGroupBuyShoppingCart(this.productSku, this.buyAmount);
         this.buytype      = "GroupBuy";
     }
     else
     {
         if (int.TryParse(this.Page.Request.QueryString["buyAmount"], out this.buyAmount) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"]) && !string.IsNullOrEmpty(this.Page.Request.QueryString["from"]) && this.Page.Request.QueryString["from"] == "countDown")
         {
             this.productSku   = this.Page.Request.QueryString["productSku"];
             this.isCountDown  = true;
             this.shoppingCart = ShoppingCartProcessor.GetCountDownShoppingCart(this.productSku, this.buyAmount);
             this.buytype      = "CountDown";
         }
         else
         {
             if (int.TryParse(this.Page.Request.QueryString["buyAmount"], out this.buyAmount) && !string.IsNullOrEmpty(this.Page.Request.QueryString["productSku"]) && !string.IsNullOrEmpty(this.Page.Request.QueryString["from"]) && this.Page.Request.QueryString["from"] == "signBuy")
             {
                 this.productSku   = this.Page.Request.QueryString["productSku"];
                 this.isSignBuy    = true;
                 this.shoppingCart = ShoppingCartProcessor.GetShoppingCart(this.productSku, this.buyAmount);
             }
             else
             {
                 if (int.TryParse(this.Page.Request.QueryString["buyAmount"], out this.buyAmount) && !string.IsNullOrEmpty(this.Page.Request.QueryString["Bundlingid"]) && !string.IsNullOrEmpty(this.Page.Request.QueryString["from"]) && this.Page.Request.QueryString["from"] == "Bundling")
                 {
                     this.productSku = this.Page.Request.QueryString["Bundlingid"];
                     if (int.TryParse(this.productSku, out this.bundlingid))
                     {
                         this.shoppingCart = ShoppingCartProcessor.GetShoppingCart(this.bundlingid, this.buyAmount);
                         this.isBundling   = true;
                         this.buytype      = "Bundling";
                     }
                 }
                 else
                 {
                     this.shoppingCart = ShoppingCartProcessor.GetShoppingCart();
                     if (this.shoppingCart != null && this.shoppingCart.GetQuantity() == 0)
                     {
                         this.buytype = "0";
                     }
                 }
             }
         }
     }
     if (this.shoppingCart == null)
     {
         this.Page.Response.Redirect(Globals.ApplicationPath + "/ResourceNotFound.aspx?errorMsg=" + Globals.UrlEncode("该件商品已经被管理员删除"));
     }
     else
     {
         if (this.SkinName == null)
         {
             this.SkinName = "Skin-SubmmitOrder.html";
         }
         base.OnInit(eventArgs_0);
     }
 }
Beispiel #31
0
        public static OrderInfo ConvertShoppingCartToOrder(ShoppingCartInfo shoppingCart, bool isGroupBuy, bool isCountDown, bool isSignBuy)
        {
            if ((shoppingCart.LineItems.Count == 0) && (shoppingCart.LineGifts.Count == 0))
            {
                return(null);
            }
            OrderInfo info = new OrderInfo();

            info.Points                      = shoppingCart.GetPoint();
            info.ReducedPromotionId          = shoppingCart.ReducedPromotionId;
            info.ReducedPromotionName        = shoppingCart.ReducedPromotionName;
            info.ReducedPromotionAmount      = shoppingCart.ReducedPromotionAmount;
            info.IsReduced                   = shoppingCart.IsReduced;
            info.SentTimesPointPromotionId   = shoppingCart.SentTimesPointPromotionId;
            info.SentTimesPointPromotionName = shoppingCart.SentTimesPointPromotionName;
            info.IsSendTimesPoint            = shoppingCart.IsSendTimesPoint;
            info.TimesPoint                  = shoppingCart.TimesPoint;
            info.FreightFreePromotionId      = shoppingCart.FreightFreePromotionId;
            info.FreightFreePromotionName    = shoppingCart.FreightFreePromotionName;
            info.IsFreightFree               = shoppingCart.IsFreightFree;
            string str = string.Empty;

            if (shoppingCart.LineItems.Values.Count > 0)
            {
                foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems.Values)
                {
                    str = str + string.Format("'{0}',", info2.SkuId);
                }
            }
            Dictionary <string, decimal> costPriceForItems = new Dictionary <string, decimal>();

            if (!string.IsNullOrEmpty(str))
            {
                str = str.Substring(0, str.Length - 1);
                costPriceForItems = ShoppingProvider.Instance().GetCostPriceForItems(str);
            }
            if (shoppingCart.LineItems.Values.Count > 0)
            {
                foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems.Values)
                {
                    decimal costPrice = 0M;
                    if ((isGroupBuy || isCountDown) || isSignBuy)
                    {
                        costPrice = ShoppingProvider.Instance().GetCostPrice(info2.SkuId);
                    }
                    else if (costPriceForItems.ContainsKey(info2.SkuId))
                    {
                        costPrice = costPriceForItems[info2.SkuId];
                    }
                    LineItemInfo info3 = new LineItemInfo();
                    info3.SkuId             = info2.SkuId;
                    info3.ProductId         = info2.ProductId;
                    info3.SKU               = info2.SKU;
                    info3.Quantity          = info2.Quantity;
                    info3.ShipmentQuantity  = info2.ShippQuantity;
                    info3.ItemCostPrice     = costPrice;
                    info3.ItemListPrice     = info2.MemberPrice;
                    info3.ItemAdjustedPrice = info2.AdjustedPrice;
                    info3.ItemDescription   = info2.Name;
                    info3.ThumbnailsUrl     = info2.ThumbnailUrl40;
                    info3.ItemWeight        = info2.Weight;
                    info3.SKUContent        = info2.SkuContent;
                    info3.PromotionId       = info2.PromotionId;
                    info3.PromotionName     = info2.PromotionName;
                    info.LineItems.Add(info3.SkuId, info3);
                }
            }
            info.Tax          = 0.00M;
            info.InvoiceTitle = "";
            if (shoppingCart.LineGifts.Count > 0)
            {
                foreach (ShoppingCartGiftInfo info4 in shoppingCart.LineGifts)
                {
                    OrderGiftInfo item = new OrderGiftInfo();
                    item.GiftId        = info4.GiftId;
                    item.GiftName      = info4.Name;
                    item.Quantity      = info4.Quantity;
                    item.ThumbnailsUrl = info4.ThumbnailUrl40;
                    item.PromoteType   = info4.PromoType;
                    if (HiContext.Current.SiteSettings.IsDistributorSettings)
                    {
                        item.CostPrice = info4.PurchasePrice;
                    }
                    else
                    {
                        item.CostPrice = info4.CostPrice;
                    }
                    info.Gifts.Add(item);
                }
            }
            return(info);
        }
    /// <summary>
    /// Returns shopping cart item with specified SKU number.
    /// </summary>
    /// <param name="cart">Shopping cart</param>
    /// <param name="skuNumber">Shopping cart item SKU number</param>    
    private ShoppingCartItemInfo GetShoppingCartItem(ShoppingCartInfo cart, string skuNumber)
    {
        // Cart not found
        if (cart == null)
        {
            return null;
        }

        skuNumber = skuNumber.ToLower();

        // Try to find item with specifid SKU number
        foreach (ShoppingCartItemInfo item in cart.CartItems)
        {
            if (item.SKUObj.SKUNumber.ToLower() == skuNumber)
            {
                // Item found
                return item;
            }
        }

        // Item not found
        return null;
    }
Beispiel #33
0
 /// <summary>
 /// On prerender.
 /// </summary>
 protected override void OnPreRender(EventArgs e)
 {
     ShoppingCart = Cart.LocalShoppingCart;
     base.OnPreRender(e);
 }
Beispiel #34
0
        private void BindShoppingCart()
        {
            ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart();

            if (shoppingCart == null)
            {
                this.pnlShopCart.Visible  = false;
                this.pnlNoProduct.Visible = true;
                ShoppingCartProcessor.ClearShoppingCart();
                return;
            }
            this.pnlShopCart.Visible  = true;
            this.pnlNoProduct.Visible = false;
            if (shoppingCart.LineItems.Count > 0)
            {
                decimal tax = shoppingCart.CalTotalTax();
                if (tax <= 50)
                {
                    this.lblTax.Text = string.Format("商品关税:<span style='text-decoration: line-through;'>{0}</span>", tax.ToString("F2"));
                }
                else
                {
                    this.lblTax.Text = string.Format("商品关税:{0}", tax.ToString("F2"));
                }
                //this.lblTax.Text = string.Format("商品关税:{0}", tax <50 ? "0.00" : tax.ToString("F2"));
                //foreach (ShoppingCartItemInfo item in shoppingCart.LineItems)
                //{
                //    item.TaxRate = Math.Round(item.TaxRate * 100, 0);
                //}

                decimal activityReduct = shoppingCart.GetActivityPrice();
                this.lblReducedActivity.Text = string.Format("活动优惠:{0}", activityReduct == 0 ? "0.00" : activityReduct.ToString("F2"));

                this.lblTotalPrice.Money = shoppingCart.GetNewTotalIncludeTax();

                var query = from q in shoppingCart.LineItems
                            group q by new { id = q.SupplierId }
                into g
                    select new
                {
                    SupplierId     = g.FirstOrDefault().SupplierId,
                    SupplierName   = g.FirstOrDefault().SupplierName,
                    Logo           = g.FirstOrDefault().Logo,
                    ProductId      = g.FirstOrDefault().ProductId,
                    SkuId          = g.FirstOrDefault().SkuId,
                    Name           = g.FirstOrDefault().Name,
                    ThumbnailUrl60 = g.FirstOrDefault().ThumbnailUrl60,
                    TaxRate        = g.FirstOrDefault().TaxRate,
                    MemberPrice    = g.FirstOrDefault().MemberPrice,
                    Quantity       = g.FirstOrDefault().Quantity,
                    SKU            = g.FirstOrDefault().SKU,
                    ShippQuantity  = g.FirstOrDefault().ShippQuantity,
                    PromotionId    = g.FirstOrDefault().PromotionId,
                    PromotionName  = g.FirstOrDefault().PromotionName,
                    SubNewTotal    = g.FirstOrDefault().SubNewTotal,
                    NewTaxRate     = GetNewTaxRate(g.FirstOrDefault().TaxRate, g.FirstOrDefault().MinTaxRate, g.FirstOrDefault().MaxTaxRate)
                                     //itemInfo  = g.FirstOrDefault()
                };
                this.shoppingCartProductList.DataSource = query;
                this.shoppingCartProductList.DataBind();
                this.shoppingCartProductList.ShowProductCart();
            }
            if (shoppingCart.LineGifts.Count > 0)
            {
                System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable =
                    from s in shoppingCart.LineGifts
                    where s.PromoType == 0
                    select s;
                System.Collections.Generic.IEnumerable <ShoppingCartGiftInfo> enumerable2 =
                    from s in shoppingCart.LineGifts
                    where s.PromoType == 5
                    select s;
                this.shoppingCartGiftList.DataSource     = enumerable;
                this.shoppingCartGiftList.FreeDataSource = enumerable2;
                this.shoppingCartGiftList.DataBind();
                this.shoppingCartGiftList.ShowGiftCart(enumerable.Count <ShoppingCartGiftInfo>() > 0, enumerable2.Count <ShoppingCartGiftInfo>() > 0);
            }
            if (shoppingCart.IsSendGift)
            {
                int num = 1;
                int giftItemQuantity = ShoppingCartProcessor.GetGiftItemQuantity(PromoteType.SentGift);
                System.Collections.Generic.IList <GiftInfo> onlinePromotionGifts = ProductBrowser.GetOnlinePromotionGifts();
                if (onlinePromotionGifts != null && onlinePromotionGifts.Count > 0)
                {
                    this.shoppingCartPromoGiftList.DataSource = onlinePromotionGifts;
                    this.shoppingCartPromoGiftList.DataBind();
                    this.shoppingCartPromoGiftList.ShowPromoGift(num - giftItemQuantity, num);
                }
            }

            //if (shoppingCart.IsReduced)
            //{
            this.lblAmoutPrice.Text       = string.Format("商品金额:{0}", shoppingCart.GetNewAmount().ToString("F2"));
            this.hlkReducedPromotion.Text = shoppingCart.ReducedPromotionName + string.Format(" 优惠:{0}", shoppingCart.ReducedPromotionAmount.ToString("F2"));
            if (shoppingCart.ReducedPromotionId != 0)
            {
                this.hlkReducedPromotion.NavigateUrl = Globals.GetSiteUrls().UrlData.FormatUrl("FavourableDetails", new object[]
                {
                    shoppingCart.ReducedPromotionId
                });
            }
            //}

            HttpCookie cookieSkuIds = this.Page.Request.Cookies["UserSession-SkuIds"];

            if (cookieSkuIds != null)
            {
                //cookieSkuIds.Expires = DateTime.Now.AddDays(-1);
                this.Page.Response.AppendCookie(cookieSkuIds);
            }
        }
        public IList <ShoppingCartInfo> GetList(int startRowIndexId, int maxNumberRows, int searchType, string keyword)
        {
            Database database             = DatabaseFactory.CreateDatabase();
            IList <ShoppingCartInfo> list = new List <ShoppingCartInfo>();
            DbCommand storedProcCommand   = null;

            if (searchType == 4)
            {
                storedProcCommand = database.GetStoredProcCommand("PR_Common_GetList");
                database.AddInParameter(storedProcCommand, "@SortColumn", DbType.String, "CartItemID");
                database.AddInParameter(storedProcCommand, "@StrColumn", DbType.String, "C.*, P.*");
            }
            else
            {
                storedProcCommand = database.GetStoredProcCommand("PR_Shop_ShoppingCart_GetList");
                database.AddInParameter(storedProcCommand, "@SortColumn", DbType.String, "CartID");
                database.AddInParameter(storedProcCommand, "@SortColumnDbType", DbType.String, "varchar(100)");
                database.AddInParameter(storedProcCommand, "@StrColumn", DbType.String, "CartID, SUM(C.Quantity * P.Price) AS TotalMoney, SUM(Quantity) AS Quantity, Max(UserName) AS UserName, Max(UpdateTime) AS UpdateTime, Max(C.InformResult) AS InformResult");
            }
            database.AddInParameter(storedProcCommand, "@StartRows", DbType.Int32, startRowIndexId);
            database.AddInParameter(storedProcCommand, "@PageSize", DbType.Int32, maxNumberRows);
            database.AddInParameter(storedProcCommand, "@Sorts", DbType.String, "DESC");
            database.AddInParameter(storedProcCommand, "@Filter", DbType.String);
            switch (searchType)
            {
            case 0:
                database.SetParameterValue(storedProcCommand, "@Filter", "");
                break;

            case 1:
                database.SetParameterValue(storedProcCommand, "@Filter", "DATEDIFF(dd, UpdateTime, GETDATE()) < 1");
                break;

            case 2:
                database.SetParameterValue(storedProcCommand, "@Filter", "DATEDIFF(ww, UpdateTime, GETDATE()) < 1");
                break;

            case 3:
                database.SetParameterValue(storedProcCommand, "@Filter", "DATEDIFF(m, UpdateTime, GETDATE()) < 1");
                break;

            case 4:
                database.SetParameterValue(storedProcCommand, "@Filter", "CartID = '" + DBHelper.FilterBadChar(keyword) + "' AND C.IsPresent = 0");
                break;

            case 10:
                database.SetParameterValue(storedProcCommand, "@Filter", "UserName IS NOT NULL AND UserName!=''");
                break;
            }
            database.AddInParameter(storedProcCommand, "@TableName", DbType.String, "PE_ShoppingCarts C INNER JOIN PE_CommonProduct P ON C.ProductID = P.ProductID AND C.TableName = P.TableName");
            database.AddOutParameter(storedProcCommand, "@Total", DbType.Int32, maxNumberRows);
            using (NullableDataReader reader = new NullableDataReader(database.ExecuteReader(storedProcCommand)))
            {
                while (reader.Read())
                {
                    if (searchType != 4)
                    {
                        ShoppingCartInfo item = new ShoppingCartInfo();
                        item.CartId       = reader.GetString("CartId");
                        item.UserName     = reader.GetString("UserName");
                        item.Quantity     = reader.GetInt32("Quantity");
                        item.UpdateTime   = reader.GetDateTime("UpdateTime");
                        item.TotalMoney   = reader.GetDecimal("TotalMoney");
                        item.InformResult = reader.GetInt32("InformResult");
                        list.Add(item);
                    }
                    else
                    {
                        list.Add(ShoppingCartFromrdr(reader, true));
                    }
                }
            }
            this.m_TotalOfShoppingCart = (int)database.GetParameterValue(storedProcCommand, "@Total");
            return(list);
        }
Beispiel #36
0
        private void CheckBuyCardinality(System.Web.HttpContext context)
        {
            var unselectedProductId       = context.Request["productIds"];
            ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart();

            if (shoppingCart.LineItems.Count == 0)
            {
                return;
            }
            List <object> result = new List <object>();

            if (!string.IsNullOrEmpty(unselectedProductId))
            {
                string[] pid_skuids = unselectedProductId.Split(',');
                foreach (var s in pid_skuids)
                {
                    int    productId = int.Parse(s.Split('|')[0]);
                    string skuId     = s.Split('|')[1];
                    var    item      = shoppingCart.LineItems.FirstOrDefault(p => p.ProductId == productId && p.SkuId == skuId);
                    if (item != null)
                    {
                        shoppingCart.LineItems.Remove(item);
                    }
                }
            }
            var checkProduct = context.Request["checkProducts"];

            if (!string.IsNullOrEmpty(checkProduct))
            {
                //检查商品是否超过限购数量
                Member   member     = HiContext.Current.User as Member;
                string[] pid_skuids = checkProduct.Split(',');
                foreach (var s in pid_skuids)
                {
                    int    productId = int.Parse(s.Split('|')[0]);
                    string skuId     = s.Split('|')[1];
                    var    item      = shoppingCart.LineItems.FirstOrDefault(p => p.ProductId == productId && p.SkuId == skuId);
                    if (member != null)
                    {
                        int MaxCount = 0;
                        int count    = ProductHelper.CheckPurchaseCount(skuId, member.UserId, out MaxCount);
                        if ((count + item.Quantity) > MaxCount && MaxCount != 0) //当前购买数量大于限购剩余购买数量
                        {
                            result.Add(new { ProductId = item.ProductId, BuyCardinality = ((MaxCount - count) < 0 ? 0 : MaxCount - count), ProductName = item.Name, Quantity = item.Quantity, Purchase = "1" });
                        }
                    }
                }
            }
            if (result.Count > 0)
            {
                context.Response.ContentType = "application/json";
                context.Response.Write(JsonConvert.SerializeObject(result));
                return;
            }
            var productIds = shoppingCart.LineItems.Select(p => p.ProductId).Distinct();

            if (productIds.Count() <= 0)
            {
                return;
            }

            Dictionary <int, int> dict = new EcShop.SqlDal.Commodities.ProductDao().GetBuyCardinality(productIds.ToArray());

            if (dict == null || dict.Count == 0)
            {
                return;
            }


            foreach (KeyValuePair <int, int> item in dict)
            {
                string productName = shoppingCart.LineItems.First(p => p.ProductId == item.Key).Name;
                int    quantity    = shoppingCart.LineItems.Where(p => p.ProductId == item.Key).Sum(p => p.Quantity);
                if (quantity >= item.Value)
                {
                    continue;
                }

                result.Add(new { ProductId = item.Key, BuyCardinality = item.Value, ProductName = productName, Quantity = quantity, Purchase = "0" });
            }

            context.Response.ContentType = "application/json";
            context.Response.Write(JsonConvert.SerializeObject(result));
        }
Beispiel #37
0
        public static ShoppingCartInfo GetCountDownShoppingCart(Member member, string productSkuId, int buyAmount, int storeId)
        {
            ShoppingCartInfo     shoppingCartInfo = new ShoppingCartInfo();
            ShoppingCartItemInfo cartItemInfo     = new ShoppingCartDao().GetCartItemInfo(member, productSkuId, buyAmount, storeId);
            ShoppingCartInfo     result;

            if (cartItemInfo == null)
            {
                result = null;
            }
            else
            {
                CountDownInfo countDownInfo = ProductBrowser.GetCountDownInfo(cartItemInfo.ProductId);

                if (countDownInfo == null)
                {
                    result = null;
                }
                else
                {
                    ShoppingCartItemInfo shoppingCartItemInfo = new ShoppingCartItemInfo();
                    shoppingCartItemInfo.SkuId       = cartItemInfo.SkuId;
                    shoppingCartItemInfo.ProductId   = cartItemInfo.ProductId;
                    shoppingCartItemInfo.SKU         = cartItemInfo.SKU;
                    shoppingCartItemInfo.Name        = cartItemInfo.Name;
                    shoppingCartItemInfo.MemberPrice = (shoppingCartItemInfo.AdjustedPrice = countDownInfo.CountDownPrice);
                    shoppingCartItemInfo.SkuContent  = cartItemInfo.SkuContent;

                    //修改数量
                    shoppingCartItemInfo.ShippQuantity   = buyAmount;
                    shoppingCartItemInfo.Quantity        = buyAmount;
                    shoppingCartItemInfo.Weight          = cartItemInfo.Weight;
                    shoppingCartItemInfo.ThumbnailUrl40  = cartItemInfo.ThumbnailUrl40;
                    shoppingCartItemInfo.ThumbnailUrl60  = cartItemInfo.ThumbnailUrl60;
                    shoppingCartItemInfo.ThumbnailUrl100 = cartItemInfo.ThumbnailUrl100;
                    shoppingCartItemInfo.IsfreeShipping  = cartItemInfo.IsfreeShipping;
                    shoppingCartItemInfo.TaxRate         = cartItemInfo.TaxRate;
                    shoppingCartItemInfo.MaxTaxRate      = cartItemInfo.MaxTaxRate;
                    shoppingCartItemInfo.MinTaxRate      = cartItemInfo.MinTaxRate;
                    shoppingCartItemInfo.TemplateId      = cartItemInfo.TemplateId;

                    if (cartItemInfo != null && cartItemInfo.CombinationItemInfos != null &&
                        cartItemInfo.CombinationItemInfos.Count > 0)
                    {
                        shoppingCartItemInfo.CombinationItemInfos = cartItemInfo.CombinationItemInfos;
                    }

                    shoppingCartInfo.LineItems.Add(shoppingCartItemInfo);

                    //订单满额包邮
                    PromotionInfo sendPromotion3 = new PromotionDao().GetSendPromotion(member, (countDownInfo.CountDownPrice) * buyAmount, PromoteType.FullAmountSentFreight);
                    if (sendPromotion3 != null)
                    {
                        shoppingCartInfo.FreightFreePromotionId   = sendPromotion3.ActivityId;
                        shoppingCartInfo.FreightFreePromotionName = sendPromotion3.Name;
                        shoppingCartInfo.IsFreightFree            = true;
                    }



                    result = shoppingCartInfo;
                }
            }
            return(result);
        }
Beispiel #38
0
 protected override bool IsPaymentOptionApplicableInternal(ShoppingCartInfo cart, PaymentOptionInfo paymentOption)
 {
     return(paymentOption.PaymentOptionID != PAYMENT_METHOD_NOT_APPLICABLE_ID);
 }
Beispiel #39
0
 private ShoppingCartInfo GetShoppingCart(HttpContext context, User userBuyer, out ShoppingCartHelper shoppingCartHelper)
 {
     ShoppingCartInfo cartInfo = null;
     string str = context.Request.Form["SkuInfos"];
     if (string.IsNullOrWhiteSpace(str))
     {
         shoppingCartHelper = new ShoppingCartHelper(userBuyer.UserID);
         cartInfo = shoppingCartHelper.GetShoppingCart();
     }
     else
     {
         JsonArray array;
         shoppingCartHelper = null;
         try
         {
             array = JsonConvert.Import<JsonArray>(str);
         }
         catch (Exception)
         {
             throw;
         }
         if ((array == null) || (array.Length < 1))
         {
             return null;
         }
         JsonObject obj2 = array.GetObject(0);
         string sku = obj2["SKU"].ToString();
         int num = Globals.SafeInt(obj2["Count"].ToString(), 1);
         int id = Globals.SafeInt(obj2["ProSales"].ToString(), -1);
         Maticsoft.Model.Shop.Products.SKUInfo modelBySKU = this._skuInfoManage.GetModelBySKU(sku);
         if (modelBySKU == null)
         {
             return null;
         }
         Maticsoft.Model.Shop.Products.ProductInfo model = this._productInfoManage.GetModel(modelBySKU.ProductId);
         if (model == null)
         {
             return null;
         }
         ShoppingCartItem itemInfo = new ShoppingCartItem {
             MarketPrice = model.MarketPrice.HasValue ? model.MarketPrice.Value : 0M,
             Name = model.ProductName,
             Quantity = num,
             SellPrice = modelBySKU.SalePrice,
             AdjustedPrice = modelBySKU.SalePrice,
             SKU = modelBySKU.SKU,
             ProductId = modelBySKU.ProductId,
             UserId = userBuyer.UserID
         };
         if (id > 0)
         {
             Maticsoft.Model.Shop.Products.ProductInfo proSaleModel = this._productInfoManage.GetProSaleModel(id);
             if (proSaleModel == null)
             {
                 return null;
             }
             if (DateTime.Now > proSaleModel.ProSalesEndDate)
             {
                 throw new ArgumentNullException("活动已过期");
             }
             itemInfo.AdjustedPrice = proSaleModel.ProSalesPrice;
         }
         List<Maticsoft.Model.Shop.Products.SKUItem> sKUItemsBySkuId = this._skuInfoManage.GetSKUItemsBySkuId(modelBySKU.SkuId);
         if ((sKUItemsBySkuId != null) && (sKUItemsBySkuId.Count > 0))
         {
             itemInfo.SkuValues = new string[sKUItemsBySkuId.Count];
             int index = 0;
             sKUItemsBySkuId.ForEach(delegate (Maticsoft.Model.Shop.Products.SKUItem xx) {
                 itemInfo.SkuValues[index++] = xx.ValueStr;
                 if (!string.IsNullOrWhiteSpace(xx.ImageUrl))
                 {
                     itemInfo.SkuImageUrl = xx.ImageUrl;
                 }
             });
         }
         itemInfo.ThumbnailsUrl = model.ThumbnailUrl1;
         itemInfo.CostPrice = modelBySKU.CostPrice.HasValue ? modelBySKU.CostPrice.Value : 0M;
         itemInfo.Weight = modelBySKU.Weight.HasValue ? modelBySKU.Weight.Value : 0;
         Maticsoft.Model.Shop.Supplier.SupplierInfo modelByCache = new Maticsoft.BLL.Shop.Supplier.SupplierInfo().GetModelByCache(model.SupplierId);
         if (modelByCache != null)
         {
             itemInfo.SupplierId = new int?(modelByCache.SupplierId);
             itemInfo.SupplierName = modelByCache.Name;
         }
         cartInfo = new ShoppingCartInfo();
         cartInfo.Items.Add(itemInfo);
     }
     try
     {
         cartInfo = new SalesRuleProduct().GetWholeSale(cartInfo);
     }
     catch (Exception)
     {
         return null;
     }
     return cartInfo;
 }
        private void GenerateEcommerceData(int siteID)
        {
            var siteName     = SiteInfoProvider.GetSiteName(siteID);
            var currencyInfo = CurrencyInfoProvider.GetCurrencies(siteID)
                               .Where("CurrencyIsMain", QueryOperator.Equals, 1).TopN(1).FirstOrDefault();
            var list1 = PaymentOptionInfoProvider.GetPaymentOptions(siteID).ToList();
            var list2 = ShippingOptionInfoProvider.GetShippingOptions(siteID).ToList();

            var orderStatusList = OrderStatusInfoProvider.GetOrderStatuses(siteID).ToDictionary(status => status.StatusName);

            var manufacturerExceptionList = new List <int>
            {
                ManufacturerInfoProvider.GetManufacturerInfo("Aerobie", siteName).ManufacturerID,
                //ManufacturerInfoProvider.GetManufacturerInfo("Chemex", siteName).ManufacturerID,
                //ManufacturerInfoProvider.GetManufacturerInfo("Espro", siteName).ManufacturerID
            };
            var list3 = SKUInfoProvider.GetSKUs(siteID).ToList().Where(sku =>
            {
                if (sku.IsProduct)
                {
                    return(!manufacturerExceptionList.Contains(sku.SKUManufacturerID));
                }
                return(false);
            }).ToList();
            int         num1;
            IList <int> intList;

            if (CustomerInfoProvider.GetCustomers().WhereEquals("CustomerSiteID", siteID).Count < 50)
            {
                num1    = customerNames.Length;
                intList = new List <int>();
                for (var index = 0; index < num1; ++index)
                {
                    intList.Add(GenerateCustomer(customerNames[index], siteID).CustomerID);
                }
            }
            else
            {
                intList = DataHelper.GetIntegerValues(CustomerInfoProvider.GetCustomers().Column("CustomerID")
                                                      .WhereEquals("CustomerSiteID", siteID).WhereNotEquals("CustomerEmail", "alex").Tables[0],
                                                      "CustomerID");
                num1 = intList.Count;
            }

            var num2 = 0;
            var num3 = 0;

            for (var index1 = 0; index1 <= 30; ++index1)
            {
                ++num2;
                var num4 = 0;
                if (index1 > 5)
                {
                    num4 = rand.Next(-1, 2);
                }
                for (var index2 = 0; index2 < num2 / 2 + num4; ++index2)
                {
                    var orderStatusInfo = index1 >= 25
                        ? index1 >= 29 ? orderStatusList["New"] : orderStatusList["InProgress"]
                        : orderStatusList["Completed"];
                    var orderInfo = new OrderInfo
                    {
                        OrderCustomerID = intList[num3 % num1],
                        OrderCurrencyID = currencyInfo.CurrencyID,
                        OrderSiteID     = siteID,
                        OrderStatusID   = orderStatusInfo.StatusID,
                        OrderIsPaid     = "Completed".Equals(orderStatusInfo.StatusName, StringComparison.Ordinal) ||
                                          (uint)rand.Next(0, 2) > 0U,
                        OrderShippingOptionID         = list2[rand.Next(list2.Count)].ShippingOptionID,
                        OrderPaymentOptionID          = list1[rand.Next(list1.Count)].PaymentOptionID,
                        OrderGrandTotal               = decimal.Zero,
                        OrderGrandTotalInMainCurrency = decimal.Zero,
                        OrderTotalPrice               = decimal.Zero,
                        OrderTotalPriceInMainCurrency = decimal.Zero,
                        OrderTotalShipping            = new decimal(10),
                        OrderTotalTax = new decimal(10)
                    };
                    OrderInfoProvider.SetOrderInfo(orderInfo);
                    var orderItems = GenerateOrderItems(orderInfo, list3);
                    GenerateOrderAddress(orderInfo.OrderID, GetRandomCountryId(), AddressType.Billing);
                    GenerateOrderAddress(orderInfo.OrderID, GetRandomCountryId(), AddressType.Shipping);
                    orderInfo.OrderDate       = DateTime.Now.AddDays(index1 - 30);
                    orderInfo.OrderTotalPrice = orderItems;
                    orderInfo.OrderTotalPriceInMainCurrency = orderItems;
                    orderInfo.OrderGrandTotal = orderItems;
                    orderInfo.OrderGrandTotalInMainCurrency = orderItems;
                    var cartInfoFromOrder = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderInfo.OrderID);
                    orderInfo.OrderInvoiceNumber = OrderInfoProvider.GenerateInvoiceNumber(cartInfoFromOrder);
                    orderInfo.OrderInvoice       = ShoppingCartInfoProvider.GetOrderInvoice(cartInfoFromOrder);
                    OrderInfoProvider.SetOrderInfo(orderInfo);
                    ++num3;
                }
            }

            if (UserInfoProvider.GetUserInfo("alex") != null)
            {
                return;
            }
            var customerInfo = new CustomerInfo
            {
                CustomerEmail             = "*****@*****.**",
                CustomerFirstName         = "Alexander",
                CustomerLastName          = "Adams",
                CustomerSiteID            = siteID,
                CustomerCompany           = "Alex & Co. Ltd",
                CustomerTaxRegistrationID = "12S379BDF798",
                CustomerOrganizationID    = "WRQ7987VRG79"
            };

            CustomerInfoProvider.SetCustomerInfo(customerInfo);
            var userInfo = CustomerInfoProvider.RegisterCustomer(customerInfo, "", "alex");
            var roleInfo = RoleInfoProvider.GetRoleInfo("SilverPartner", siteID);

            if (roleInfo != null)
            {
                UserInfoProvider.AddUserToRole(userInfo.UserID, roleInfo.RoleID);
            }
            for (var index = 0; index < 5; ++index)
            {
                var cart = new ShoppingCartInfo();
                cart.ShoppingCartCulture         = CultureHelper.GetDefaultCultureCode(siteName);
                cart.ShoppingCartCurrencyID      = currencyInfo.CurrencyID;
                cart.ShoppingCartSiteID          = siteID;
                cart.ShoppingCartCustomerID      = customerInfo.CustomerID;
                cart.ShoppingCartBillingAddress  = GenerateAddress(GetRandomCountryId(), customerInfo.CustomerID);
                cart.ShoppingCartShippingAddress = GenerateAddress(GetRandomCountryId(), customerInfo.CustomerID);
                cart.User = userInfo;
                ShoppingCartInfoProvider.SetShoppingCartInfo(cart);
                ShoppingCartInfoProvider.SetShoppingCartItem(cart,
                                                             new ShoppingCartItemParameters(list3.ElementAt(rand.Next(list3.Count)).SKUID, rand.Next(5)));
                cart.Evaluate();
                ShoppingCartInfoProvider.SetOrder(cart);
            }
        }
 private static bool CheckPaymentIsAllowedForShipping(ShoppingCartInfo currentShoppingCart, int paymentOptionId)
 {
     return (currentShoppingCart.ShoppingCartShippingOptionID == 0) ||
            (PaymentOptionInfoProvider.GetPaymentOptionsForShipping(currentShoppingCart.ShoppingCartShippingOptionID, true)
                                      .Where("PaymentOptionID", QueryOperator.Equals, paymentOptionId)
                                      .TopN(1)
                                      .Any());
 }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            string text = context.Request["action"].ToNullString();

            if (string.IsNullOrEmpty(text) || text == "")
            {
                string text2 = string.Empty;
                string text3 = context.Request["ckids"];
                if (!string.IsNullOrEmpty(text3))
                {
                    text2 = text3;
                }
                string           a2 = context.Request["client"].ToNullString();
                ShoppingCartInfo shoppingCartInfo = (!(a2 == "wap")) ? ShoppingCartProcessor.GetShoppingCart(text2, false, false, -1) : ShoppingCartProcessor.GetMobileShoppingCart(text2, false, false, -1);
                if (shoppingCartInfo != null)
                {
                    string[] source = text2.Split(',');
                    bool     flag   = false;
                    bool     flag2  = true;
                    bool     flag3  = true;
                    foreach (ShoppingCartItemInfo lineItem in shoppingCartInfo.LineItems)
                    {
                        if (source.Contains(lineItem.SkuId) || source.Contains(lineItem.SkuId + "|" + lineItem.StoreId))
                        {
                            int skuStock = ShoppingCartProcessor.GetSkuStock(lineItem.SkuId, lineItem.StoreId);
                            if (skuStock < lineItem.Quantity)
                            {
                                flag = true;
                                break;
                            }
                            if (HiContext.Current.SiteSettings.OpenMultStore && lineItem.StoreId > 0)
                            {
                                StoresInfo storeById = StoresHelper.GetStoreById(lineItem.StoreId);
                                if (storeById != null)
                                {
                                    if (!SettingsManager.GetMasterSettings().Store_IsOrderInClosingTime)
                                    {
                                        DateTime dateTime = DateTime.Now;
                                        string   str      = dateTime.ToString("yyyy-MM-dd");
                                        dateTime = storeById.OpenStartDate;
                                        DateTime value = (str + " " + dateTime.ToString("HH:mm")).ToDateTime().Value;
                                        dateTime = DateTime.Now;
                                        string str2 = dateTime.ToString("yyyy-MM-dd");
                                        dateTime = storeById.OpenEndDate;
                                        DateTime dateTime2 = (str2 + " " + dateTime.ToString("HH:mm")).ToDateTime().Value;
                                        if (dateTime2 <= value)
                                        {
                                            dateTime2 = dateTime2.AddDays(1.0);
                                        }
                                        if (DateTime.Now < value || DateTime.Now > dateTime2)
                                        {
                                            flag3 = false;
                                        }
                                    }
                                    if (!storeById.CloseStatus && storeById.CloseEndTime.HasValue && storeById.CloseBeginTime.HasValue && storeById.CloseEndTime.Value > DateTime.Now && storeById.CloseBeginTime.Value < DateTime.Now)
                                    {
                                        flag2 = false;
                                    }
                                }
                            }
                        }
                    }
                    if (flag)
                    {
                        context.Response.ContentType = "text/json";
                        context.Response.Write("{\"status\":\"false\",\"msg\":\"有商品库存不足,不能结算\"}");
                        context.Response.End();
                    }
                    if (!flag3)
                    {
                        context.Response.ContentType = "text/json";
                        context.Response.Write("{\"status\":\"StoreNotInTime\",\"msg\":\"非营业时间\"}");
                        context.Response.End();
                    }
                    if (!flag2)
                    {
                        context.Response.ContentType = "text/json";
                        context.Response.Write("{\"status\":\"StoreNotOpen\",\"msg\":\"歇业中\"}");
                        context.Response.End();
                    }
                    if (shoppingCartInfo != null)
                    {
                        ShoppingCartGiftInfo shoppingCartGiftInfo = (from a in shoppingCartInfo.LineGifts
                                                                     where a.PromoType == 5
                                                                     select a).FirstOrDefault();
                        shoppingCartInfo.SendGiftPromotionId = (shoppingCartGiftInfo?.GiftId ?? 0);
                        if (!shoppingCartInfo.IsSendGift && shoppingCartInfo.LineGifts.Count > 0)
                        {
                            foreach (ShoppingCartGiftInfo lineGift in shoppingCartInfo.LineGifts)
                            {
                                ShoppingCartProcessor.RemoveGiftItem(lineGift.GiftId, PromoteType.SentGift);
                            }
                        }
                    }
                    string s = JsonConvert.SerializeObject(shoppingCartInfo);
                    context.Response.ContentType = "text/json";
                    context.Response.Write(s);
                }
            }
            else if (text == "ClearCart")
            {
                string text4 = context.Request.Form["ck_productId"].ToNullString();
                if (string.IsNullOrEmpty(text4))
                {
                    context.Response.Write("{\"status\":\"false\",\"msg\":\"请选择要清除的商品\"}");
                }
                else
                {
                    string[] array = text4.Split(',');
                    foreach (string text5 in array)
                    {
                        string[] array2 = text5.Split('|');
                        if (array2.Length == 2)
                        {
                            ShoppingCartProcessor.RemoveLineItem(array2[0], array2[1].ToInt(0));
                        }
                        else
                        {
                            ShoppingCartProcessor.RemoveLineItem(text5, 0);
                        }
                    }
                    context.Response.Write("{\"status\":\"true\",\"msg\":\"清除成功\"}");
                }
                context.Response.End();
            }
            else if (text == "HasStore")
            {
                string       text6          = context.Request.Form["skuId"].ToNullString();
                SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                if (string.IsNullOrEmpty(text6) || !masterSettings.OpenMultStore)
                {
                    context.Response.Write("{\"status\":\"false\"}");
                }
                else if (ShoppingCartProcessor.HasStoreSkuStocks(text6))
                {
                    context.Response.Write("{\"status\":\"true\"}");
                }
                else
                {
                    context.Response.Write("{\"status\":\"false\"}");
                }
            }
            else if (text == "ProductsHasStore")
            {
                string       text7           = context.Request.Form["productIds"];
                SiteSettings masterSettings2 = SettingsManager.GetMasterSettings();
                if (string.IsNullOrEmpty(text7) || !masterSettings2.OpenMultStore)
                {
                    context.Response.Write("{\"status\":\"false\"}");
                }
                else
                {
                    string str3 = ShoppingCartProcessor.HasStoreByProducts(text7);
                    context.Response.Write("{\"status\":\"true\",\"productIds\":\"" + str3 + "\"}");
                }
            }
            else if (text == "updateBuyNum")
            {
                string               skuid                = context.Request.Form["SkuId"].ToNullString().Trim();
                int                  num                  = context.Request.Form["BuyNum"].ToNullString().Trim().ToInt(0);
                string               a3                   = context.Request.Form["client"].ToNullString().Trim();
                ShoppingCartInfo     shoppingCartInfo2    = (!(a3 == "wap")) ? ShoppingCartProcessor.GetShoppingCart(null, false, false, -1) : ShoppingCartProcessor.GetMobileShoppingCart(null, false, false, -1);
                ShoppingCartItemInfo shoppingCartItemInfo = shoppingCartInfo2.LineItems.FirstOrDefault((ShoppingCartItemInfo a) => a.SkuId == skuid);
                int                  num2                 = shoppingCartItemInfo?.Quantity ?? 1;
                if (num <= 0)
                {
                    context.Response.Write("{\"status\":\"numError\",\"msg\":\"购买数量必须为大于0的整数\",\"oldNumb\":\"" + num2 + "\"}");
                }
                else if (ShoppingCartProcessor.GetSkuStock(skuid, 0) < num)
                {
                    context.Response.Write("{\"status\":\"StockError\",\"msg\":\"该商品库存不足\",\"oldNumb\":\"" + num2 + "\"}");
                }
                else
                {
                    ShoppingCartProcessor.UpdateLineItemQuantity(skuid, num, 0);
                    PromotionInfo productQuantityDiscountPromotion = ShoppingCartProcessor.GetProductQuantityDiscountPromotion(skuid, HiContext.Current.User.GradeId);
                    if (productQuantityDiscountPromotion != null && (decimal)num >= productQuantityDiscountPromotion.Condition)
                    {
                        shoppingCartItemInfo.AdjustedPrice = shoppingCartItemInfo.MemberPrice * productQuantityDiscountPromotion.DiscountValue;
                    }
                    else
                    {
                        shoppingCartItemInfo.AdjustedPrice = shoppingCartItemInfo.MemberPrice;
                    }
                    context.Response.Write("{\"status\":\"true\",\"adjustedPrice\":" + shoppingCartItemInfo.AdjustedPrice.F2ToString("f2") + "}");
                }
            }
            else if (text == "updateGiftBuyNum")
            {
                string               giftId                = context.Request.Form["giftId"].ToNullString().Trim();
                int                  num3                  = context.Request.Form["BuyNum"].ToNullString().Trim().ToInt(0);
                string               a4                    = context.Request.Form["client"].ToNullString().Trim();
                ShoppingCartInfo     shoppingCartInfo3     = (!(a4 == "wap")) ? ShoppingCartProcessor.GetShoppingCart(null, false, false, -1) : ShoppingCartProcessor.GetMobileShoppingCart(null, false, false, -1);
                ShoppingCartGiftInfo shoppingCartGiftInfo2 = shoppingCartInfo3.LineGifts.FirstOrDefault((ShoppingCartGiftInfo a) => a.GiftId == giftId.ToInt(0));
                if (shoppingCartGiftInfo2 == null)
                {
                    context.Response.Write("{\"status\":\"nullError\",\"msg\":\"该礼品不存在或已删除\",\"oldNumb\":\"" + 0 + "\"}");
                }
                else if (num3 <= 0)
                {
                    context.Response.Write("{\"status\":\"numError\",\"msg\":\"购买数量必须为大于0的整数\",\"oldNumb\":\"" + shoppingCartGiftInfo2.Quantity + "\"}");
                }
                else
                {
                    ShoppingCartProcessor.UpdateGiftItemQuantity(giftId.ToInt(0), num3, PromoteType.NotSet);
                    context.Response.Write("{\"status\":\"true\"}");
                }
            }
            else if (text == "deleteGift")
            {
                string text8 = context.Request.Form["giftId"].ToNullString().Trim();
                text8 = text8.TrimStart(',').TrimEnd(',');
                string[] array3 = text8.Split(',');
                foreach (string text9 in array3)
                {
                    ShoppingCartProcessor.RemoveGiftItem(text8.ToInt(0), PromoteType.NotSet);
                }
                context.Response.Write("{\"status\":\"true\"}");
            }
            else if (text == "deletestore")
            {
                string skuId   = context.Request.Form["SkuId"].ToNullString().Trim();
                int    storeId = context.Request.Form["StoreId"].ToInt(0);
                ShoppingCartProcessor.RemoveLineItem(skuId, storeId);
                context.Response.Write("{\"status\":\"true\"}");
            }
            else if (text == "delete")
            {
                string skuId2 = context.Request.Form["SkuId"].ToNullString().Trim();
                ShoppingCartProcessor.RemoveLineItem(skuId2, 0);
                context.Response.Write("{\"status\":\"true\"}");
            }
            else if (text == "deleteall")
            {
                string text10 = context.Request.Form["SkuIdList"].ToNullString().Trim();
                if (!string.IsNullOrEmpty(text10.ToNullString().Trim()))
                {
                    text10 = text10.TrimStart(',').TrimEnd(',');
                    string[] array4 = text10.Split(',');
                    foreach (string skuId3 in array4)
                    {
                        ShoppingCartProcessor.RemoveLineItem(skuId3, 0);
                    }
                }
                context.Response.Write("{\"status\":\"true\"}");
            }
            else if (text == "reducedpromotion")
            {
                decimal       amount           = context.Request.Form["Amount"].ToDecimal(0);
                int           quantity         = context.Request.Form["Quantity"].ToInt(0);
                MemberInfo    user             = HiContext.Current.User;
                decimal       num4             = default(decimal);
                PromotionInfo reducedPromotion = new PromotionDao().GetReducedPromotion(user.GradeId, amount, quantity, out num4, 0);
                if (reducedPromotion != null)
                {
                    context.Response.Write("{\"ReducedPromotionAmount\":\"" + num4 + "\",\"ReducedPromotionCondition\":\"" + reducedPromotion.Condition + "\"}");
                }
                else
                {
                    context.Response.Write("{\"ReducedPromotionAmount\":\"0\",\"ReducedPromotionCondition\":\"0\"}");
                }
            }
        }
    private bool CheckBreakingErrors(ShoppingCartInfo shoppingCart)
    {
        bool valid = true;
        // Check currency
        if (shoppingCart.Currency == null)
        {
            valid = false;
            LogError("Missing currency", EVENT_CODE_VALIDATION);
        }

        // Check customer
        if (shoppingCart.Customer == null)
        {
            valid = false;
            LogError("Missing customer", EVENT_CODE_VALIDATION);
        }

        // Check BillingAddress
        if (shoppingCart.ShoppingCartBillingAddress == null)
        {
            valid = false;
            LogError("Missing billing address", EVENT_CODE_VALIDATION);
        }

        return valid;
    }
    /// <summary>
    /// Checks whether the payment option is valid for current user.
    /// </summary>
    /// <param name="shoppingCart">The shopping cart.</param>
    /// <param name="message">The message in case of failure.</param>    
    protected bool CheckPaymentOptionIsValidForUser(ShoppingCartInfo shoppingCart, out string message)
    {
        message = string.Empty;
        CMSPaymentGatewayProvider provider = CMSPaymentGatewayProvider.GetPaymentGatewayProvider(shoppingCart.ShoppingCartPaymentOptionID);

        if ((provider != null) && (!provider.IsUserAuthorizedToFinishPayment(shoppingCart.User, shoppingCart)))
        {
            message = provider.ErrorMessage;
            return false;
        }

        return true;
    }
    private bool EnsureCartCustomer(ShoppingCartInfo shoppingCart)
    {
        CustomerInfo customer = shoppingCart.Customer;
        customer.CustomerSiteID = shoppingCart.ShoppingCartSiteID;
        customer.CustomerUserID = shoppingCart.ShoppingCartUserID;

        CustomerInfoProvider.SetCustomerInfo(customer);
        shoppingCart.ShoppingCartCustomerID = customer.CustomerID;

        if (customer.CustomerID == 0)
        {
            LogError("Save customer action failed", EVENT_CODE_SAVING);
            return false;
        }

        return true;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!RequestHelper.IsPostBack())
        {
            ShoppingCart = GetNewCart();
        }

        Cart.LocalShoppingCart = ShoppingCart;
        Cart.EnableProductPriceDetail = true;
        Cart.OnPaymentCompleted += (s, ea) => GoToOrderDetail();
        Cart.OnPaymentSkipped += (s, ea) => GoToOrderDetail();
        Cart.OnCheckPermissions += Cart_OnCheckPermissions;
        Cart.RequiredFieldsMark = CMS.EcommerceProvider.ShoppingCart.DEFAULT_REQUIRED_FIELDS_MARK;

        Cart.CheckoutProcessType = (customerId > 0) ? CheckoutProcessEnum.CMSDeskCustomer : CheckoutProcessEnum.CMSDeskOrder;
    }
    private bool HandleAutoRegistration(ShoppingCartInfo currentShoppingCart)
    {
        registrationBanned = string.Empty;
        var customer = currentShoppingCart.Customer;

        if ((customer == null) || customer.CustomerIsRegistered)
        {
            return true;
        }

        if (ECommerceSettings.AutomaticCustomerRegistration(currentShoppingCart.ShoppingCartSiteID) || currentShoppingCart.RegisterAfterCheckout)
        {
            // Ban IP addresses which are blocked for registration
            var registrationBan = !BannedIPInfoProvider.IsAllowed(currentShoppingCart.SiteName, BanControlEnum.Registration);
            var allUserActionBan = !BannedIPInfoProvider.IsAllowed(currentShoppingCart.SiteName, BanControlEnum.AllNonComplete);

            if (registrationBan || allUserActionBan)
            {
                registrationBanned = GetString("banip.ipisbannedregistration");
                LogError(registrationBanned, EVENT_CODE_VALIDATION);
                return false;
            }
            // Auto-register user and send mail notification
            CustomerInfoProvider.RegisterAndNotify(customer, currentShoppingCart.RegisterAfterCheckoutTemplate);
        }

        return true;
    }
    public static string GetFormatedPrice(object SKUPrice, object SKUDepartmentId, ShoppingCartInfo cart, object SKUId, bool FormatPrice)
    {
        double price = ValidationHelper.GetDouble(SKUPrice, 0);
        int departmentId = ValidationHelper.GetInteger(SKUDepartmentId, 0);
        int skuId = ValidationHelper.GetInteger(SKUId, 0);

        // When on the live site
        if (cart == null)
        {
            cart = ECommerceContext.CurrentShoppingCart;
        }

        if (departmentId > 0)
        {
            // Try site discount level
            DiscountLevelInfo discountLevel = cart.SiteDiscountLevel;
            bool valid = (discountLevel != null) && discountLevel.IsInDepartment(departmentId) && discountLevel.IsValid;

            if (!valid)
            {
                // Try global discount level
                discountLevel = cart.DiscountLevel;
                valid = (discountLevel != null) && discountLevel.IsInDepartment(departmentId) && discountLevel.IsValid;
            }

            // Apply discount to product price
            if (valid)
            {
                // Remember price before discount
                double oldPrice = price;

                // Get new price after discount
                price = price * (1 - discountLevel.DiscountLevelValue / 100);

                if ((oldPrice > 0) && (price < 0))
                {
                    price = 0;
                }
            }
        }

        int stateId = cart.StateID;
        int countryId = cart.CountryID;
        bool isTaxIDSupplied = ((cart.Customer != null) && (cart.Customer.CustomerTaxRegistrationID != ""));

        if ((skuId > 0) && ((stateId > 0) || (countryId > 0)))
        {
            // Apply taxes
            price += GetSKUTotalTax(price, skuId, stateId, countryId, isTaxIDSupplied);
        }

        // Apply exchange rate
        price = cart.ApplyExchangeRate(price);

        if (FormatPrice)
        {
            // Get formatted price
            return cart.GetFormattedPrice(price, true);
        }
        else
        {
            // Get not-formated price
            return price.ToString();
        }
    }
    /// <summary>
    /// Validates the shopping cart. In case of error user is able to go through CHOP again with the same cart object.
    /// </summary>
    /// <param name="shoppingCart">The shopping cart.</param>
    /// <param name="errorMessage">The error message.</param>    
    private bool ValidateShoppingCart(ShoppingCartInfo shoppingCart, out string errorMessage)
    {
        bool valid = true;
        StringBuilder sb = new StringBuilder();

        // Check shopping cart items.
        // The following conditions must be met to pass the check:
        // 1)All shopping cart items are enabled 2)Max units in one order are not exceeded
        // 3)There is enough units in the inventory 4) Customer is registered, if there is a membership type product in the cart
        // 5)Product validity is valid, if there is a membership or e-product type product in the cart
        // 6)Selected shipping option is applicable to cart
        var result = ShoppingCartInfoProvider.CheckShoppingCart(shoppingCart);
        if (result.CheckFailed || shoppingCart.IsEmpty)
        {
            valid = false;
            sb.Append(result.GetHTMLFormattedMessage());
            sb.Append(HTML_SEPARATOR);
        }

        // Check PaymentOption
        if (shoppingCart.PaymentOption == null)
        {
            valid = false;
            sb.Append(GetString("com.checkout.paymentoptionnotselected"));
            sb.Append(HTML_SEPARATOR);
        }

        // Check whether payment option is valid for user.
        string message;
        if (!CheckPaymentOptionIsValidForUser(shoppingCart, out message))
        {
            valid = false;
            sb.Append(message);
            sb.Append(HTML_SEPARATOR);
        }

        // Check payment is valid for cart shipping
        if (!CheckPaymentIsAllowedForShipping(shoppingCart, shoppingCart.ShoppingCartPaymentOptionID))
        {
            valid = false;
            sb.Append(GetString("com.checkout.paymentoptionnotapplicable"));
            sb.Append(HTML_SEPARATOR);
        }

        // If there is at least one product that needs shipping and shipping is not selected
        if (shoppingCart.IsShippingNeeded && (shoppingCart.ShippingOption == null))
        {
            valid = false;
            sb.Append(GetString("com.checkoutprocess.shippingneeded"));
            sb.Append(HTML_SEPARATOR);
        }

        errorMessage = TextHelper.TrimEndingWord(sb.ToString(), HTML_SEPARATOR);
        return valid;
    }
Beispiel #50
0
        protected int SkipWeixinOpenId(string openId, string weixinNickName, string unionId, string headimgurl, string ReferralUserId, bool isSubscribe)
        {
            int        num        = 1;
            MemberInfo memberInfo = MemberProcessor.GetMemberByOpenId("hishop.plugins.openid.weixin", openId);
            bool       flag       = false;

            if (memberInfo == null)
            {
                memberInfo = MemberProcessor.GetMemberByUnionId(unionId);
                flag       = true;
            }
            SiteSettings     masterSettings     = SettingsManager.GetMasterSettings();
            ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
            bool             flag2 = false;

            if (memberInfo != null)
            {
                num = 2;
                if (memberInfo.IsSubscribe != isSubscribe)
                {
                    memberInfo.IsSubscribe = isSubscribe;
                    flag2 = true;
                }
                bool flag3 = MemberProcessor.IsBindedWeixin(memberInfo.UserId, "hishop.plugins.openid.weixin");
                memberInfo.Picture = headimgurl;
                if (!string.IsNullOrEmpty(unionId) && memberInfo.UnionId != unionId && !flag)
                {
                    memberInfo.UnionId = unionId;
                    flag2 = true;
                }
                if (flag)
                {
                    if (!flag3)
                    {
                        MemberOpenIdInfo memberOpenIdInfo = new MemberOpenIdInfo();
                        memberOpenIdInfo.UserId     = memberInfo.UserId;
                        memberOpenIdInfo.OpenIdType = "hishop.plugins.openid.weixin";
                        memberOpenIdInfo.OpenId     = openId;
                        MemberProcessor.AddMemberOpenId(memberOpenIdInfo);
                        memberInfo.IsQuickLogin = true;
                        flag2 = true;
                    }
                    else
                    {
                        MemberOpenIdInfo memberOpenIdInfo2 = new MemberOpenIdInfo();
                        memberOpenIdInfo2.UserId     = memberInfo.UserId;
                        memberOpenIdInfo2.OpenIdType = "hishop.plugins.openid.weixin";
                        memberOpenIdInfo2.OpenId     = openId;
                        MemberProcessor.UpdateMemberOpenId(memberOpenIdInfo2);
                    }
                }
                if (flag2)
                {
                    MemberProcessor.UpdateMember(memberInfo);
                }
                Users.SetCurrentUser(memberInfo.UserId, 30, true, false);
                HiContext.Current.User = memberInfo;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                if (!string.IsNullOrEmpty(openId))
                {
                    HttpCookie httpCookie = new HttpCookie("openId");
                    httpCookie.HttpOnly = true;
                    httpCookie.Value    = openId;
                    httpCookie.Expires  = DateTime.MaxValue;
                    HttpContext.Current.Response.Cookies.Add(httpCookie);
                }
                lock (this.lockCopyRedEnvelope)
                {
                    this.CopyRedEnvelope(openId, memberInfo);
                }
                return(num);
            }
            memberInfo             = new MemberInfo();
            memberInfo.Picture     = headimgurl;
            memberInfo.IsSubscribe = isSubscribe;
            int num2 = 0;

            if (ReferralUserId.ToInt(0) > 0)
            {
                memberInfo.ReferralUserId = ReferralUserId.ToInt(0);
            }
            MemberWXReferralInfo wXReferral = VShopHelper.GetWXReferral(openId.Trim());

            if (wXReferral != null)
            {
                VShopHelper.DeleteWXReferral(openId.Trim());
            }
            memberInfo.GradeId = MemberProcessor.GetDefaultMemberGrade();
            if (!string.IsNullOrEmpty(weixinNickName))
            {
                MemberInfo memberInfo2 = memberInfo;
                MemberInfo memberInfo3 = memberInfo;
                string     text3       = memberInfo2.UserName = (memberInfo3.NickName = HttpUtility.UrlDecode(weixinNickName));
            }
            if (string.IsNullOrEmpty(memberInfo.UserName))
            {
                memberInfo.UserName = "******" + this.GenerateUsername(8);
            }
            if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
            {
                memberInfo.UserName = "******" + this.GenerateUsername(9);
                if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
                {
                    memberInfo.UserName = this.GenerateUsername();
                    if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null)
                    {
                        num = -1;
                    }
                }
            }
            if (num == 1)
            {
                string text4 = this.GeneratePassword();
                string text5 = "Open";
                string text6 = text4;
                text4 = (memberInfo.Password = Users.EncodePassword(text4, text5));
                memberInfo.PasswordSalt     = text5;
                memberInfo.RegisteredSource = 3;
                memberInfo.CreateDate       = DateTime.Now;
                memberInfo.IsQuickLogin     = true;
                memberInfo.IsLogined        = true;
                memberInfo.UnionId          = unionId;
                num2 = MemberProcessor.CreateMember(memberInfo);
                if (num2 <= 0)
                {
                    num = -1;
                }
            }
            if (num == 1)
            {
                memberInfo.UserId   = num2;
                memberInfo.UserName = MemberHelper.GetUserName(memberInfo.UserId);
                MemberHelper.Update(memberInfo, true);
                Users.SetCurrentUser(memberInfo.UserId, 30, false, false);
                HiContext.Current.User = memberInfo;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                if (!string.IsNullOrEmpty(openId))
                {
                    MemberOpenIdInfo memberOpenIdInfo3 = new MemberOpenIdInfo();
                    memberOpenIdInfo3.UserId     = memberInfo.UserId;
                    memberOpenIdInfo3.OpenIdType = "hishop.plugins.openid.weixin";
                    memberOpenIdInfo3.OpenId     = openId;
                    if (MemberProcessor.GetMemberByOpenId(memberOpenIdInfo3.OpenIdType, openId) == null)
                    {
                        MemberProcessor.AddMemberOpenId(memberOpenIdInfo3);
                    }
                    if (!string.IsNullOrEmpty(openId))
                    {
                        HttpCookie httpCookie2 = new HttpCookie("openId");
                        httpCookie2.HttpOnly = true;
                        httpCookie2.Value    = openId;
                        httpCookie2.Expires  = DateTime.MaxValue;
                        HttpContext.Current.Response.Cookies.Add(httpCookie2);
                    }
                    lock (this.lockCopyRedEnvelope)
                    {
                        this.CopyRedEnvelope(openId, memberInfo);
                    }
                }
            }
            return(num);
        }
Beispiel #51
0
 public static double GetPrice(object SKUPrice, object SKUDepartmentId, ShoppingCartInfo cart)
 {
     return GetPrice(SKUPrice, SKUDepartmentId, cart, 0);
 }
Beispiel #52
0
    protected void btnOk_Click(object sender, EventArgs e)
    {
        // check 'EcommerceModify' permission
        if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyOrders"))
        {
            RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyOrders");
        }

        // Get order
        OrderInfo oi = OrderInfoProvider.GetOrderInfo(orderId);

        if (oi != null)
        {
            // Get order site
            SiteInfo si = SiteInfoProvider.GetSiteInfo(oi.OrderSiteID);

            // If shipping address is required
            if (((this.ShoppingCartInfoObj != null) && (ShippingOptionInfoProvider.IsShippingNeeded(this.ShoppingCartInfoObj))) ||
                ((si != null) && (ECommerceSettings.ApplyTaxesBasedOn(si.SiteName) == ApplyTaxBasedOnEnum.ShippingAddress)))
            {
                // If shipping address is not set
                if (this.addressElem.AddressID <= 0)
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("Order_Edit_Shipping.NoAddress");

                    return;
                }
            }

            try
            {
                // Load the shopping cart to process the data
                ShoppingCartInfo sci = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderId);
                if (sci != null)
                {
                    // Set order new properties
                    sci.ShoppingCartShippingOptionID  = drpShippingOption.ShippingID;
                    sci.ShoppingCartShippingAddressID = this.addressElem.AddressID;

                    // Evaulate order data
                    ShoppingCartInfoProvider.EvaluateShoppingCart(sci);

                    // Update order data
                    ShoppingCartInfoProvider.SetOrder(sci, false);
                }

                // Update tracking number
                oi.OrderTrackingNumber = txtTrackingNumber.Text.Trim();
                OrderInfoProvider.SetOrderInfo(oi);

                lblInfo.Visible = true;
                lblInfo.Text    = GetString("General.ChangesSaved");
            }
            catch (Exception ex)
            {
                lblError.Visible = true;
                lblError.Text    = ex.Message;
            }
        }
    }
 public static string GetFormatedPrice(object SKUPrice, object SKUDepartmentId, ShoppingCartInfo cart, object SKUId)
 {
     return GetFormatedPrice(SKUPrice, SKUDepartmentId, cart, SKUId, true);
 }
Beispiel #54
0
        protected override void AttachChildControls()
        {
            PageTitle.AddSiteNameTitle("会员中心");
            Member member = HiContext.Current.User as Member;

            if (member == null)
            {
                this.Page.Response.Redirect("/Vshop/Login.aspx");
            }
            this.litUserLink       = (System.Web.UI.WebControls.Literal) this.FindControl("litUserLink");
            this.litUserName       = (System.Web.UI.WebControls.Literal) this.FindControl("litUserName");
            this.litPaymentBalance = (System.Web.UI.WebControls.Literal) this.FindControl("litPaymentBalance");
            this.litExpenditure    = (System.Web.UI.WebControls.Literal) this.FindControl("litExpenditure");
            this.litExpenditure.SetWhenIsNotNull(member.Expenditure.ToString("F2"));
            this.litPaymentBalance.SetWhenIsNotNull(member.Balance.ToString("F2"));
            this.litPoints         = (System.Web.UI.WebControls.Literal) this.FindControl("litPoints");
            this.referralLink      = (System.Web.UI.WebControls.HyperLink) this.FindControl("referralLink");
            this.bindAccountLink   = (System.Web.UI.WebControls.HyperLink) this.FindControl("bindAccountLink");
            this.litAllOrderCount  = (System.Web.UI.WebControls.Literal) this.FindControl("litAllOrderCount");
            this.litRefundCount    = (System.Web.UI.WebControls.Literal) this.FindControl("litRefundCount");
            this.litReturnCount    = (System.Web.UI.WebControls.Literal) this.FindControl("litReturnCount");
            this.litReplaceCount   = (System.Web.UI.WebControls.Literal) this.FindControl("litReplaceCount");
            this.switchAccountLink = (System.Web.UI.WebControls.HyperLink) this.FindControl("switchAccountLink");
            this.litCoupons        = (System.Web.UI.WebControls.Literal) this.FindControl("litCoupons");
            this.litVoucher        = (System.Web.UI.WebControls.Literal) this.FindControl("litVoucher");
            this.litBindPhone      = (System.Web.UI.HtmlControls.HtmlAnchor) this.FindControl("litBindPhone");
            Regex regMobile = new Regex("^(13|14|15|17|18)\\d{9}$");

            if (!regMobile.IsMatch(member.Username))
            {
                this.litBindPhone.Visible = true;
            }
            else
            {
                this.litBindPhone.Visible = false;
            }
            if (this.litPoints != null)
            {
                this.litPoints.SetWhenIsNotNull(member.Points.ToString("F2"));
            }
            this.litMemberGrade = (System.Web.UI.WebControls.Literal) this.FindControl("litMemberGrade");
            MemberGradeInfo memberGrade = MemberProcessor.GetMemberGrade(member.GradeId);

            if (memberGrade != null)
            {
                this.litMemberGrade.SetWhenIsNotNull(memberGrade.Name);
            }
            this.litUserName.Text       = (string.IsNullOrEmpty(member.RealName) ? member.Username : member.RealName);
            this.litWaitForRecieveCount = (System.Web.UI.WebControls.Literal) this.FindControl("litWaitForRecieveCount");
            this.litWaitForPayCount     = (System.Web.UI.WebControls.Literal) this.FindControl("litWaitForPayCount");
            OrderQuery orderQuery = new OrderQuery();

            orderQuery.Status = OrderStatus.WaitBuyerPay;
            int userOrderCount = MemberProcessor.GetUserOrderCount(HiContext.Current.User.UserId, orderQuery);
            //
            HttpCookie httpCookieMember = new HttpCookie("wait");

            httpCookieMember.Value   = userOrderCount.ToString();
            httpCookieMember.Expires = System.DateTime.Now.AddYears(1);
            HttpContext.Current.Response.Cookies.Add(httpCookieMember);

            #region 处理cookie中的购物车和收藏信息
            Member curMember = HiContext.Current.User as Member;
            if (curMember != null && !curMember.IsAnonymous)
            {
                //修改TopRegionId
                if (curMember.TopRegionId == 0)
                {
                    long ip = 0;
                    try
                    {
                        ip = Globals.IpToInt(Globals.IPAddress);
                    }
                    catch
                    {
                    }
                    if (ip != 0)
                    {
                        string provinceName = TradeHelper.GetProvinceName(ip);
                        int    ProvinceId   = 0;
                        if (!string.IsNullOrEmpty(provinceName))
                        {
                            provinceName = provinceName.Replace("市", "");
                            ProvinceId   = RegionHelper.GetProvinceId(provinceName);
                            ErrorLog.Write(string.Format("更新会员的ProvinceId:{0}", ProvinceId));
                            if (ProvinceId != 0)
                            {
                                UserHelper.UpdateUserTopRegionId(curMember.UserId, ProvinceId);
                            }
                        }
                    }
                }
                //
                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }

                System.Web.HttpCookie cookieFavorite = HiContext.Current.Context.Request.Cookies["Hid_Ecshop_Favorite_Data_New"];
                if (cookieFavorite != null && !string.IsNullOrEmpty(cookieFavorite.Value))
                {
                    string[] favoriteProductIds = cookieFavorite.Value.Split('|');
                    int      productId          = 0;
                    foreach (string fav in favoriteProductIds)
                    {
                        try
                        {
                            productId = int.Parse(fav);
                            int favoriteId;
                            ProductBrowser.AddProductToFavorite(productId, curMember.UserId, out favoriteId);
                        }
                        catch
                        {
                            continue;
                        }
                    }
                    cookieFavorite.Expires = DateTime.Now.AddDays(-1);
                    HttpContext.Current.Response.Cookies.Add(cookieFavorite);
                }
            }
            #endregion

            //购物车商品数量
            ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart();
            string           quantity     = "0";
            if (shoppingCart != null)
            {
                quantity = shoppingCart.GetQuantity().ToString();
            }
            HttpCookie httpCookieShoppingCart = new HttpCookie("cn");
            httpCookieShoppingCart.Value   = quantity;
            httpCookieShoppingCart.Expires = System.DateTime.Now.AddYears(1);
            HttpContext.Current.Response.Cookies.Add(httpCookieShoppingCart);

            this.litWaitForPayCount.SetWhenIsNotNull(userOrderCount.ToString());
            orderQuery.Status = OrderStatus.SellerAlreadySent;
            userOrderCount    = MemberProcessor.GetUserOrderCount(HiContext.Current.User.UserId, orderQuery);
            this.litWaitForRecieveCount.SetWhenIsNotNull(userOrderCount.ToString());
            //
            orderQuery.Status = OrderStatus.All;
            userOrderCount    = MemberProcessor.GetUserOrderCount(HiContext.Current.User.UserId, orderQuery);
            this.litAllOrderCount.SetWhenIsNotNull(userOrderCount.ToString());

            userOrderCount = MemberProcessor.GetRefundCount(HiContext.Current.User.UserId);
            this.litRefundCount.SetWhenIsNotNull(userOrderCount.ToString());
            userOrderCount = MemberProcessor.GetReturnCount(HiContext.Current.User.UserId);
            this.litReturnCount.SetWhenIsNotNull(userOrderCount.ToString());
            userOrderCount = MemberProcessor.GetReplaceCount(HiContext.Current.User.UserId);
            this.litReplaceCount.SetWhenIsNotNull(userOrderCount.ToString());

            int UserNotReadCoupons = MemberProcessor.GetUserNotReadCoupons(HiContext.Current.User.UserId);
            this.litCoupons.SetWhenIsNotNull(UserNotReadCoupons.ToString());

            int UserNotReadlitVoucher = MemberProcessor.GetUserNotReadVoucher(HiContext.Current.User.UserId);
            if (this.litVoucher != null)
            {
                this.litVoucher.SetWhenIsNotNull(UserNotReadlitVoucher.ToString());
            }

            if (this.litUserLink != null)
            {
                System.Uri url  = System.Web.HttpContext.Current.Request.Url;
                string     text = (url.Port == 80) ? string.Empty : (":" + url.Port.ToString(System.Globalization.CultureInfo.InvariantCulture));
                this.litUserLink.Text = string.Concat(new object[]
                {
                    string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}://{1}{2}", new object[]
                    {
                        url.Scheme,
                        url.Host,
                        text
                    }),
                    Globals.ApplicationPath,
                    "/VShop/?ReferralUserId=",
                    HiContext.Current.User.UserId
                });
            }
            if (this.referralLink != null)
            {
                this.referralLink.CssClass = "list-group-item";
                if (member.ReferralStatus == 0 || member.ReferralStatus == 1 || member.ReferralStatus == 3)
                {
                    this.referralLink.Text = "申请成为推广员";
                    if (member.ReferralStatus == 1 || member.ReferralStatus == 3)
                    {
                        this.referralLink.NavigateUrl = "/VShop/ReferralRegisterresults.aspx";
                    }
                    else
                    {
                        this.referralLink.NavigateUrl = "/VShop/ReferralRegisterAgreement.aspx";
                    }
                }
                if (member.ReferralStatus == 2)
                {
                    this.referralLink.Text        = "推广员";
                    this.referralLink.NavigateUrl = "/VShop/Referral.aspx";
                }
            }

            if (bindAccountLink != null)
            {
                this.bindAccountLink.CssClass    = "list-group-item";
                this.bindAccountLink.Text        = "绑定PC端会员帐号";
                this.bindAccountLink.NavigateUrl = "/VShop/BindPCAccount.aspx";
            }

            int    totalCount = 0;
            string opernId    = member.OpenId;
            if (!string.IsNullOrEmpty(opernId))
            {
                totalCount = UserHelper.GetToalCountByOpenId(opernId);
            }

            if (switchAccountLink != null && totalCount >= 2)
            {
                this.switchAccountLink.CssClass    = "list-group-item";
                this.switchAccountLink.Text        = "切换帐号";
                this.switchAccountLink.NavigateUrl = "/VShop/SwitchAccount.aspx";
            }
        }
 public static double GetPrice(object SKUPrice, object SKUDepartmentId, ShoppingCartInfo cart)
 {
     string price = GetFormatedPrice(SKUPrice, SKUDepartmentId, cart, 0, false);
     return ValidationHelper.GetDouble(price, 0);
 }
Beispiel #56
0
 private void AssignDataSource(OrderService.OrderInfo orderInfo, OrderService.CreditCardInfo cardInfo)
 {
     OrderNoLiteral.Text        = orderInfo.OrderId.ToString();
     OrderDateLiteral.Text      = orderInfo.Date.ToShortDateString();
     PaymentDetailsLiteral.Text = cardInfo.Type.Name + " ," + "XXXX-XXXX-XXXX-" + cardInfo.Number.Substring(cardInfo.Number.Length - 4);
     BillingAddressLiteral.Text = cardInfo.Address.Address1 + ", ";
     if (cardInfo.Address.Address2 != string.Empty && cardInfo.Address.Address2 != null)
     {
         BillingAddressLiteral.Text += cardInfo.Address.Address2 + ", ";
     }
     BillingAddressLiteral.Text += cardInfo.Address.City + ", " + cardInfo.Address.State.Name + "-" + cardInfo.Address.Zip;
     if (orderInfo.RefundAmount != null && orderInfo.RefundAmount != 0)
     {
         RefundAmountLiteral.Text = orderInfo.RefundAmount.ToString();
         RefundPanel.Visible      = true;
     }
     else
     {
         RefundPanel.Visible = false;
     }
     if (orderInfo.Items.Length > 0)
     {
         ShoppingCartInfo            cartInfo1    = new ShoppingCartInfo();
         ShoppingCartItemInfo        cartItemInfo = new ShoppingCartItemInfo();
         List <ShoppingCartItemInfo> cartItems    = new List <ShoppingCartItemInfo>();
         foreach (OrderService.OrderItemInfo orderItem in orderInfo.Items)
         {
             cartItemInfo             = new ShoppingCartItemInfo();
             cartItemInfo.Description = orderItem.Title;
             cartItemInfo.Price       = orderItem.Rate;
             cartItemInfo.Quantity    = orderItem.Quantity;
             cartItemInfo.ProductId   = orderItem.ItemId;
             cartItemInfo.TotalPrice  = cartItemInfo.Quantity * cartItemInfo.Price;
             cartInfo1.SubTotal      += cartItemInfo.TotalPrice;
             cartInfo1.SubTotal       = Math.Round(cartInfo1.SubTotal, 2);
             cartItems.Add(cartItemInfo);
         }
         cartInfo1.CartItems = cartItems.ToArray();
         if (cardInfo.Address.State.Name.ToLower() == "colorado")
         {
             CommonService commonService = ServiceAccess.GetInstance().GetCommon();
             if (commonService.GetProperty("Tax") != null)
             {
                 cartInfo1.Tax = Convert.ToDecimal(commonService.GetProperty("Tax").Value);
             }
         }
         else
         {
             cartInfo1.Tax = 0;
         }
         ShoppingCartService cartService = ServiceAccess.GetInstance().GetShoppingCart();
         ShoppingCartInfo    cartInfo    = cartService.CalculateGrandTotal(cartInfo1);
         CartGridView.DataSource = cartInfo.CartItems;
         CartGridView.DataBind();
         SubTotalLiteral.Text   = cartInfo.SubTotal.ToString();
         ShippingLiteral.Text   = cartInfo.ShippingAndHandling.ToString();
         TaxLiteral.Text        = cartInfo.Tax.ToString();
         GrandTotalLiteral.Text = cartInfo.GrandTotal.ToString();
         DiscountLiteral.Text   = cartInfo.Discount.ToString();
     }
     else
     {
         ProductsPanel.Visible = false;
     }
 }
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Orders.Items"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Orders.Items");
        }

        // Get order id
        orderId = QueryHelper.GetInteger("orderid", 0);

        if (!RequestHelper.IsPostBack())
        {
            if (!QueryHelper.GetBoolean("cartexist", false))
            {
                this.ShoppingCart = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderId);
            }
        }

        if (orderId > 0)
        {
            if ((ShoppingCart != null) && (ShoppingCart.Order != null))
            {
                // Check order site ID
                CheckOrderSiteID(ShoppingCart.Order.OrderSiteID);
            }

            this.Cart.LocalShoppingCart = this.ShoppingCart;
            this.Cart.EnableProductPriceDetail = true;
            this.Cart.ShoppingCartInfoObj.IsCreatedFromOrder = true;
            this.Cart.CheckoutProcessType = CheckoutProcessEnum.CMSDeskOrderItems;
            this.Cart.OnPaymentCompleted += new EventHandler(Cart_OnPaymentCompleted);
            this.Cart.OnPaymentSkipped += new EventHandler(Cart_OnPaymentSkipped);
            this.Cart.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(Cart_OnCheckPermissions);
            this.Cart.RequiredFieldsMark = CMS.EcommerceProvider.ShoppingCart.DEFAULT_REQUIRED_FIELDS_MARK;
        }

        if (!RequestHelper.IsPostBack())
        {
            // Display 'Changes saved' message
            if (QueryHelper.GetBoolean("saved", false))
            {
                lblInfo.Visible = true;
                lblInfo.Text = GetString("General.ChangesSaved");
            }
            // Display 'Payment completed' message
            else if (QueryHelper.GetBoolean("paymentcompleted", false))
            {
                lblInfo.Visible = true;
                lblInfo.Text = GetString("PaymentGateway.CMSDeskOrderItems.PaymentCompleted");
            }
        }
    }
Beispiel #58
0
        private SelectList CreatePaymentMethodList(ShoppingCartInfo cart)
        {
            var paymentMethods = GetApplicablePaymentMethods(cart);

            return(new SelectList(paymentMethods, "PaymentOptionID", "PaymentOptionDisplayName"));
        }
        /// <summary>
        /// Create attendees for each product of the specified order.
        /// </summary>
        /// <param name="cart">Shopping cart object with order data.</param>
        public static void SetAttendees(ShoppingCartInfo cart)
        {
            if ((cart != null) && (cart.Customer != null))
            {                
                // Is order payment completed?
                var order = OrderInfoProvider.GetOrderInfo(cart.OrderId);
                var isPaymentCompleted = false;
                if (order != null)
                {
                    isPaymentCompleted = order.OrderIsPaid;
                }

                // Build WHERE condition to get specified tree nodes which represent specified products of the order
                var where = string.Empty;
                foreach (var item in cart.CartItems)
                {
                    where += item.SKUID + ",";                    
                }

                // Trim ending comma from WHERE condition
                if (where != "")
                {
                    where = where.Remove(where.Length - 1);
                    where = "NODESKUID IN (" + where + ")";
                }

                // Remove old attendees
                DeleteAttendees(cart.OrderId);

                // Select events (tree nodes) that represents specified products of the order
                var tree = new TreeProvider();
                DataSet ds = tree.SelectNodes(cart.SiteName, "/%", TreeProvider.ALL_CULTURES, false, "cms.bookingevent", where);

                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        // Get tree node ID of the event
                        int nodeId = ValidationHelper.GetInteger(dr["NodeID"], 0);

                        // Get product ID
                        int skuId = ValidationHelper.GetInteger(dr["SKUID"], 0);

                        // Get product units
                        int units = GetSKUShoppingCartUnits(cart, skuId);

                        // Create attendees and assign them to the specified event
                        for (int i = 1; i < units + 1; i++)
                        {                            
                            var attendee = new EventAttendeeInfo
                            {
                                AttendeeFirstName = cart.Customer.CustomerFirstName,
                                AttendeeLastName = cart.Customer.CustomerLastName + " (" + i + ")",
                                AttendeeEmail = cart.Customer.CustomerEmail,
                                AttendeeEventNodeID = nodeId
                            };
                            attendee.SetValue(COLUMN_ATTENDEE_ORDERID, cart.OrderId);
                            attendee.SetValue(COLUMN_ATTENDEE_PAYMENTCOMPLETED, isPaymentCompleted);

                            // Set attendee phone from billing address
                            var address = cart.ShoppingCartBillingAddress;
                            if (address != null)
                            {
                                attendee.AttendeePhone = address.AddressPhone;
                            }

                            EventAttendeeInfoProvider.SetEventAttendeeInfo(attendee);
                        }
                    }
                }
            }
        }
Beispiel #60
0
 private IEnumerable <PaymentOptionInfo> GetApplicablePaymentMethods(ShoppingCartInfo cart)
 {
     return(mPaymentMethodRepository.GetAll().Where(paymentMethod => PaymentOptionInfoProvider.IsPaymentOptionApplicable(cart, paymentMethod)));
 }