Ejemplo n.º 1
0
 private void CountDownBusiness()
 {
     if (this.CountDownId > 0)
     {
         CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(this.CountDownId, 0);
         if (countDownInfo != null)
         {
             HtmlInputHidden htmlInputHidden = this.hidden_SKUSubmitOrderCountDownId;
             int             num             = this.CountDownId;
             htmlInputHidden.Value = num.ToString();
             List <CountDownSkuInfo> countDownSkuInfo = countDownInfo.CountDownSkuInfo;
             if (countDownSkuInfo.Count > 0)
             {
                 this.hidden_SKUSubmitOrderCountDownMinPrice.Value = (from t in countDownSkuInfo
                                                                      orderby t.SalePrice
                                                                      select t).FirstOrDefault().SalePrice.F2ToString("f2");
                 CountDownSkuInfo countDownSkuInfo2 = (from t in countDownSkuInfo
                                                       orderby t.TotalCount - t.BoughtCount descending
                                                       select t).FirstOrDefault();
                 int num2 = 0;
                 int num3 = countDownSkuInfo2.ActivityTotal - countDownSkuInfo2.BoughtCount;
                 num2 = ((countDownSkuInfo2.TotalCount <= num3) ? countDownSkuInfo2.TotalCount : num3);
                 this.hidden_SKUSubmitOrderCountDownStock.Value = ((num2 > 0) ? num2.ToString() : "0");
                 Label label = this.lblSKUSubmitOrderStockNow;
                 num        = countDownSkuInfo.Min((CountDownSkuInfo t) => t.TotalCount);
                 label.Text = num.ToString();
             }
             Literal literal = this.litMaxCount;
             num          = countDownInfo.MaxCount;
             literal.Text = num.ToString();
         }
     }
 }
Ejemplo n.º 2
0
        private void SetOver(HttpContext context)
        {
            int?intParam = base.GetIntParam(context, "CountDownId", true);

            if (!intParam.HasValue)
            {
                throw new HidistroAshxException("错误的活动编号");
            }
            CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(intParam.Value, 0);

            if (countDownInfo == null)
            {
                throw new HidistroAshxException("错误的活动编号");
            }
            if (countDownInfo.StartDate > DateTime.Now)
            {
                throw new HidistroAshxException("该活动尚未开始");
            }
            if (countDownInfo.EndDate < DateTime.Now)
            {
                throw new HidistroAshxException("该活动已经结束");
            }
            PromoteHelper.SetOverCountDown(intParam.Value);
            base.ReturnSuccessResult(context, "活动提前结束成功", 0, true);
        }
        protected override void AttachChildControls()
        {
            this.countDownId = this.Page.Request.QueryString["countDownId"].ToInt(0);
            this.storeId     = this.Page.Request.QueryString["StoreId"].ToInt(0);
            CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(this.countDownId, this.storeId);

            if (countDownInfo == null)
            {
                this.ShowWapMessage("抢购信息不存在", "default.aspx");
            }
            MemberInfo user = HiContext.Current.User;

            if (user.UserId != 0 && user.IsReferral() && string.IsNullOrEmpty(this.Page.Request.QueryString["ReferralUserId"]))
            {
                string text = HttpContext.Current.Request.Url.ToString();
                text = ((text.IndexOf("?") <= -1) ? (text + "?ReferralUserId=" + HiContext.Current.UserId) : (text + "&ReferralUserId=" + HiContext.Current.UserId));
                this.Page.Response.Redirect(text);
            }
            else
            {
                this.FindControls();
                this.SetControlsValue(countDownInfo);
                PageTitle.AddSiteNameTitle("限时抢购商品详情");
            }
        }
Ejemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!int.TryParse(this.Page.Request.QueryString["countDownId"], out this.countDownId))
     {
         base.GotoResourceNotFound();
     }
     else if (SettingsManager.GetMasterSettings().OpenMultStore)
     {
         CountDownInfo    countDownInfo  = PromoteHelper.GetCountDownInfo(this.countDownId, 0);
         List <StoreBase> activityStores = StoreActivityHelper.GetActivityStores(countDownInfo.CountDownId, 2, countDownInfo.StoreType);
         this.ddlStores.DataSource = activityStores;
         this.ddlStores.DataBind();
         this.ddlStores.Items.Insert(0, new ListItem
         {
             Text  = "请选择",
             Value = "-1"
         });
         this.pnlStoreDetail.Visible = true;
         this.ltStoreNames.Text      = string.Format("已参加活动门店({0}家):{1}", activityStores.Count, (from t in activityStores
                                                                                                 select t.StoreName).Aggregate((string t, string n) => t + "、" + n));
         this.hidOpenMultStore.Value = "1";
     }
     else
     {
         this.hidOpenMultStore.Value = "0";
         this.pnlStoreDetail.Visible = false;
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!int.TryParse(base.Request.QueryString["CountDownId"], out this.countDownId))
     {
         base.GotoResourceNotFound();
     }
     else
     {
         this.btnUpdateCountDown.Click += new EventHandler(this.btnUpdateGroupBuy_Click);
         if (!base.IsPostBack)
         {
             this.dropGroupBuyProduct.DataBind();
             this.dropCategories.DataBind();
             this.HourDropDownList1.DataBind();
             this.drophours.DataBind();
             CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(this.countDownId);
             if (countDownInfo == null)
             {
                 base.GotoResourceNotFound();
             }
             else
             {
                 this.LoadCountDown(countDownInfo);
             }
         }
     }
 }
Ejemplo n.º 6
0
        private void btnUpdateGroupBuy_Click(object sender, EventArgs e)
        {
            CountDownInfo info2 = new CountDownInfo();

            info2.CountDownId = this.countDownId;
            CountDownInfo countDownInfo = info2;
            string        str           = string.Empty;

            if (this.dropGroupBuyProduct.SelectedValue > 0)
            {
                if ((PromoteHelper.GetCountDownInfo(this.countDownId).ProductId != this.dropGroupBuyProduct.SelectedValue.Value) && PromoteHelper.ProductCountDownExist(this.dropGroupBuyProduct.SelectedValue.Value))
                {
                    this.ShowMsg("已经存在此商品的限时抢购活动", false);
                    return;
                }
                countDownInfo.ProductId = this.dropGroupBuyProduct.SelectedValue.Value;
            }
            else
            {
                str = str + Formatter.FormatErrorMessage("请选择限时抢购商品");
            }
            if (!this.calendarEndDate.SelectedDate.HasValue)
            {
                str = str + Formatter.FormatErrorMessage("请选择结束日期");
            }
            else
            {
                countDownInfo.EndDate = this.calendarEndDate.SelectedDate.Value;
            }
            if (!string.IsNullOrEmpty(this.txtPrice.Text))
            {
                decimal num;
                if (decimal.TryParse(this.txtPrice.Text.Trim(), out num))
                {
                    countDownInfo.CountDownPrice = num;
                }
                else
                {
                    str = str + Formatter.FormatErrorMessage("价格填写格式不正确");
                }
            }
            if (!string.IsNullOrEmpty(str))
            {
                this.ShowMsg(str, false);
            }
            else
            {
                countDownInfo.Content = Globals.HtmlEncode(this.txtContent.Text);
                if (PromoteHelper.UpdateCountDown(countDownInfo))
                {
                    this.ShowMsg("编辑限时抢购活动成功", true);
                }
                else
                {
                    this.ShowMsg("编辑限时抢购活动失败", true);
                }
            }
        }
Ejemplo n.º 7
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (string.IsNullOrEmpty(base.Text))
            {
                base.Text = "我要咨询";
            }
            int num  = RouteConfig.GetParameter(this.Page, "countDownId", false).ToInt(0);
            int num2 = RouteConfig.GetParameter(this.Page, "groupBuyId", false).ToInt(0);
            int num3 = RouteConfig.GetParameter(this.Page, "PreSaleId", false).ToInt(0);

            if (num > 0)
            {
                CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(num, 0);
                if (countDownInfo != null)
                {
                    base.NavigateUrl = base.GetRouteUrl("ProductConsultations", new
                    {
                        countDownInfo.ProductId
                    });
                }
            }
            else if (num2 > 0)
            {
                GroupBuyInfo groupBuy = PromoteHelper.GetGroupBuy(num2);
                if (groupBuy != null)
                {
                    base.NavigateUrl = base.GetRouteUrl("ProductConsultations", new
                    {
                        groupBuy.ProductId
                    });
                }
            }
            else if (num3 > 0)
            {
                ProductPreSaleInfo productPreSaleInfo = ProductPreSaleHelper.GetProductPreSaleInfo(num3);
                if (productPreSaleInfo != null)
                {
                    base.NavigateUrl = base.GetRouteUrl("ProductConsultations", new
                    {
                        productPreSaleInfo.ProductId
                    });
                }
            }
            else
            {
                base.NavigateUrl = base.GetRouteUrl("ProductConsultations", new
                {
                    ProductId = RouteConfig.GetParameter(this.Page, "productId", false)
                });
            }
            base.Render(writer);
        }
        protected override void AttachChildControls()
        {
            this.countDownId = this.Page.Request.QueryString["countDownId"].ToInt(0);
            CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(this.countDownId, 0);

            if (countDownInfo == null)
            {
                base.GotoResourceNotFound("抢购信息不存在");
            }
            this.FindControls();
            this.SetControlsValue(countDownInfo);
            PageTitle.AddSiteNameTitle("限时抢购商品详情");
        }
        protected override void AttachChildControls()
        {
            this.countDownId = this.Page.Request.QueryString["countDownId"].ToInt(0);
            int           storeId       = this.Page.Request.QueryString["StoreId"].ToInt(0);
            CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(this.countDownId, storeId);

            if (countDownInfo == null)
            {
                this.ShowWapMessage("抢购信息不存在", "default.aspx");
            }
            this.FindControls();
            this.SetControlsValue(countDownInfo);
            PageTitle.AddSiteNameTitle("限时抢购商品详情");
        }
Ejemplo n.º 10
0
        private void BindCountDown()
        {
            CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(this.countDownId, 0);

            if (countDownInfo.StartDate <= DateTime.Now && countDownInfo.EndDate > DateTime.Now)
            {
                this.aChoiceProduct.Visible = false;
                this.CPStartTime.Enabled    = false;
            }
            DataTable countDownSkus = PromoteHelper.GetCountDownSkus(this.countDownId, 0, false);

            if (SettingsManager.GetMasterSettings().OpenMultStore)
            {
                List <StoreBase> activityStores = StoreActivityHelper.GetActivityStores(this.countDownId, 2, countDownInfo.StoreType);
                this.hidStoreIds.Value = (from t in activityStores
                                          select t.StoreId.ToString()).Aggregate((string t, string n) => t + "," + n);
            }
            else
            {
                this.hidStoreIds.Value = "";
            }
            int num = 0;

            if (countDownSkus.Rows.Count == 1)
            {
                DataRow dataRow = countDownSkus.Rows[0];
                this.txtPrice.Text      = dataRow["SalePrice"].ToDecimal(0).F2ToString("f2");
                this.txtTotalCount.Text = dataRow["TotalCount"].ToNullString();
                num = dataRow["BoughtCount"].ToInt(0);
            }
            else
            {
                for (int i = 0; i < countDownSkus.Rows.Count; i++)
                {
                    num += countDownSkus.Rows[i]["BoughtCount"].ToInt(0);
                }
            }
            this.txtContent.Text          = Globals.HtmlDecode(countDownInfo.Content);
            this.txtMaxCount.Text         = Convert.ToString(countDownInfo.MaxCount);
            this.ltBoughtCount.Text       = num.ToString();
            this.CPEndDate.SelectedDate   = countDownInfo.EndDate;
            this.CPStartTime.SelectedDate = countDownInfo.StartDate;
            this.txtShareDetails.Text     = countDownInfo.ShareDetails;
            this.txtShareTitle.Text       = countDownInfo.ShareTitle;
            this.hidUploadLogo.Value      = countDownInfo.ShareIcon;
        }
Ejemplo n.º 11
0
        protected override void AttachChildControls()
        {
            this.countDownId = this.Page.Request.QueryString["countDownId"].ToInt(0);
            this.storeId     = this.Page.Request.QueryString["StoreId"].ToInt(0);
            CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(this.countDownId, this.storeId);

            if (countDownInfo == null)
            {
                this.ShowWapMessage("抢购信息不存在", "goHomeUrl");
            }
            MemberInfo user = HiContext.Current.User;

            if (user.UserId != 0 && user.IsReferral() && string.IsNullOrEmpty(this.Page.Request.QueryString["ReferralUserId"]))
            {
                string text = HttpContext.Current.Request.Url.ToString();
                text = ((text.IndexOf("?") <= -1) ? (text + "?ReferralUserId=" + HiContext.Current.UserId) : (text + "&ReferralUserId=" + HiContext.Current.UserId));
                this.Page.Response.Redirect(text);
            }
            else
            {
                string text2    = this.Page.Request["lat"].ToNullString();
                string text3    = this.Page.Request["lng"].ToNullString();
                string cityName = this.Page.Request["city"].ToNullString();
                string address  = this.Page.Request["address"].ToNullString();
                if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text3))
                {
                    Hidistro.Entities.Store.RegionInfo regionByCityAddress = RegionHelper.GetRegionByCityAddress(cityName, address);
                    if (regionByCityAddress != null)
                    {
                        int num = regionByCityAddress.RegionId;
                        if (regionByCityAddress.FullRegionPath.Split(',').Length >= 2)
                        {
                            num = regionByCityAddress.FullRegionPath.Split(',')[1].ToInt(0);
                        }
                        WebHelper.SetCookie("UserCoordinateCookie", "CityRegionId", num.ToNullString(), null);
                        WebHelper.SetCookie("UserCoordinateCookie", "RegionId", regionByCityAddress.RegionId.ToNullString(), null);
                        WebHelper.SetCookie("UserCoordinateCookie", "FullRegionPath", regionByCityAddress.FullRegionPath, null);
                    }
                    WebHelper.SetCookie("UserCoordinateCookie", "NewCoordinate", $"{text2},{text3}", null);
                }
                this.FindControls();
                this.SetControlsValue(countDownInfo);
                PageTitle.AddSiteNameTitle("限时抢购商品详情");
            }
        }
        protected override void Render(HtmlTextWriter writer)
        {
            int num = 0;

            if (!int.TryParse(this.Page.Request.QueryString["productId"].ToNullString(), out num))
            {
                int num2 = 0;
                int.TryParse(this.Page.Request.QueryString["countDownId"].ToNullString(), out num2);
                if (num2 > 0)
                {
                    CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(num2, 0);
                    if (countDownInfo != null)
                    {
                        num = countDownInfo.ProductId;
                    }
                }
                if (num <= 0)
                {
                    int num3 = 0;
                    int.TryParse(this.Page.Request.QueryString["groupBuyId"].ToNullString(), out num3);
                    if (num3 > 0)
                    {
                        GroupBuyInfo groupBuy = PromoteHelper.GetGroupBuy(num3);
                        if (groupBuy != null)
                        {
                            num = groupBuy.ProductId;
                        }
                    }
                }
            }
            if (num > 0)
            {
                base.NavigateUrl = base.GetRouteUrl("ProductImages", new
                {
                    ProductId = num
                });
            }
            else
            {
                this.Visible = false;
            }
            base.Render(writer);
        }
Ejemplo n.º 13
0
        private void BindProduct()
        {
            CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(this.countDownId, 0);

            this.productId                 = ((this.productId == 0) ? countDownInfo.ProductId : this.productId);
            this.hidProductId.Value        = this.productId.ToString();
            this.rptProductSkus.DataSource = PromoteHelper.GetCountDownSkuTable(this.countDownId, this.productId, 0);
            this.rptProductSkus.DataBind();
            IList <int> list = null;
            Dictionary <int, IList <int> > dictionary = default(Dictionary <int, IList <int> >);
            ProductInfo productDetails = ProductHelper.GetProductDetails(this.productId, out dictionary, out list);

            if (productDetails != null)
            {
                this.ltProductName.Text = productDetails.ProductName;
                this.ltStock.Text       = productDetails.Stock.ToString();
                this.lblPrice.Text      = productDetails.MinSalePrice.F2ToString("f2");
            }
        }
 protected void rptProduct_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         DataRowView     dataRowView      = (DataRowView)e.Item.DataItem;
         HtmlInputButton htmlInputButton  = e.Item.Controls[0].FindControl("btnNow") as HtmlInputButton;
         HtmlInputButton htmlInputButton2 = e.Item.Controls[0].FindControl("btnWill") as HtmlInputButton;
         HtmlInputButton htmlInputButton3 = e.Item.Controls[0].FindControl("btnOver") as HtmlInputButton;
         htmlInputButton.Visible  = false;
         htmlInputButton2.Visible = false;
         htmlInputButton3.Visible = false;
         DateTime?     nullable      = dataRowView["StartDate"].ToDateTime();
         DateTime?     nullable2     = dataRowView["EndDate"].ToDateTime();
         int           num           = dataRowView["TotalCount"].ToInt(0);
         int           num2          = dataRowView["BoughtCount"].ToInt(0);
         CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(dataRowView["CountDownId"].ToInt(0), this.Page.Request.QueryString["StoreId"].ToInt(0));
         if (htmlInputButton != null && htmlInputButton2 != null && htmlInputButton3 != null)
         {
             if (nullable.Value >= DateTime.Now)
             {
                 htmlInputButton2.Visible = true;
             }
             else if (nullable.Value <= DateTime.Now && nullable2.Value >= DateTime.Now)
             {
                 htmlInputButton.Visible = true;
                 if (!countDownInfo.IsRunning)
                 {
                     htmlInputButton.Visible  = false;
                     htmlInputButton3.Visible = true;
                 }
             }
             else if (nullable2.Value < DateTime.Now)
             {
                 htmlInputButton3.Visible = true;
             }
         }
     }
 }
Ejemplo n.º 15
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     if (!int.TryParse(base.Request.QueryString["CountDownId"], out this.countDownId))
     {
         base.GotoResourceNotFound();
         return;
     }
     this.btnUpdateCountDown.Click += new System.EventHandler(this.btnUpdateGroupBuy_Click);
     if (!base.IsPostBack)
     {
         this.dropGroupBuyProduct.SupplierDataBind(UserHelper.GetAssociatedSupplierId(HiContext.Current.User.UserId));
         this.dropCategories.DataBind();
         this.HourDropDownList1.DataBind();
         this.drophours.DataBind();
         CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(this.countDownId);
         if (countDownInfo == null)
         {
             base.GotoResourceNotFound();
             return;
         }
         this.LoadCountDown(countDownInfo);
     }
 }
Ejemplo n.º 16
0
        public void Delete(HttpContext context)
        {
            string text = context.Request["CountDownIds"];

            if (string.IsNullOrWhiteSpace(text))
            {
                throw new HidistroAshxException("错误的活动编号");
            }
            int[] array = (from d in text.Split(',')
                           select int.Parse(d)).ToArray();
            int num  = 0;
            int num2 = array.Count();

            int[] array2 = array;
            foreach (int countDownId in array2)
            {
                CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(countDownId, 0);
                if (DateTime.Now >= countDownInfo.StartDate && DateTime.Now <= countDownInfo.EndDate)
                {
                    if (num2 == 1)
                    {
                        throw new HidistroAshxException("活动正在进行中,不能删除!");
                    }
                }
                else
                {
                    num++;
                    PromoteHelper.DeleteCountDown(countDownId);
                }
            }
            if (num > 0)
            {
                base.ReturnSuccessResult(context, $"成功删除{num}条活动!", 0, true);
                return;
            }
            throw new HidistroAshxException("选择的活动暂不可删除!");
        }
        private void btnUpdateGroupBuy_Click(object sender, EventArgs e)
        {
            int           num2;
            CountDownInfo countDownInfo = new CountDownInfo();

            countDownInfo.CountDownId = this.countDownId;
            string str = string.Empty;

            if (this.dropGroupBuyProduct.SelectedValue > 0)
            {
                if ((PromoteHelper.GetCountDownInfo(this.countDownId).ProductId != this.dropGroupBuyProduct.SelectedValue.Value) && PromoteHelper.ProductCountDownExist(this.dropGroupBuyProduct.SelectedValue.Value))
                {
                    this.ShowMsg("已经存在此商品的限时抢购活动", false);
                    return;
                }
                countDownInfo.ProductId = this.dropGroupBuyProduct.SelectedValue.Value;
            }
            else
            {
                str = str + Formatter.FormatErrorMessage("请选择限时抢购商品");
            }
            if (!this.calendarEndDate.SelectedDate.HasValue)
            {
                str = str + Formatter.FormatErrorMessage("请选择结束日期");
            }
            else
            {
                countDownInfo.EndDate = this.calendarEndDate.SelectedDate.Value.AddHours((double)this.HourDropDownList1.SelectedValue.Value);
                if (DateTime.Compare(countDownInfo.EndDate, DateTime.Now) <= 0)
                {
                    str = str + Formatter.FormatErrorMessage("结束日期必须要晚于今天日期");
                }
                else if (DateTime.Compare(this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value), countDownInfo.EndDate) >= 0)
                {
                    str = str + Formatter.FormatErrorMessage("开始日期必须要早于结束日期");
                }
                else
                {
                    countDownInfo.StartDate = this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value);
                }
            }
            if (!string.IsNullOrEmpty(this.txtPrice.Text))
            {
                decimal num;
                if (decimal.TryParse(this.txtPrice.Text.Trim(), out num))
                {
                    countDownInfo.CountDownPrice = num;
                }
                else
                {
                    str = str + Formatter.FormatErrorMessage("价格填写格式不正确");
                }
            }
            if (int.TryParse(this.txtMaxCount.Text.Trim(), out num2))
            {
                countDownInfo.MaxCount = num2;
            }
            else
            {
                str = str + Formatter.FormatErrorMessage("限购数量不能为空,只能为整数");
            }
            if (!string.IsNullOrEmpty(str))
            {
                this.ShowMsg(str, false);
            }
            else
            {
                countDownInfo.Content = Globals.HtmlEncode(this.txtContent.Text);
                if (PromoteHelper.UpdateCountDown(countDownInfo))
                {
                    this.ShowMsg("编辑限时抢购活动成功", true);
                }
                else
                {
                    this.ShowMsg("编辑限时抢购活动失败", true);
                }
            }
        }
Ejemplo n.º 18
0
        private void ShowCoupons(HttpContext context)
        {
            int           num              = context.Request["ProductId"].ToInt(0);
            bool          flag             = context.Request["IsGroup"].ToBool();
            bool          flag2            = context.Request["IsPanicBuying"].ToBool();
            bool          useWithFireGroup = context.Request["IsFireGroup"].ToBool();
            StringBuilder stringBuilder    = new StringBuilder();

            if (flag)
            {
                GroupBuyInfo groupBuy = PromoteHelper.GetGroupBuy(num);
                num = (groupBuy?.ProductId ?? 0);
            }
            if (flag2)
            {
                CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(num, 0);
                num = (countDownInfo?.ProductId ?? 0);
            }
            DataTable couponList = CouponHelper.GetCouponList(num, HiContext.Current.UserId, flag, flag2, useWithFireGroup);

            if (couponList.Rows.Count > 0)
            {
                foreach (DataRow row in couponList.Rows)
                {
                    decimal num2 = row["Price"].ToDecimal(0);
                    string  text = "";
                    text = ((!(num2 <= 5m)) ? ((!(num2 <= 50m)) ? "Tag3" : "Tag2") : "Tag1");
                    try
                    {
                        StringBuilder stringBuilder2 = stringBuilder;
                        object[]      obj            = new object[6]
                        {
                            text,
                            row["CouponId"].ToNullString(),
                            num2.F2ToString("f2"),
                            string.IsNullOrEmpty(row["CanUseProducts"].ToNullString().Trim()) ? "通用" : "部分",
                            (row["OrderUseLimit"].ToDecimal(0) == decimal.Zero) ? "无限制" : ("满" + row["OrderUseLimit"].ToDecimal(0).F2ToString("f2") + "元使用"),
                            null
                        };
                        object   str;
                        DateTime value;
                        if (!row["StartTime"].ToDateTime().HasValue)
                        {
                            str = "";
                        }
                        else
                        {
                            value = row["StartTime"].ToDateTime().Value;
                            str   = value.ToString("yyyy.MM.dd");
                        }
                        object str2;
                        if (!row["ClosingTime"].ToDateTime().HasValue)
                        {
                            str2 = "";
                        }
                        else
                        {
                            value = row["ClosingTime"].ToDateTime().Value;
                            str2  = value.ToString("yyyy.MM.dd");
                        }
                        obj[5] = (string)str + "至" + (string)str2;
                        stringBuilder2.AppendFormat("{{ \"LiId\": \"{0}\", \"CId\": \"{1}\", \"Price\": \"{2}\", \"CanUseProducts\": \"{3}\", \"OrderUseLimit\": \"{4}\", \"SCTime\": \"{5}\"}},", obj);
                    }
                    catch (Exception ex)
                    {
                        string message = ex.Message;
                    }
                }
            }
            context.Response.Write("{\"TotalRecords\":\"" + couponList.Rows.Count + "\",\"Data\":[" + stringBuilder.ToString().TrimEnd(',') + "]}");
            context.Response.End();
        }
Ejemplo n.º 19
0
        private void ProcessProductSkus(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            int       num         = context.Request["sourceId"].ToInt(0);
            int       productId   = int.Parse(context.Request["productId"], NumberStyles.None);
            int       attributeId = int.Parse(context.Request["AttributeId"], NumberStyles.None);
            int       valueId     = int.Parse(context.Request["ValueId"], NumberStyles.None);
            int       num2        = context.Request["StoreId"].ToInt(0);
            DataTable skuItems    = ShoppingProcessor.GetUnUpUnUpsellingSkus(productId, attributeId, valueId);

            if (skuItems == null || skuItems.Rows.Count == 0)
            {
                context.Response.Write("{\"Status\":\"1\"}");
            }
            else
            {
                skuItems.Columns.Add(new DataColumn
                {
                    ColumnName = "SalePrice",
                    DataType   = typeof(decimal)
                });
                bool flag = false;
                if (context.Request.UrlReferrer.AbsoluteUri.ToLower().Contains("fightgroup".ToLower()) && num > 0)
                {
                    IList <FightGroupSkuInfo> fightGroupSkus = VShopHelper.GetFightGroupSkus(num);
                    if (fightGroupSkus.Count > 0)
                    {
                        flag = true;
                        for (int j = 0; j < skuItems.Rows.Count; j++)
                        {
                            DataRow           row = skuItems.Rows[j];
                            FightGroupSkuInfo fightGroupSkuInfo = (from c in fightGroupSkus
                                                                   where c.SkuId == row["SkuId"].ToString()
                                                                   select c).FirstOrDefault();
                            if (fightGroupSkuInfo == null)
                            {
                                string    skuId  = skuItems.Rows[j]["skuId"].ToString();
                                DataTable theSku = new SkuDao().GetTheSku(skuId);
                                if (theSku != null && theSku.Rows.Count > 0)
                                {
                                    skuItems.Rows[j]["Stock"]     = 0;
                                    skuItems.Rows[j]["SalePrice"] = theSku.Rows[0]["SalePrice"].ToDecimal(0).F2ToString("f2");
                                }
                            }
                            else
                            {
                                int totalCount  = fightGroupSkuInfo.TotalCount;
                                int boughtCount = fightGroupSkuInfo.BoughtCount;
                                int num3        = totalCount - boughtCount;
                                if (num3 > fightGroupSkuInfo.Stock)
                                {
                                    num3 = fightGroupSkuInfo.Stock;
                                }
                                decimal salePrice = fightGroupSkuInfo.SalePrice;
                                skuItems.Rows[j]["Stock"]     = ((num3 >= 0) ? num3 : 0);
                                skuItems.Rows[j]["SalePrice"] = salePrice.F2ToString("f2");
                            }
                        }
                    }
                }
                if (context.Request.UrlReferrer.AbsoluteUri.ToLower().Contains("countdown"))
                {
                    CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(num, num2);
                    if (countDownInfo != null && countDownInfo.CountDownSkuInfo != null && countDownInfo.CountDownSkuInfo.Count > 0)
                    {
                        flag = true;
                        skuItems.Columns.Add(new DataColumn
                        {
                            ColumnName = "OldSalePrice",
                            DataType   = typeof(decimal)
                        });
                        List <CountDownSkuInfo> countDownSkuInfo = countDownInfo.CountDownSkuInfo;
                        int i;
                        for (i = 0; i < skuItems.Rows.Count; i++)
                        {
                            List <CountDownSkuInfo> list = (from s in countDownSkuInfo
                                                            where s.SkuId == skuItems.Rows[i]["SkuId"].ToNullString()
                                                            select s).ToList();
                            if (list == null || list.Count == 0)
                            {
                                string    skuId2  = list[0].SkuId.ToString();
                                DataTable theSku2 = new SkuDao().GetTheSku(skuId2);
                                if (theSku2 != null && theSku2.Rows.Count > 0)
                                {
                                    skuItems.Rows[i]["Stock"]        = 0;
                                    skuItems.Rows[i]["SalePrice"]    = theSku2.Rows[0]["SalePrice"].ToDecimal(0).F2ToString("f2");
                                    skuItems.Rows[i]["OldSalePrice"] = theSku2.Rows[0]["MarketPrice"].ToDecimal(0).F2ToString("f2");
                                }
                            }
                            else
                            {
                                int totalCount2  = list[0].TotalCount;
                                int boughtCount2 = list[0].BoughtCount;
                                int num4         = totalCount2 - boughtCount2;
                                skuItems.Rows[i]["Stock"] = ((num4 >= 0) ? num4 : 0);
                                decimal salePrice2   = list[0].SalePrice;
                                decimal oldSalePrice = list[0].OldSalePrice;
                                skuItems.Rows[i]["SalePrice"]    = salePrice2.F2ToString("f2");
                                skuItems.Rows[i]["OldSalePrice"] = oldSalePrice.F2ToString("f2");
                            }
                        }
                    }
                }
                if (context.Request.UrlReferrer.AbsoluteUri.ToLower().Contains("groupbuy"))
                {
                    GroupBuyInfo groupBuy = PromoteHelper.GetGroupBuy(num);
                    if (groupBuy != null)
                    {
                        flag = true;
                        skuItems.Columns.Add(new DataColumn
                        {
                            ColumnName = "OldSalePrice",
                            DataType   = typeof(decimal)
                        });
                        Dictionary <string, SKUItem> productSkuSaleInfo = ProductBrowser.GetProductSkuSaleInfo(productId, 0);
                        int soldCount = PromoteHelper.GetSoldCount(groupBuy.GroupBuyId);
                        for (int k = 0; k < skuItems.Rows.Count; k++)
                        {
                            DataRow dataRow = skuItems.Rows[k];
                            if (productSkuSaleInfo.ContainsKey(dataRow["SkuId"].ToNullString()))
                            {
                                SKUItem sKUItem = productSkuSaleInfo[dataRow["SkuId"].ToNullString()];
                                int     num5    = skuItems.Rows[k]["Stock"].ToInt(0);
                                int     num6    = groupBuy.MaxCount - soldCount;
                                if (num5 < num6)
                                {
                                    skuItems.Rows[k]["Stock"] = num5;
                                }
                                else
                                {
                                    skuItems.Rows[k]["Stock"] = num6;
                                }
                                skuItems.Rows[k]["SalePrice"]    = groupBuy.Price.F2ToString("f2");
                                skuItems.Rows[k]["OldSalePrice"] = sKUItem.SalePrice.F2ToString("f2");
                            }
                        }
                    }
                }
                if (context.Request.UrlReferrer.AbsoluteUri.ToLower().Contains("presaleproductdetails") && num > 0)
                {
                    ProductPreSaleInfo productPreSaleInfo = ProductPreSaleHelper.GetProductPreSaleInfo(num);
                    if (productPreSaleInfo != null)
                    {
                        flag = true;
                        Dictionary <string, SKUItem> preSaleProductSkuSaleInfo = ProductBrowser.GetPreSaleProductSkuSaleInfo(productId);
                        foreach (DataRow row2 in skuItems.Rows)
                        {
                            if (preSaleProductSkuSaleInfo.ContainsKey(row2["SkuId"].ToString()))
                            {
                                SKUItem sKUItem2 = preSaleProductSkuSaleInfo[row2["SkuId"].ToString()];
                                row2["SalePrice"] = sKUItem2.SalePrice;
                                row2["Stock"]     = sKUItem2.Stock;
                            }
                        }
                    }
                }
                if (!flag)
                {
                    Dictionary <string, SKUItem> productSkuSaleInfo2 = ProductBrowser.GetProductSkuSaleInfo(productId, num2);
                    string text = "";
                    if (num2 == 0)
                    {
                        text = PromoteHelper.GetPhonePriceByProductId(productId);
                    }
                    foreach (DataRow row3 in skuItems.Rows)
                    {
                        if (productSkuSaleInfo2.ContainsKey(row3["SkuId"].ToString()))
                        {
                            SKUItem sKUItem3 = productSkuSaleInfo2[row3["SkuId"].ToString()];
                            if (!string.IsNullOrEmpty(text))
                            {
                                string  s2   = text.Split(',')[0];
                                decimal num7 = (sKUItem3.SalePrice - decimal.Parse(s2) > decimal.Zero) ? (sKUItem3.SalePrice - decimal.Parse(s2)) : decimal.Zero;
                                row3["SalePrice"] = num7.F2ToString("f2");
                            }
                            else
                            {
                                row3["SalePrice"] = sKUItem3.SalePrice;
                            }
                            row3["Stock"] = sKUItem3.Stock;
                        }
                        else
                        {
                            row3["Stock"]     = "0";
                            row3["SalePrice"] = "0.00";
                        }
                    }
                }
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append("{");
                stringBuilder.Append("\"Status\":\"OK\",");
                stringBuilder.Append("\"SkuItems\":[");
                foreach (DataRow row4 in skuItems.Rows)
                {
                    stringBuilder.Append("{");
                    if (skuItems.Columns.Contains("SkuId"))
                    {
                        stringBuilder.AppendFormat("\"SkuId\":\"{0}\",", row4["SkuId"].ToString());
                    }
                    if (skuItems.Columns.Contains("SalePrice"))
                    {
                        stringBuilder.AppendFormat("\"SalePrice\":\"{0}\",", row4["SalePrice"].ToDecimal(0).F2ToString("f2"));
                    }
                    if (skuItems.Columns.Contains("OldSalePrice"))
                    {
                        stringBuilder.AppendFormat("\"OldSalePrice\":\"{0}\",", row4["OldSalePrice"].ToDecimal(0).F2ToString("f2"));
                    }
                    if (skuItems.Columns.Contains("Stock"))
                    {
                        stringBuilder.AppendFormat("\"Stock\":\"{0}\",", row4["Stock"].ToString());
                    }
                    stringBuilder.AppendFormat("\"AttributeId\":\"{0}\",", row4["AttributeId"].ToString());
                    stringBuilder.AppendFormat("\"ValueId\":\"{0}\"", row4["ValueId"].ToString());
                    stringBuilder.Append("},");
                }
                stringBuilder.Remove(stringBuilder.Length - 1, 1);
                stringBuilder.Append("]");
                stringBuilder.Append("}");
                context.Response.Write(stringBuilder.ToString());
            }
        }
Ejemplo n.º 20
0
        private void btnUpdateGroupBuy_Click(object sender, System.EventArgs e)
        {
            CountDownInfo countDownInfo = new CountDownInfo();

            countDownInfo.CountDownId = this.countDownId;
            string text = string.Empty;

            if (this.dropGroupBuyProduct.SelectedValue > 0)
            {
                CountDownInfo countDownInfo2 = PromoteHelper.GetCountDownInfo(this.countDownId);
                if (countDownInfo2.ProductId != this.dropGroupBuyProduct.SelectedValue.Value && PromoteHelper.ProductCountDownExist(this.dropGroupBuyProduct.SelectedValue.Value))
                {
                    this.ShowMsg("已经存在此商品的限时抢购活动", false);
                    return;
                }
                countDownInfo.ProductId = this.dropGroupBuyProduct.SelectedValue.Value;
            }
            else
            {
                text += Formatter.FormatErrorMessage("请选择限时抢购商品");
            }

            bool timeValidated = false;

            if (!this.calendarEndDate.SelectedDate.HasValue)
            {
                text += Formatter.FormatErrorMessage("请选择结束日期");
            }
            else
            {
                countDownInfo.EndDate = this.calendarEndDate.SelectedDate.Value.AddHours((double)this.HourDropDownList1.SelectedValue.Value);
                if (System.DateTime.Compare(countDownInfo.EndDate, System.DateTime.Now) <= 0)
                {
                    text += Formatter.FormatErrorMessage("结束日期必须要晚于今天日期");
                }
                else
                {
                    if (System.DateTime.Compare(this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value), countDownInfo.EndDate) >= 0)
                    {
                        text += Formatter.FormatErrorMessage("开始日期必须要早于结束日期");
                    }
                    else
                    {
                        countDownInfo.StartDate = this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value);

                        timeValidated = true;
                    }
                }
            }

            if (timeValidated && PromoteHelper.ProductCountDownExist(this.dropGroupBuyProduct.SelectedValue.Value, countDownInfo.StartDate, countDownInfo.EndDate, this.countDownId))
            {
                this.ShowMsg("已经存在此商品该时间段的限时抢购活动", false);
                return;
            }

            if (!string.IsNullOrEmpty(this.txtPrice.Text))
            {
                decimal countDownPrice;
                if (decimal.TryParse(this.txtPrice.Text.Trim(), out countDownPrice))
                {
                    countDownInfo.CountDownPrice = countDownPrice;
                }
                else
                {
                    text += Formatter.FormatErrorMessage("价格填写格式不正确");
                }
            }
            int maxCount;

            if (int.TryParse(this.txtMaxCount.Text.Trim(), out maxCount))
            {
                countDownInfo.MaxCount = maxCount;
            }
            else
            {
                text += Formatter.FormatErrorMessage("限购数量不能为空,只能为整数");
            }

            int planCount;

            if (int.TryParse(this.txtPlanCount.Text.Trim(), out planCount))
            {
                countDownInfo.PlanCount = planCount;
            }
            else
            {
                text += Formatter.FormatErrorMessage("活动数量不能为空,只能为整数");
            }

            if (!string.IsNullOrEmpty(text))
            {
                this.ShowMsg(text, false);
                return;
            }
            countDownInfo.Content = Globals.HtmlEncode(this.txtContent.Text);
            //countDownInfo.PlanCount = maxCount * 10;   //TODO
            if (PromoteHelper.UpdateCountDown(countDownInfo))
            {
                this.ShowMsg("编辑限时抢购活动成功", true);
                return;
            }
            this.ShowMsg("编辑限时抢购活动失败", true);
        }
 protected override void AttachChildControls()
 {
     if (!int.TryParse(base.GetParameter("countDownId", false), out this.countDownId))
     {
         base.GotoResourceNotFound();
     }
     this.common_Location         = (Common_Location)this.FindControl("common_Location");
     this.litProductCode          = (Literal)this.FindControl("litProductCode");
     this.litProductName          = (Literal)this.FindControl("litProductName");
     this.lblSku                  = (SkuLabel)this.FindControl("lblSku");
     this.lblStock                = (StockLabel)this.FindControl("lblStock");
     this.litUnit                 = (Literal)this.FindControl("litUnit");
     this.litSurplusNumber        = (Literal)this.FindControl("litSurplusNumber");
     this.litWeight               = (Label)this.FindControl("litWeight");
     this.litBrosedNum            = (Literal)this.FindControl("litBrosedNum");
     this.litBrand                = (Literal)this.FindControl("litBrand");
     this.litmaxcount             = (Literal)this.FindControl("litMaxCount");
     this.lblSalePrice            = (FormatedMoneyLabel)this.FindControl("lblSalePrice");
     this.lblTotalPrice           = (TotalLabel)this.FindControl("lblTotalPrice");
     this.litDescription          = (Literal)this.FindControl("litDescription");
     this.litShortDescription     = (Literal)this.FindControl("litShortDescription");
     this.btnOrder                = (BuyButton)this.FindControl("btnOrder");
     this.hpkProductConsultations = (HyperLink)this.FindControl("hpkProductConsultations");
     this.ltlSaleCount            = (Literal)this.FindControl("ltlSaleCount");
     this.ltlConsultation         = (Literal)this.FindControl("ltlConsultation");
     this.ltlReviewCount          = (Literal)this.FindControl("ltlReviewCount");
     this.lblCurrentSalePrice     = (FormatedMoneyLabel)this.FindControl("lblCurrentSalePrice");
     this.litContent              = (Literal)this.FindControl("litContent");
     this.lblEndTime              = (FormatedTimeLabel)this.FindControl("lblEndTime");
     this.lblStartTime            = (FormatedTimeLabel)this.FindControl("lblStartTime");
     this.litRemainTime           = (Literal)this.FindControl("litRemainTime");
     this.images                  = (Common_ProductImages)this.FindControl("common_ProductImages");
     this.rptExpandAttributes     = (ThemedTemplatedRepeater)this.FindControl("rptExpandAttributes");
     this.skuSelector             = (SKUSelector)this.FindControl("SKUSelector");
     this.consultations           = (Common_ProductConsultations)this.FindControl("list_Common_ProductConsultations");
     this.correlative             = (Common_GoodsList_Correlative)this.FindControl("list_Common_GoodsList_Correlative");
     this.nowTime                 = (HtmlInputHidden)this.FindControl("nowTime");
     this.nowTime.SetWhenIsNotNull(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo));
     this.hidden_skus        = (HtmlInputHidden)this.FindControl("hidden_skus");
     this.hidden_skuItem     = (HtmlInputHidden)this.FindControl("hidden_skuItem");
     this.hidden_IsOver      = (HtmlInputHidden)this.FindControl("hidden_IsOver");
     this.hidden_CountDownId = (HtmlInputHidden)this.FindControl("hidden_CountDownId");
     this.hidden_productId   = (HtmlInputHidden)this.FindControl("hidden_productId");
     this.hdShareDetails     = (HtmlInputHidden)this.FindControl("hdShareDetails");
     this.hdShareIcon        = (HtmlInputHidden)this.FindControl("hdShareIcon");
     this.hdShareTitle       = (HtmlInputHidden)this.FindControl("hdShareTitle");
     if (!this.Page.IsPostBack)
     {
         CountDownInfo countDownInfo  = PromoteHelper.GetCountDownInfo(this.countDownId, 0);
         SiteSettings  masterSettings = SettingsManager.GetMasterSettings();
         if (countDownInfo != null)
         {
             HtmlInputHidden htmlInputHidden = this.hidden_CountDownId;
             int             num             = countDownInfo.CountDownId;
             htmlInputHidden.Value = num.ToString();
             HtmlInputHidden htmlInputHidden2 = this.hidden_productId;
             num = countDownInfo.ProductId;
             htmlInputHidden2.Value = num.ToString();
             int num2 = 0;
             ProductBrowseInfo productBrowseInfo = ProductBrowser.GetProductBrowseInfo(countDownInfo.ProductId, null, masterSettings.OpenMultStore, 0);
             Literal           literal           = this.ltlReviewCount;
             num          = productBrowseInfo.ReviewCount;
             literal.Text = num.ToString();
             Literal literal2 = this.ltlSaleCount;
             num           = productBrowseInfo.SaleCount;
             literal2.Text = num.ToString();
             if (productBrowseInfo.Product == null)
             {
                 this.hidden_IsOver.Value = "pullOff";
             }
             else if (!productBrowseInfo.Product.SaleStatus.Equals(ProductSaleStatus.OnSale))
             {
                 this.hidden_IsOver.Value = "pullOff";
             }
             if (!string.IsNullOrEmpty(countDownInfo.ShareDetails))
             {
                 HtmlInputHidden htmlInputHidden3 = this.hdShareDetails;
                 htmlInputHidden3.Value += countDownInfo.ShareDetails;
             }
             else if (!string.IsNullOrEmpty(countDownInfo.Content))
             {
                 this.hdShareDetails.Value = "限时抢购简单说明:";
                 HtmlInputHidden htmlInputHidden4 = this.hdShareDetails;
                 htmlInputHidden4.Value += countDownInfo.Content;
             }
             else
             {
                 this.hdShareDetails.Value = "限时抢购简单说明:";
             }
             Literal literal3 = this.ltlConsultation;
             num                     = productBrowseInfo.ConsultationCount;
             literal3.Text           = num.ToString();
             this.hdShareIcon.Value  = Globals.FullPath(countDownInfo.ShareIcon);
             this.hdShareTitle.Value = countDownInfo.ShareTitle;
             if (countDownInfo.StartDate > DateTime.Now)
             {
                 this.hidden_IsOver.Value = "AboutToBegin";
             }
             else if (countDownInfo.EndDate < DateTime.Now)
             {
                 this.hidden_IsOver.Value = "over";
             }
             else if (!countDownInfo.IsRunning)
             {
                 this.hidden_IsOver.Value = "true";
             }
             num2 = PromoteHelper.GetCountDownSurplusNumber(this.countDownId);
             num2 = ((num2 >= 0) ? num2 : 0);
             this.litSurplusNumber.Text = num2.ToString();
             Dictionary <string, SKUItem> dictionary = new Dictionary <string, SKUItem>();
             foreach (SKUItem value2 in productBrowseInfo.Product.Skus.Values)
             {
                 CountDownSkuInfo countDownSkuInfo = (from c in countDownInfo.CountDownSkuInfo
                                                      where c.SkuId == value2.SkuId
                                                      select c).FirstOrDefault();
                 if (countDownSkuInfo != null)
                 {
                     value2.Stock = ((value2.Stock < countDownSkuInfo.ActivityTotal - countDownSkuInfo.BoughtCount) ? value2.Stock : (countDownSkuInfo.ActivityTotal - countDownSkuInfo.BoughtCount));
                 }
                 dictionary.Add(value2.SkuId, value2);
             }
             IEnumerable value = from item in dictionary
                                 select item.Value;
             if (JsonConvert.SerializeObject(productBrowseInfo.DbSKUs) != null)
             {
                 this.hidden_skuItem.Value = JsonConvert.SerializeObject(productBrowseInfo.DbSKUs);
             }
             if (this.hidden_skus != null)
             {
                 this.hidden_skus.Value = JsonConvert.SerializeObject(value);
             }
             this.LoadPageSearch(productBrowseInfo.Product);
             this.hpkProductConsultations.Target      = "_blank";
             this.hpkProductConsultations.Text        = "查看全部";
             this.hpkProductConsultations.NavigateUrl = $"ProductConsultationsAndReplay.aspx?productId={countDownInfo.ProductId}";
             this.LoadProductInfo(productBrowseInfo.Product, productBrowseInfo.BrandName);
             this.LoadCountDownBuyInfo(countDownInfo);
             this.btnOrder.Stock = productBrowseInfo.Product.Stock;
             if (!countDownInfo.IsJoin)
             {
                 this.hidden_IsOver.Value = "nojoin";
             }
             BrowsedProductQueue.EnQueue(countDownInfo.ProductId);
             this.images.ImageInfo = productBrowseInfo.Product;
             if (productBrowseInfo.DbAttribute != null)
             {
                 this.rptExpandAttributes.DataSource = productBrowseInfo.DbAttribute;
                 this.rptExpandAttributes.DataBind();
             }
             if (productBrowseInfo.DbSKUs != null)
             {
                 this.skuSelector.ProductId  = countDownInfo.ProductId;
                 this.skuSelector.DataSource = productBrowseInfo.DbSKUs;
             }
             if (productBrowseInfo.DBConsultations != null)
             {
                 this.consultations.DataSource = productBrowseInfo.DBConsultations;
                 this.consultations.DataBind();
             }
             if (productBrowseInfo.DbCorrelatives != null)
             {
                 this.correlative.DataSource = productBrowseInfo.DbCorrelatives;
                 this.correlative.DataBind();
             }
         }
         else
         {
             base.GotoResourceNotFound();
         }
     }
 }
Ejemplo n.º 22
0
        private void btnEditCountDown_Click(object sender, EventArgs e)
        {
            bool          openMultStore = SettingsManager.GetMasterSettings().OpenMultStore;
            CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(this.countDownId, 0);

            if (countDownInfo == null)
            {
                this.ShowMsg("限时购不存在", false, "CountDowns.aspx");
            }
            else
            {
                if (countDownInfo.StartDate > DateTime.Now && this.productId > 0)
                {
                    countDownInfo.ProductId = this.productId;
                }
                List <CountDownSkuInfo> list = new List <CountDownSkuInfo>();
                for (int i = 0; i < this.rptProductSkus.Items.Count; i++)
                {
                    RepeaterItem repeaterItem = this.rptProductSkus.Items[i];
                    HiddenField  hiddenField  = repeaterItem.FindControl("hfSkuId") as HiddenField;
                    TextBox      textBox      = repeaterItem.FindControl("txtActivityStock") as TextBox;
                    TextBox      textBox2     = repeaterItem.FindControl("txtActivitySalePrice") as TextBox;
                    if (textBox2.Text.Trim().ToDecimal(0) == decimal.Zero)
                    {
                        this.ShowMsg("请完整填写商品规格", false);
                        return;
                    }
                    CountDownSkuInfo item = new CountDownSkuInfo
                    {
                        SalePrice   = textBox2.Text.Trim().ToDecimal(0),
                        TotalCount  = textBox.Text.Trim().ToInt(0),
                        SkuId       = hiddenField.Value,
                        CountDownId = countDownInfo.CountDownId,
                        BoughtCount = new CountDownDao().GetCountDownOrderCount(this.countDownId, hiddenField.Value, -1)
                    };
                    list.Add(item);
                }
                if (this.rptProductSkus.Items.Count == 0)
                {
                    if (this.txtPrice.Text.Trim().ToDecimal(0) == decimal.Zero)
                    {
                        this.ShowMsg("请填写限时抢购价格", false);
                        return;
                    }
                    if (this.txtTotalCount.Text.Trim().ToInt(0) == 0)
                    {
                        this.ShowMsg("请填写活动库存", false);
                        return;
                    }
                }
                if (!this.CPStartTime.SelectedDate.HasValue)
                {
                    this.ShowMsg(Formatter.FormatErrorMessage("请填写活动开始时间"), false);
                }
                else
                {
                    if (countDownInfo.StartDate > DateTime.Now)
                    {
                        countDownInfo.StartDate = this.CPStartTime.SelectedDate.Value;
                    }
                    if (!this.CPEndDate.SelectedDate.HasValue)
                    {
                        this.ShowMsg(Formatter.FormatErrorMessage("请填写活动结束时间"), false);
                    }
                    else
                    {
                        countDownInfo.EndDate = this.CPEndDate.SelectedDate.Value;
                        if (countDownInfo.StartDate >= countDownInfo.EndDate)
                        {
                            this.ShowMsg(Formatter.FormatErrorMessage("活动结束时间要大于活动开始时间"), false);
                        }
                        else if (countDownInfo.EndDate <= DateTime.Now)
                        {
                            this.ShowMsg(Formatter.FormatErrorMessage("活动结束时间要大于当前系统时间"), false);
                        }
                        else if (PromoteHelper.ProductCountDownExist(countDownInfo.ProductId, countDownInfo.StartDate, this.countDownId, countDownInfo.EndDate))
                        {
                            this.ShowMsg("已经存在此商品的限时抢购活动", false);
                        }
                        else if (this.txtMaxCount.Text.Trim().ToInt(0) == 0)
                        {
                            this.ShowMsg("请填写每人限购数量", false);
                        }
                        else
                        {
                            countDownInfo.MaxCount = this.txtMaxCount.Text.ToInt(0);
                            int num = 0;
                            num = ((this.rptProductSkus.Items.Count == 0) ? this.txtTotalCount.Text.Trim().ToInt(0) : list.Sum((CountDownSkuInfo c) => c.TotalCount));
                            if (!openMultStore && countDownInfo.MaxCount > num && list.Count == 0)
                            {
                                this.ShowMsg(Formatter.FormatErrorMessage("每人限购数量不能大于活动库存"), false);
                            }
                            else if (!openMultStore && list.Count > 0 && countDownInfo.MaxCount > (from c in list
                                                                                                   where c.TotalCount > 0
                                                                                                   select c).Min((CountDownSkuInfo c) => c.TotalCount))
                            {
                                this.ShowMsg(Formatter.FormatErrorMessage("每人限购数量不能大于规格的最小活动库存"), false);
                            }
                            else
                            {
                                countDownInfo.Content      = Globals.HtmlEncode(this.txtContent.Text);
                                countDownInfo.ShareTitle   = Globals.HtmlEncode(this.txtShareTitle.Text);
                                countDownInfo.ShareDetails = Globals.HtmlEncode(this.txtShareDetails.Text);
                                countDownInfo.ShareIcon    = Globals.SaveFile("countDown", this.hidUploadLogo.Value, "/Storage/master/", true, false, "");
                                IList <int> list2 = null;
                                Dictionary <int, IList <int> > dictionary = default(Dictionary <int, IList <int> >);
                                ProductInfo productDetails = ProductHelper.GetProductDetails(countDownInfo.ProductId, out dictionary, out list2);
                                if (productDetails != null)
                                {
                                    if (!openMultStore && productDetails.Stock < countDownInfo.MaxCount)
                                    {
                                        this.ShowMsg("库存小于每人限购数量", false);
                                        return;
                                    }
                                    if (!openMultStore && productDetails.Stock < num)
                                    {
                                        this.ShowMsg("库存小于活动库存", false);
                                        return;
                                    }
                                    if (list.Count > 0)
                                    {
                                        foreach (KeyValuePair <string, SKUItem> sku in productDetails.Skus)
                                        {
                                            CountDownSkuInfo countDownSkuInfo = (from s in list
                                                                                 where s.SkuId == sku.Value.SkuId
                                                                                 select s).FirstOrDefault();
                                            if (countDownSkuInfo == null)
                                            {
                                                this.ShowMsg("规格不存在,请重新刷新页面", false);
                                                return;
                                            }
                                            if (!openMultStore && countDownSkuInfo.TotalCount > sku.Value.Stock)
                                            {
                                                this.ShowMsg("商品规格库存不足", false);
                                                return;
                                            }
                                        }
                                    }
                                }
                                if (list.Count == 0)
                                {
                                    DataTable skusByProductId = ProductHelper.GetSkusByProductId((this.productId > 0) ? this.productId : countDownInfo.ProductId);
                                    if (skusByProductId.Rows.Count > 0)
                                    {
                                        DataRow          dataRow = skusByProductId.Rows[0];
                                        CountDownSkuInfo item2   = new CountDownSkuInfo
                                        {
                                            SalePrice   = this.txtPrice.Text.Trim().ToDecimal(0),
                                            TotalCount  = num,
                                            SkuId       = dataRow["SkuId"].ToNullString(),
                                            CountDownId = countDownInfo.CountDownId,
                                            BoughtCount = new CountDownDao().GetCountDownOrderCount(this.countDownId, dataRow["SkuId"].ToNullString(), -1)
                                        };
                                        list.Add(item2);
                                    }
                                }
                                if (openMultStore)
                                {
                                    if (string.IsNullOrEmpty(this.hidStoreIds.Value))
                                    {
                                        this.ShowMsg("请选择门店范围", false);
                                        return;
                                    }
                                    countDownInfo.StoreType = 2;
                                    countDownInfo.StoreIds  = this.hidStoreIds.Value;
                                }
                                else
                                {
                                    countDownInfo.StoreIds  = "";
                                    countDownInfo.StoreType = 0;
                                }
                                PromoteHelper.EditCountDown(countDownInfo, list);
                                if (countDownInfo.StartDate < DateTime.Now && countDownInfo.EndDate > DateTime.Now)
                                {
                                    this.ShowMsg("编辑限时抢购活动成功", true, "countdowns.aspx");
                                }
                                else
                                {
                                    this.ShowMsg("编辑限时抢购活动成功", true, "countdowns.aspx?State=1");
                                }
                            }
                        }
                    }
                }
            }
        }