Пример #1
0
        private void lkbtnDeleteCheck_Click(object sender, EventArgs e)
        {
            int?nullable = null;

            foreach (GridViewRow row in this.grdCutDownList.Rows)
            {
                CheckBox box = (CheckBox)row.FindControl("checkboxCol");
                if (box.Checked)
                {
                    nullable = new int?(nullable.GetValueOrDefault());
                    int         cutDownId = Convert.ToInt32(this.grdCutDownList.DataKeys[row.RowIndex].Value, CultureInfo.InvariantCulture);
                    CutDownInfo cutDown   = PromoteHelper.GetCutDown(cutDownId);
                    nullable = new int?(nullable.GetValueOrDefault() + 1);
                    PromoteHelper.DeleteCutDown(cutDownId);
                }
            }
            if (nullable.HasValue)
            {
                this.BindCutDown();
                this.ShowMsg(string.Format("成功删除{0}条砍价活动", nullable), true);
            }
            else
            {
                this.ShowMsg("请先选择需要删除的砍价活动", false);
            }
        }
Пример #2
0
        /// <summary>
        /// 添加活动
        /// </summary>
        public int AddCutDown(CutDownInfo cutDown, DbTransaction dbTran = null)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DECLARE @DisplaySequence AS INT SELECT @DisplaySequence = (CASE WHEN MAX(DisplaySequence) IS NULL THEN 1 ELSE MAX(DisplaySequence) + 1 END) FROM Hishop_CutDown;INSERT INTO Hishop_CutDown(ProductId,FirstPrice,StartDate,EndDate,MaxCount,Content,Status,DisplaySequence,CurrentPrice,PerCutPrice,Count,MinPrice) VALUES(@ProductId,@FirstPrice,@StartDate,@EndDate,@MaxCount,@Content,@Status,@DisplaySequence,@CurrentPrice,@PerCutPrice,@Count,@MinPrice); SELECT @@IDENTITY");

            this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, cutDown.ProductId);
            this.database.AddInParameter(sqlStringCommand, "StartDate", DbType.DateTime, cutDown.StartDate);
            this.database.AddInParameter(sqlStringCommand, "EndDate", DbType.DateTime, cutDown.EndDate);
            this.database.AddInParameter(sqlStringCommand, "MaxCount", DbType.Int32, cutDown.MaxCount);
            this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, cutDown.Content);
            this.database.AddInParameter(sqlStringCommand, "PerCutPrice", DbType.String, cutDown.PerCutPrice);
            this.database.AddInParameter(sqlStringCommand, "Count", DbType.String, cutDown.Count);
            this.database.AddInParameter(sqlStringCommand, "MinPrice", DbType.String, cutDown.MinPrice);
            this.database.AddInParameter(sqlStringCommand, "FirstPrice", DbType.String, cutDown.CurrentPrice);
            this.database.AddInParameter(sqlStringCommand, "CurrentPrice", DbType.String, cutDown.CurrentPrice);
            this.database.AddInParameter(sqlStringCommand, "Status", DbType.Int32, 1);
            object obj2 = null;

            if (dbTran != null)
            {
                obj2 = this.database.ExecuteScalar(sqlStringCommand, dbTran);
            }
            else
            {
                obj2 = this.database.ExecuteScalar(sqlStringCommand);
            }
            if (obj2 != null)
            {
                return(Convert.ToInt32(obj2));
            }
            return(0);
        }
Пример #3
0
        /// <summary>
        /// 砍价
        /// </summary>
        public static string goCutDown(CutDownDetailInfo info)
        {
            CutDownInfo cutDown = GetCutDown(info.CutDownId);
            string      result  = "";

            //如果当前价格超过最低价, 并且活动时间结束,并且达到最大砍价次数,则返回提示信息
            if (cutDown.CurrentPrice <= cutDown.MinPrice)
            {
                return(result = "当前价格已经达到最低价,无法砍价!");
            }
            if (cutDown.EndDate <= DateTime.Now)
            {
                return(result = "活动已经结束,无法砍价!");
            }
            if (cutDown.MaxCount <= GetCutDownTotalCount(cutDown.CutDownId))
            {
                return(result = "当前砍价次数已经达到上限,无法砍价!");
            }
            //开始砍价
            if (new CutDownDao().goCutDown(info) && new CutDownDao().updateCurrentPrice(info.CutDownId, cutDown.PerCutPrice))
            {
                result = "success";
            }
            return(result);
        }
Пример #4
0
        public CutDownInfo GetCutDown(int cutDownId)
        {
            CutDownInfo info             = null;
            DbCommand   sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM vw_Hishop_CutDown WHERE CutDownId=@CutDownId;SELECT * FROM Hishop_cutdowndetail WHERE CutDownId=@CutDownId");

            this.database.AddInParameter(sqlStringCommand, "CutDownId", DbType.Int32, cutDownId);
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    info = DataMapper.PopulateCutDown(reader);
                }
                reader.NextResult();
                while (reader.Read())
                {
                    CutDownDetailInfo item = new CutDownDetailInfo
                    {
                        CutDownId    = (int)reader["CutDownId"],
                        MemberId     = (int)reader["MemberId"],
                        CutTime      = (DateTime)reader["CutTime"],
                        CutDownPrice = (decimal)reader["CutDownPrice"]
                    };
                    info.CutDownDetails.Add(item);
                }
            }
            return(info);
        }
Пример #5
0
        public static bool AddCutDown(CutDownInfo cutDown)
        {
            bool flag;

            Globals.EntityCoding(cutDown, true);
            using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
            {
                connection.Open();
                DbTransaction dbTran = connection.BeginTransaction();
                try
                {
                    CutDownDao dao       = new CutDownDao();
                    int        cutDownId = dao.AddCutDown(cutDown, dbTran);
                    if (cutDownId <= 0)
                    {
                        dbTran.Rollback();
                        return(false);
                    }
                    dbTran.Commit();
                    flag = true;
                }
                catch (Exception)
                {
                    dbTran.Rollback();
                    flag = false;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(flag);
        }
Пример #6
0
 private void grdCutDownList_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         CutDownInfo        cutDown = PromoteHelper.GetCutDown((int)this.grdCutDownList.DataKeys[e.Row.RowIndex].Value);
         FormatedMoneyLabel label   = (FormatedMoneyLabel)e.Row.FindControl("lblCurrentPrice");
         label.Money = cutDown.CurrentPrice;
     }
 }
Пример #7
0
        private void LoadCutDown(CutDownInfo cutDown)
        {
            this.TxtCount.Text       = cutDown.Count.ToString();
            this.TxtMaxCount.Text    = cutDown.MaxCount.ToString();
            this.TxtPerCutPrice.Text = cutDown.PerCutPrice.ToString("F2");
            this.TxtMinPrice.Text    = cutDown.MinPrice.ToString("F2");
            this.txtContent.Text     = Globals.HtmlDecode(cutDown.Content);

            this.calendarEndDate.SelectedDate     = new DateTime?(cutDown.EndDate.Date);
            this.calendarStartDate.SelectedDate   = new DateTime?(cutDown.StartDate.Date);
            this.drophours.SelectedValue          = new int?(cutDown.StartDate.Hour);
            this.HourDropDownList1.SelectedValue  = new int?(cutDown.EndDate.Hour);
            this.dropCutDownProduct.SelectedValue = new int?(cutDown.ProductId);
        }
Пример #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(base.Request["isCallback"]) && (base.Request["isCallback"] == "true"))
     {
         int num;
         if (int.TryParse(base.Request["productId"], out num))
         {
             string priceByProductId = PromoteHelper.GetPriceByProductId(num);
             if (priceByProductId.Length > 0)
             {
                 base.Response.Clear();
                 base.Response.ContentType = "application/json";
                 base.Response.Write("{ ");
                 base.Response.Write("\"Status\":\"OK\",");
                 base.Response.Write(string.Format("\"Price\":\"{0}\"", decimal.Parse(priceByProductId).ToString("F2")));
                 base.Response.Write("}");
                 base.Response.End();
             }
         }
     }
     else if (!int.TryParse(base.Request.QueryString["cutDownId"], out this.cutDownId))
     {
         base.GotoResourceNotFound();
     }
     else
     {
         this.btnUpdateCutDown.Click += new EventHandler(this.btnUpdateCutDown_Click);
         if (!base.IsPostBack)
         {
             this.dropCutDownProduct.DataBind();
             this.dropCategories.DataBind();
             this.HourDropDownList1.DataBind();
             this.drophours.DataBind();
             CutDownInfo cutDown = PromoteHelper.GetCutDown(this.cutDownId);
             if (PromoteHelper.GetCutDownOrderCount(this.cutDownId) > 0)
             {
                 this.dropCutDownProduct.Enabled = false;
             }
             if (cutDown == null)
             {
                 base.GotoResourceNotFound();
             }
             else
             {
                 this.LoadCutDown(cutDown);
             }
         }
     }
 }
Пример #9
0
        /// <summary>
        /// 更新砍价活动
        /// </summary>

        public bool UpdateCutDown(CutDownInfo cutDown, DbTransaction dbTran)
        {//(ProductId,StartDate,EndDate,MaxCount,Content,Status,DisplaySequence,PerCutPrice,Count,MinPrice) VALUES(@ProductId,,@StartDate,@EndDate,@MaxCount,@Content,@Status,@DisplaySequence,@PerCutPrice,@Count,@MinPrice)
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Hishop_CutDown SET ProductId=@ProductId,StartDate=@StartDate,EndDate=@EndDate,MaxCount=@MaxCount,Content=@Content,PerCutPrice=@PerCutPrice,Count=@Count,MinPrice=@MinPrice WHERE CutDownId=@CutDownId");

            this.database.AddInParameter(sqlStringCommand, "CutDownId", DbType.Int32, cutDown.CutDownId);
            this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, cutDown.ProductId);
            this.database.AddInParameter(sqlStringCommand, "StartDate", DbType.DateTime, cutDown.StartDate);
            this.database.AddInParameter(sqlStringCommand, "EndDate", DbType.DateTime, cutDown.EndDate);
            this.database.AddInParameter(sqlStringCommand, "MaxCount", DbType.Int32, cutDown.MaxCount);
            this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, cutDown.Content);
            this.database.AddInParameter(sqlStringCommand, "PerCutPrice", DbType.String, cutDown.PerCutPrice);
            this.database.AddInParameter(sqlStringCommand, "Count", DbType.String, cutDown.Count);
            this.database.AddInParameter(sqlStringCommand, "MinPrice", DbType.String, cutDown.MinPrice);
            if (dbTran != null)
            {
                return(this.database.ExecuteNonQuery(sqlStringCommand, dbTran) == 1);
            }
            return(this.database.ExecuteNonQuery(sqlStringCommand) == 1);
        }
Пример #10
0
        private void grdCutDownList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            CutDownInfo cutDown = PromoteHelper.GetCutDown((int)this.grdCutDownList.DataKeys[e.RowIndex].Value);

            /*
             * if ((cutDown.Status == CutDownStatus.) || (groupBuy.Status == GroupBuyStatus.EndUntreated))
             * {
             *  this.ShowMsg("团购活动正在进行中或结束未处理,不允许删除", false);
             * }
             */
            if (PromoteHelper.DeleteCutDown((int)this.grdCutDownList.DataKeys[e.RowIndex].Value))
            {
                this.BindCutDown();
                this.ShowMsg("成功删除了选择的砍价活动", true);
            }
            else
            {
                this.ShowMsg("删除失败", false);
            }
        }
Пример #11
0
        public static bool UpdateCutDown(CutDownInfo cutDown)
        {
            bool flag;

            Globals.EntityCoding(cutDown, true);
            using (DbConnection connection = DatabaseFactory.CreateDatabase().CreateConnection())
            {
                connection.Open();
                DbTransaction dbTran = connection.BeginTransaction();
                try
                {
                    CutDownDao dao = new CutDownDao();
                    if (!dao.UpdateCutDown(cutDown, dbTran))
                    {
                        dbTran.Rollback();
                        return(false);
                    }

                    /*
                     * if (!dao.DeleteCutDownDetail(cutDown.CutDownId, dbTran))
                     * {
                     *  dbTran.Rollback();
                     *  return false;
                     * }
                     */
                    dbTran.Commit();
                    flag = true;
                }
                catch (Exception)
                {
                    dbTran.Rollback();
                    flag = false;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(flag);
        }
Пример #12
0
        public static ShoppingCartInfo GetCutDownShoppingCart(string productSkuId, int buyAmount, int cutDownId)
        {
            ShoppingCartItemInfo info5;
            ShoppingCartInfo     info  = new ShoppingCartInfo();
            ShoppingCartItemInfo info2 = new ShoppingCartDao().GetCartItemInfo(MemberProcessor.GetCurrentMember(), productSkuId, buyAmount);

            if (info2 == null)
            {
                return(null);
            }
            CutDownInfo cutDownInfo = Hidistro.ControlPanel.Promotions.PromoteHelper.GetCutDown(cutDownId);;

            if (cutDownInfo == null)
            {
                return(null);
            }
            info5 = new ShoppingCartItemInfo
            {
                SkuId     = info2.SkuId,
                ProductId = info2.ProductId,
                SKU       = info2.SKU,
                Name      = info2.Name,

                SkuContent = info2.SkuContent,

                Weight           = info2.Weight,
                ThumbnailUrl40   = info2.ThumbnailUrl40,
                ThumbnailUrl60   = info2.ThumbnailUrl60,
                ThumbnailUrl100  = info2.ThumbnailUrl100,
                IsfreeShipping   = info2.IsfreeShipping,
                MainCategoryPath = info2.MainCategoryPath,
            };

            info5.MemberPrice = info5.AdjustedPrice = cutDownInfo.CurrentPrice;
            info5.Quantity    = info5.ShippQuantity = buyAmount;
            info.LineItems.Add(info5);
            return(info);
        }
Пример #13
0
        protected override void AttachChildControls()
        {
            this.litShipTo           = (Literal)this.FindControl("litShipTo");
            this.litCellPhone        = (Literal)this.FindControl("litCellPhone");
            this.litAddress          = (Literal)this.FindControl("litAddress");
            this.rptCartProducts     = (VshopTemplatedRepeater)this.FindControl("rptCartProducts"); //商品
            this.rptCartGifts        = (VshopTemplatedRepeater)this.FindControl("rptCartGifts");    //礼品
            this.dropShippingType    = (Common_ShippingTypeSelect)this.FindControl("dropShippingType");
            this.dropCoupon          = (Common_CouponSelect)this.FindControl("dropCoupon");
            this.dropRedPager        = (Common_UserRedPagerSelect)this.FindControl("dropRedPager");
            this.dropStreets         = (Common_StreetSelect)this.FindControl("dropStreets"); //街道下拉框
            this.dropAgents          = (Common_AgentSelect)this.FindControl("dropAgents");   //天使下拉框
            this.litOrderTotal       = (Literal)this.FindControl("litOrderTotal");
            this.litTotalPoint       = (Literal)this.FindControl("litTotalPoint");           //所需积分
            this.isSelectAgentEnable = (HtmlInputHidden)this.FindControl("isSelectAgentEnable");
            this.hiddenCartTotal     = (HtmlInputHidden)this.FindControl("hiddenCartTotal");
            this.aLinkToShipping     = (HtmlAnchor)this.FindControl("aLinkToShipping");
            this.groupbuyHiddenBox   = (HtmlInputControl)this.FindControl("groupbuyHiddenBox");
            this.countdownHiddenBox  = (HtmlInputControl)this.FindControl("countdownHiddenBox");
            this.cutdownHiddenBox    = (HtmlInputControl)this.FindControl("cutdownHiddenBox");
            this.couponRecharge      = (HtmlInputHidden)this.FindControl("couponRecharge");
            this.usercount           = (HtmlInputHidden)this.FindControl("usercount");
            this.rptAddress          = (VshopTemplatedRepeater)this.FindControl("rptAddress");
            this.selectShipTo        = (HtmlInputHidden)this.FindControl("selectShipTo");
            this.regionId            = (HtmlInputHidden)this.FindControl("regionId");
            Literal literal = (Literal)this.FindControl("litProductTotalPrice");

            this.litExemption      = (Literal)this.FindControl("litExemption");
            this.litAddAddress     = (Literal)this.FindControl("litAddAddress");
            this.isStreetEnable    = (HtmlInputHidden)this.FindControl("isStreetEnable");
            this.isStreetMatch     = (HtmlInputHidden)this.FindControl("isStreetMatch");
            this.claimcode         = (HtmlInputHidden)this.FindControl("claimcode");
            this.litExemption.Text = "0.00";
            IList <ShippingAddressInfo> shippingAddresses = MemberProcessor.GetShippingAddresses();

            this.rptAddress.DataSource = from item in shippingAddresses
                                         orderby item.IsDefault
                                         select item;

            this.rptAddress.DataBind();
            this.rptCartProducts.ItemDataBound += new RepeaterItemEventHandler(this.rptCartProducts_ItemDataBound);
            ShippingAddressInfo info = shippingAddresses.FirstOrDefault <ShippingAddressInfo>(item => item.IsDefault);

            if (info == null)
            {
                info = (shippingAddresses.Count > 0) ? shippingAddresses[0] : null;
            }

            if (info != null)
            {
                this.litShipTo.Text    = info.ShipTo;
                this.litCellPhone.Text = info.CellPhone;
                this.litAddress.Text   = info.Address;
                this.selectShipTo.SetWhenIsNotNull(info.ShippingId.ToString());
                this.regionId.SetWhenIsNotNull(info.RegionId.ToString());
            }
            this.litAddAddress.Text = " href='/Vshop/AddShippingAddress.aspx?returnUrl=" + HttpContext.Current.Request.Url.ToString() + "'";
            if (CustomConfigHelper.Instance.IsProLa)
            {
                this.litAddAddress.Text = " href='/Vshop/AddShippingAddressPro.aspx?returnUrl=" + HttpContext.Current.Request.Url.ToString() + "'";
            }
            if ((shippingAddresses == null) || (shippingAddresses.Count == 0))
            {
                this.Page.Response.Redirect(Globals.ApplicationPath + "/Vshop/AddShippingAddress.aspx?returnUrl=" + HttpContext.Current.Request.Url.ToString());
            }
            else
            {
                this.aLinkToShipping.HRef = Globals.ApplicationPath + "/Vshop/ShippingAddresses.aspx?returnUrl=" + HttpContext.Current.Request.Url.ToString();
                ShoppingCartInfo shoppingCart = null;
                string           msg          = "";
                string           str          = this.Page.Request.QueryString["from"];
                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.Page.Request.QueryString["from"] == "groupBuy") || (this.Page.Request.QueryString["from"] == "countDown") || (this.Page.Request.QueryString["from"] == "cutDown")))
                {
                    this.productSku = this.Page.Request.QueryString["productSku"];

                    //团购//待完善
                    if ((str == "groupBuy") && int.TryParse(this.Page.Request.QueryString["groupbuyId"], out this.groupBuyId))
                    {
                        this.groupbuyHiddenBox.SetWhenIsNotNull(this.groupBuyId.ToString());
                        shoppingCart = ShoppingCartProcessor.GetGroupBuyShoppingCart(this.groupBuyId, this.productSku, this.buyAmount);
                    }
                    //限时抢购
                    else if ((str == "countDown") && int.TryParse(this.Page.Request.QueryString["countdownId"], out this.countDownId))
                    {
                        this.countdownHiddenBox.SetWhenIsNotNull(this.countDownId.ToString());
                        CountDownInfo info4 = ProductBrowser.GetCountDownInfo(this.countDownId, this.buyAmount, out msg);
                        if (info4 == null)
                        {
                            base.GotoResourceNotFound(msg);
                            return;
                        }
                        if (string.IsNullOrEmpty(this.productSku) || (this.productSku.Split(new char[] { '_' })[0] != info4.ProductId.ToString()))
                        {
                            base.GotoResourceNotFound("错误的商品信息");
                            return;
                        }

                        shoppingCart = ShoppingCartProcessor.GetCountDownShoppingCart(this.productSku, this.buyAmount);
                    }
                    //砍价
                    else if ((str == "cutDown") && int.TryParse(this.Page.Request.QueryString["cutDownId"], out this.cutDownId))
                    {
                        this.cutdownHiddenBox.SetWhenIsNotNull(this.cutDownId.ToString());
                        CutDownInfo info5 = PromoteHelper.GetCutDown(this.cutDownId);
                        if (info5 == null)
                        {
                            base.GotoResourceNotFound();
                            return;
                        }
                        if (string.IsNullOrEmpty(this.productSku) || (this.productSku.Split(new char[] { '_' })[0] != info5.ProductId.ToString()))
                        {
                            base.GotoResourceNotFound("错误的商品信息");
                            return;
                        }

                        shoppingCart = ShoppingCartProcessor.GetCutDownShoppingCart(this.productSku, this.buyAmount, info5.CutDownId);
                    }
                    else
                    {
                        shoppingCart = ShoppingCartProcessor.GetShoppingCart(this.productSku, this.buyAmount);
                    }
                }
                else
                {
                    shoppingCart = ShoppingCartProcessor.GetShoppingCart();
                }



                //获取/新建了购物车对象后,进行商品价格根据分销商特殊优惠设置进行减价处理.
                MemberInfo currentMember = MemberProcessor.GetCurrentMember();
                int        distributorid = Globals.GetCurrentDistributorId();
                //根据分销商的特殊优惠设置进行计算返佣
                switch (SettingsManager.GetMasterSettings(false).DistributorCutOff)
                {
                case "default":    //直接退出,没有任何操作一切照常
                    break;

                case "bycostprice":                            //根据进货价进行返佣
                    if (currentMember.UserId != distributorid) //如果不是分销商购买自己的产品,则退出特殊处理
                    {
                        break;
                    }
                    for (int i = 0; i < shoppingCart.LineItems.Count; i++)
                    {
                        shoppingCart.LineItems[i].AdjustedPrice = ProductHelper.GetSkuCostPrice(shoppingCart.LineItems[i].SkuId);
                    }
                    break;

                default:                                       //根据指定折扣进行返佣(此种情况下,不存在直接分佣)
                    if (currentMember.UserId != distributorid) //如果不是分销商购买自己的产品,则退出特殊处理
                    {
                        break;
                    }
                    decimal rate = Convert.ToDecimal(SettingsManager.GetMasterSettings(false).DistributorCutOff) / 100;    //获取折扣比例
                    for (int i = 0; i < shoppingCart.LineItems.Count; i++)
                    {
                        shoppingCart.LineItems[i].AdjustedPrice = shoppingCart.LineItems[i].AdjustedPrice * rate;
                    }
                    break;
                }

                if (shoppingCart != null)
                {
                    //根据购物车内商品名是否为[会员充值]和是否开启了会员充值送优惠券的功能来给隐藏域赋值,前端js再进行相应的隐藏显示,默认选中等处理
                    if (shoppingCart.LineItems.Where(n => n.Name == "会员充值") != null && shoppingCart.LineItems.Where(n => n.Name == "会员充值").Count() == 1 && CustomConfigHelper.Instance.CouponRecharge)
                    {
                        this.couponRecharge.Value = "1";
                    }
                    else
                    {
                        this.couponRecharge.Value = "0";
                    }
                    //提交订单前先检查是否达到规则要求上限
                    if (!TradeHelper.CheckShoppingStock(shoppingCart, out msg))
                    {
                        this.ShowMessage("订单中有商品(" + msg + ")库存不足", false);
                        if (!this.Page.ClientScript.IsClientScriptBlockRegistered("AlertStockScript"))
                        {
                            StringBuilder builder = new StringBuilder();
                            builder.AppendLine("var stockError = true;");
                            builder.AppendLine(string.Format("var stockErrorInfo=\"订单中有商品({0})库存不足,请返回购物车修改库存.\";", msg));
                            this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "AlertStockScript", "var stockError=true;function AlertStock(){alert('订单中有商品(" + msg + ")库存不足,请返回购物车修改库存.');}", true);
                        }
                    }

                    //当前用户已使用的优惠券信息
                    DataTable userCoupon = CouponHelper.GetUserCoupons(currentMember.UserId, 2);    //代表已使用的
                    if (userCoupon.Rows.Count > 0)
                    {
                        this.usercount.Value = "1";
                    }
                    else
                    {
                        ////把当前用户所有优惠券信息取出来
                        DataTable userCouponList = CouponHelper.GetUserCoupons(currentMember.UserId, 1);    //1代表未使用的,有效期内的
                        ////对当前购物车shoppingCart.LineItems进行循环查找,如果优惠券的categoryId与商品的品类不匹配,把优惠券的claimcode取出来放到隐藏域内,传递到前台,前台再进行相关的隐藏操作
                        foreach (ShoppingCartItemInfo shopp in shoppingCart.LineItems)
                        {
                            foreach (DataRow coupon in userCouponList.Rows)
                            {
                                if (!Convert.IsDBNull(coupon["CategoryId"]))
                                {
                                    int cp = Convert.ToInt32(coupon["CategoryId"]);
                                    if (shopp.CategoryId != cp && cp != 0)
                                    {
                                        claimcode.Value += coupon["ClaimCode"].ToString() + ";";
                                    }
                                }
                            }
                        }
                    }
                    claimcode.Value = claimcode.Value.TrimEnd(';');


                    this.rptCartProducts.DataSource = shoppingCart.LineItems;
                    this.rptCartProducts.DataBind();
                    //绑定礼品
                    this.rptCartGifts.DataSource = shoppingCart.LineGifts;
                    this.rptCartGifts.DataBind();
                    //绑定配送方式
                    this.dropShippingType.ShoppingCartItemInfo = shoppingCart.LineItems;
                    this.dropShippingType.RegionId             = 0;
                    this.dropShippingType.Weight = shoppingCart.Weight;
                    this.dropCoupon.CartTotal    = shoppingCart.GetTotal();

                    //addby hj 2015-04-23(迪蔓)
                    this.isSelectAgentEnable.Value = CustomConfigHelper.Instance.SelectServerAgent.ToString();
                    //addby hj 2015-12-25(爽爽挝咖)
                    //给出是否开启街道选择和门店配送功能的标识
                    this.isStreetEnable.Value = Hidistro.ControlPanel.Config.CustomConfigHelper.Instance.AutoShipping.ToString();
                    //绑定街道下拉框
                    if (this.isStreetEnable.Value == "True")
                    {
                        DataTable dtStreetsInfo = Hidistro.ControlPanel.Sales.SalesHelper.GetStreetInfo(regionId.Value.ToString());
                        if (dtStreetsInfo.Rows.Count > 0)
                        {
                            this.dropStreets.StreetsInfo = dtStreetsInfo;
                            this.isStreetMatch.Value     = "True";
                        }
                        else//此种情况下消费者的所在区域内并没有相应的配送店铺,给出提示,页面无法提交
                        {
                            this.isStreetMatch.Value = "False";
                        }
                    }
                    string    noCouponIds    = string.Empty;
                    string    tempCategoryId = string.Empty;
                    DataTable dtDB           = CouponHelper.GetCouponAllCate(); //new DataTable();//设置的使用权限的有效期内的优惠卷 两表关联信息
                    foreach (DataRow dr in dtDB.Rows)
                    {
                        tempCategoryId = "," + dr["CategoryIds"].ToString() + ",";
                        decimal dAmount = (decimal)dr["Amount"];

                        //计算排除掉不能参与的分类金额
                        //shoppingCart.LineItems
                        decimal dAmount2 = dropCoupon.CartTotal;
                        foreach (ShoppingCartItemInfo scii in shoppingCart.LineItems)
                        {
                            if (tempCategoryId.IndexOf("," + scii.CategoryId + ",") > -1)
                            {
                                dAmount2 -= scii.SubTotal;
                            }
                        }

                        //待排除的
                        if (dAmount > dAmount2)
                        {
                            noCouponIds += dr["CouponId"] + ",";
                        }
                    }
                    if (noCouponIds != "")
                    {
                        noCouponIds = noCouponIds.TrimEnd(',');
                    }
                    this.dropCoupon.CouponIds   = noCouponIds;
                    this.dropRedPager.CartTotal = shoppingCart.GetTotal();
                    this.hiddenCartTotal.Value  = literal.Text = shoppingCart.GetTotal().ToString("F2");
                    decimal num = this.DiscountMoney(shoppingCart.LineItems);
                    this.litOrderTotal.Text = (shoppingCart.GetTotal() - num).ToString("F2");
                    this.litTotalPoint.Text = getTotalPoints(shoppingCart).ToString();
                    this.litExemption.Text  = num.ToString("0.00");
                }
                else
                {
                    this.Page.Response.Redirect("/Vshop/ShoppingCart.aspx");
                }
                PageTitle.AddSiteNameTitle("订单确认");
            }
        }
Пример #14
0
        private void btnAddCutDown_Click(object sender, EventArgs e)
        {
            int         num2;
            int         num3;
            decimal     num4;
            CutDownInfo cutDown = new CutDownInfo();
            string      str     = string.Empty;

            if (this.dropCutDownProduct.SelectedValue > 0)
            {
                if (PromoteHelper.ProductCutDownExist(this.dropCutDownProduct.SelectedValue.Value))
                {
                    this.ShowMsg("已经存在此商品的团购活动,并且活动正在进行中", false);
                    return;
                }
                cutDown.ProductId = this.dropCutDownProduct.SelectedValue.Value;
            }
            else
            {
                str = str + Formatter.FormatErrorMessage("请选择团购商品");
            }
            if (!this.calendarStartDate.SelectedDate.HasValue)
            {
                str = str + Formatter.FormatErrorMessage("请选择开始日期");
            }
            if (!this.calendarEndDate.SelectedDate.HasValue)
            {
                str = str + Formatter.FormatErrorMessage("请选择结束日期");
            }
            else
            {
                cutDown.EndDate = this.calendarEndDate.SelectedDate.Value.AddHours((double)this.HourDropDownList1.SelectedValue.Value);
                if (DateTime.Compare(cutDown.EndDate, DateTime.Now) < 0)
                {
                    str = str + Formatter.FormatErrorMessage("结束日期必须要晚于今天日期");
                }
                else if (DateTime.Compare(this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value), cutDown.EndDate) >= 0)
                {
                    str = str + Formatter.FormatErrorMessage("开始日期必须要早于结束日期");
                }
                else
                {
                    cutDown.StartDate = this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value);
                }
            }
            //每次砍价金额
            if (!string.IsNullOrEmpty(this.TxtPerCutPrice.Text))
            {
                decimal num;
                if (decimal.TryParse(this.TxtPerCutPrice.Text.Trim(), out num))
                {
                    cutDown.PerCutPrice = num;
                }
                else
                {
                    str = str + Formatter.FormatErrorMessage("每次砍价金额填写格式不正确");
                }
            }
            //最低金额
            if (!string.IsNullOrEmpty(this.TxtMinPrice.Text))
            {
                decimal num;
                if (decimal.TryParse(this.TxtMinPrice.Text.Trim(), out num))
                {
                    cutDown.MinPrice = num;
                }
                else
                {
                    str = str + Formatter.FormatErrorMessage("最低金额填写格式不正确");
                }
            }
            //最大砍价次数
            if (int.TryParse(this.TxtMaxCount.Text.Trim(), out num2))
            {
                cutDown.MaxCount = num2;
            }
            else
            {
                str = str + Formatter.FormatErrorMessage("最大砍价次数数量不能为空,只能为整数");
            }
            //限购总数量
            if (int.TryParse(this.TxtCount.Text.Trim(), out num3))
            {
                cutDown.Count = num3;
            }
            else
            {
                str = str + Formatter.FormatErrorMessage("限购总数量不能为空,只能为整数");
            }
            //最大购买数量不得小于商品的库存

            //起始价格
            if (!string.IsNullOrEmpty(this.TxtCurrentPrice.Text))
            {
                decimal num;
                if (decimal.TryParse(this.TxtCurrentPrice.Text.Trim(), out num))
                {
                    cutDown.CurrentPrice = num;
                }
                else
                {
                    str = str + Formatter.FormatErrorMessage("起始金额填写格式不正确");
                }
            }

            if (!string.IsNullOrEmpty(str))
            {
                this.ShowMsg(str, false);
            }
            else
            {
                cutDown.Content = this.txtContent.Text;
                if (PromoteHelper.AddCutDown(cutDown))
                {
                    this.ShowMsg("添加砍价活动成功", true);
                }
                else
                {
                    this.ShowMsg("添加砍价活动失败", true);
                }
            }
        }
Пример #15
0
        private Literal litEndtime;//抢购结束时间

        protected override void AttachChildControls()
        {
            if (!int.TryParse(this.Page.Request.QueryString["cutDownId"], out this.cutDownId))
            {
                base.GotoResourceNotFound("");
            }
            this.rptProductImages      = (VshopTemplatedRepeater)this.FindControl("rptProductImages");
            this.litItemParams         = (Literal)this.FindControl("litItemParams");
            this.litProdcutName        = (Literal)this.FindControl("litProdcutName");
            this.litActivities         = (Literal)this.FindControl("litActivities");
            this.litSalePrice          = (Literal)this.FindControl("litSalePrice");    //原价
            this.litCurrentPrice       = (Literal)this.FindControl("litCurrentPrice"); //当前价格
            this.litShortDescription   = (Literal)this.FindControl("litShortDescription");
            this.litDescription        = (Literal)this.FindControl("litDescription");
            this.litStock              = (Literal)this.FindControl("litStock");
            this.skuSelector           = (Common_SKUSelector)this.FindControl("skuSelector");
            this.linkDescription       = (HyperLink)this.FindControl("linkDescription");
            this.expandAttr            = (Common_ExpandAttributes)this.FindControl("ExpandAttributes");
            this.litSoldCount          = (Literal)this.FindControl("litSoldCount");
            this.litConsultationsCount = (Literal)this.FindControl("litConsultationsCount");
            this.litReviewsCount       = (Literal)this.FindControl("litReviewsCount");
            this.litHasCollected       = (HtmlInputHidden)this.FindControl("litHasCollected");
            this.litCategoryId         = (HtmlInputHidden)this.FindControl("litCategoryId");
            this.litproductid          = (HtmlInputHidden)this.FindControl("litproductid");
            this.litCutDownId          = (HtmlInputControl)this.FindControl("litCutDownId");
            this.litEndtime            = (Literal)this.FindControl("litEndtime");//抢购结束时间
            //ProductInfo product = ProductBrowser.GetProduct(MemberProcessor.GetCurrentMember(), this.productId);
            CutDownInfo  cutDownInfo    = PromoteHelper.GetCutDown(this.cutDownId);
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);
            //ProductBrowseInfo info2 = ProductBrowser.GetProductBrowseInfo(countDownInfoByCountDownId.ProductId, null, null, masterSettings.StoreStockValidateType, masterSettings.OpenMultStore);
            ProductInfo product = ProductBrowser.GetProduct(MemberProcessor.GetCurrentMember(), cutDownInfo.ProductId);

            this.litproductid.Value = product.ProductId.ToString();

            if (!string.IsNullOrEmpty(this.litActivities.Text) && (product == null))
            {
                base.GotoResourceNotFound("此商品已不存在");
            }
            if (product.SaleStatus != ProductSaleStatus.OnSale)
            {
                base.GotoResourceNotFound("此商品已下架");
            }
            if (this.rptProductImages != null)
            {
                string       locationUrl = "javascript:;";
                SlideImage[] imageArray  = new SlideImage[] { new SlideImage(product.ImageUrl1, locationUrl), new SlideImage(product.ImageUrl2, locationUrl), new SlideImage(product.ImageUrl3, locationUrl), new SlideImage(product.ImageUrl4, locationUrl), new SlideImage(product.ImageUrl5, locationUrl) };
                this.rptProductImages.DataSource = from item in imageArray
                                                   where !string.IsNullOrWhiteSpace(item.ImageUrl)
                                                   select item;
                this.rptProductImages.DataBind();
            }
            string mainCategoryPath = product.MainCategoryPath;

            if (!string.IsNullOrEmpty(mainCategoryPath))
            {
                this.litCategoryId.Value = mainCategoryPath.Split(new char[] { '|' })[0];
            }
            else
            {
                this.litCategoryId.Value = "0";
            }
            this.litProdcutName.Text = product.ProductName;
            this.litSalePrice.Text   = cutDownInfo.FirstPrice.ToString("F2");//原价是该活动的初始价
            if (product.MarketPrice.HasValue)
            {
                this.litCurrentPrice.SetWhenIsNotNull(cutDownInfo.CurrentPrice.ToString("F2"));//现价是该商品的被砍后的价格
            }
            this.litShortDescription.Text = product.ShortDescription;
            if (this.litDescription != null)
            {
                this.litDescription.Text = product.Description;
            }
            this.litSoldCount.SetWhenIsNotNull(product.ShowSaleCounts.ToString());
            this.litStock.Text         = cutDownInfo.Count.ToString(); //库存为限购数量
            this.skuSelector.ProductId = cutDownInfo.ProductId;        //为型号选择器绑定productid
            if (this.litEndtime != null)                               //倒计时
            {
                this.litEndtime.Text = Convert.ToDateTime(cutDownInfo.EndDate).ToString();
            }
            this.skuSelector.ProductId = cutDownInfo.ProductId;
            if (this.expandAttr != null)
            {
                this.expandAttr.ProductId = cutDownInfo.ProductId;
            }
            if (this.linkDescription != null)
            {
                this.linkDescription.NavigateUrl = "/Vshop/ProductDescription.aspx?productId=" + cutDownInfo.ProductId;
            }
            this.litConsultationsCount.SetWhenIsNotNull(ProductBrowser.GetProductConsultationsCount(cutDownInfo.ProductId, false).ToString());
            this.litReviewsCount.SetWhenIsNotNull(ProductBrowser.GetProductReviewsCount(cutDownInfo.ProductId).ToString());
            MemberInfo currentMember = MemberProcessor.GetCurrentMember();
            bool       flag          = false;

            if (currentMember != null)
            {
                flag = ProductBrowser.CheckHasCollect(currentMember.UserId, cutDownInfo.ProductId);
            }
            this.litHasCollected.SetWhenIsNotNull(flag ? "1" : "0");
            ProductBrowser.UpdateVisitCounts(cutDownInfo.ProductId);
            PageTitle.AddSiteNameTitle("商品详情");
            string str3 = "";

            if (!string.IsNullOrEmpty(masterSettings.GoodsPic))
            {
                str3 = Globals.HostPath(HttpContext.Current.Request.Url) + masterSettings.GoodsPic;
            }
            this.litItemParams.Text = string.Concat(new object[] { str3, "|", masterSettings.GoodsName, "|", masterSettings.GoodsDescription, "$", Globals.HostPath(HttpContext.Current.Request.Url), product.ImageUrl1, "|", this.litProdcutName.Text, "|", product.ShortDescription, "|", HttpContext.Current.Request.Url });
            this.litCutDownId.SetWhenIsNotNull(cutDownInfo.CutDownId.ToString());
        }
Пример #16
0
        protected override void AttachChildControls()
        {
            BindControls();
            MemberInfo  currentMember  = MemberProcessor.GetCurrentMember();                                                                    //当前用户
            CutDownInfo cutDown        = new CutDownInfo();
            ProductInfo currentProduct = ProductBrowser.GetProduct(currentMember, Convert.ToInt32(this.Page.Request.QueryString["productId"])); //当前商品

            if (currentMember == null)
            {
                this.Page.Response.Redirect("UserLogin.aspx");
            }
            if (int.TryParse(this.Page.Request.QueryString["CutDownId"], out cutDownId))
            {
                cutDown = PromoteHelper.GetCutDown(cutDownId);
                if (cutDown == null)
                {
                    GotoResourceNotFound("当前活动已结束!");
                }
            }
            else
            {
                GotoResourceNotFound();
            }
            //当前用户id
            if (this.hidMemberId != null)
            {
                this.hidMemberId.Value = currentMember.UserId.ToString();
            }
            //砍价id(隐藏域)
            if (this.hidCutDownId != null)
            {
                this.hidCutDownId.Value = this.cutDownId.ToString();
            }
            //头像
            if (!string.IsNullOrEmpty(currentMember.UserHead))
            {
                this.image.ImageUrl = currentMember.UserHead;
            }
            //用户名
            if (this.litUserName != null)
            {
                this.litUserName.Text = currentMember.UserName;
            }
            //最底价
            if (this.litMinPrice != null)
            {
                this.litMinPrice.Text = cutDown.MinPrice.ToString("F2");
            }
            //当前价
            if (this.litCurrentPrice != null)
            {
                this.litCurrentPrice.Text = cutDown.CurrentPrice.ToString("F2");
            }
            //被砍总价
            if (this.litCutDownPriceTotal != null)
            {
                this.litCutDownPriceTotal.Text = PromoteHelper.GetCutDownTotalPrice(cutDown.CutDownId).ToString("F2");
            }
            //当前用户是否已经参加砍价
            if (this.hidIsAlreadyCut != null)
            {
                this.hidIsAlreadyCut.Value = PromoteHelper.IsAlreadyCut(this.cutDownId, currentMember.UserId).ToString();
            }
            //活动详情
            if (this.litContent != null)
            {
                this.litContent.Text = HttpUtility.HtmlDecode(cutDown.Content);
            }

            //获取最新列表
            CutDownDetailsQuery dQuery = new CutDownDetailsQuery()
            {
                PageSize  = 30,
                PageIndex = 1,
                CutDownId = cutDown.CutDownId,
                SortBy    = "cutTime",
                SortOrder = SortAction.Desc,
            };
            DataTable  dtCutDownDetailList = (DataTable)PromoteHelper.GetCutDownDetailList(dQuery).Data;//获取砍价详情
            string     detailList          = "";
            MemberInfo rowMember           = new MemberInfo();

            foreach (DataRow row in dtCutDownDetailList.Rows)
            {
                rowMember = MemberProcessor.GetMember((Convert.ToInt32(row["memberId"])));
                if (rowMember == null)
                {
                    continue;
                }
                string MemberName  = rowMember.UserName;
                string cutTime     = DateTime.Parse(row["cutTime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                string imgUserHead = "<img src='" + rowMember.UserHead + "'/>";
                string cutPrice    = ((decimal)row["cutDownPrice"]).ToString("F2");
                detailList += string.Format("<li><b>{0}</b><span>{1} 帮你砍了<i>{2}元</i></span></li>", imgUserHead, MemberName, cutPrice);
            }
            hidCutDownDetailHtml.Value = detailList;

            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
            string       str3           = "";

            if (!string.IsNullOrEmpty(masterSettings.GoodsPic))
            {
                str3 = Globals.HostPath(HttpContext.Current.Request.Url) + masterSettings.GoodsPic;
            }
            if (currentProduct != null)
            {
                string strDes = "快来砍价!";//"正品低价砍回家,澳洲尖货就在考拉萌购!;
                if (Hidistro.ControlPanel.Config.CustomConfigHelper.Instance.BrandShow)
                {
                    strDes = "正品低价砍回家,澳洲尖货就在考拉萌购!";
                }
                this.litItemParams.Text = string.Concat(new object[] { str3, "|", masterSettings.GoodsName, "|", masterSettings.GoodsDescription, "$", Globals.HostPath(HttpContext.Current.Request.Url), currentMember.UserHead, "|", strDes, "|", currentProduct.ProductName + "最低可以砍到" + cutDown.MinPrice.ToString("F0") + "元!还不快行动!", "|", HttpContext.Current.Request.Url });
            }
            PageTitle.AddSiteNameTitle("砍价详情页");
        }