Example #1
0
 private void CountDownBusiness()
 {
     if (this.CountDownId > 0)
     {
         this.hidden_SKUSubmitOrderCountDownId.Value = this.CountDownId.ToString();
         List <CountDownSkuInfo> countDownSkuInfo = this.CountDownInfo.CountDownSkuInfo;
         int num3;
         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 num  = 0;
             int num2 = countDownSkuInfo2.ActivityTotal - countDownSkuInfo2.BoughtCount;
             num = ((countDownSkuInfo2.TotalCount <= num2) ? countDownSkuInfo2.TotalCount : num2);
             this.hidden_SKUSubmitOrderCountDownStock.Value = ((num > 0) ? num.ToString() : "0");
             Label label = this.lblSKUSubmitOrderStockNow;
             num3       = countDownSkuInfo.Min((CountDownSkuInfo t) => t.TotalCount);
             label.Text = num3.ToString();
         }
         Literal literal = this.litMaxCount;
         num3         = this.CountDownInfo.MaxCount;
         literal.Text = num3.ToString();
     }
 }
Example #2
0
        public CountDownSkuInfo GetCountDownSkus(int countDownId, string skuId)
        {
            CountDownSkuInfo result           = null;
            DbCommand        sqlStringCommand = base.database.GetSqlStringCommand("SELECT CountDownSkuId,SkuId,SalePrice,TotalCount AS ActivityTotal,TotalCount,CountDownId,BoughtCount FROM Hishop_CountDownSku WHERE SkuId = @SkuId AND CountDownId = @CountDownId");

            base.database.AddInParameter(sqlStringCommand, "CountDownId", DbType.Int32, countDownId);
            base.database.AddInParameter(sqlStringCommand, "SkuId", DbType.String, skuId);
            using (IDataReader dataReader = base.database.ExecuteReader(sqlStringCommand))
            {
                if (dataReader.Read())
                {
                    result = DataMapper.PopulateCountDownSku(dataReader);
                }
            }
            return(result);
        }
Example #3
0
        public static CountDownSkuInfo PopulateCountDownSku(IDataReader reader)
        {
            if (reader == null)
            {
                return(null);
            }
            CountDownSkuInfo countDownSkuInfo = new CountDownSkuInfo();

            countDownSkuInfo.CountDownSkuId = ((IDataRecord)reader)["CountDownSkuId"].ToInt(0);
            countDownSkuInfo.SkuId          = ((IDataRecord)reader)["SkuId"].ToString();
            countDownSkuInfo.SalePrice      = ((IDataRecord)reader)["SalePrice"].ToDecimal(0).F2ToString("f2").ToDecimal(0);
            countDownSkuInfo.TotalCount     = ((IDataRecord)reader)["TotalCount"].ToInt(0);
            countDownSkuInfo.CountDownId    = ((IDataRecord)reader)["CountDownId"].ToInt(0);
            countDownSkuInfo.BoughtCount    = ((IDataRecord)reader)["BoughtCount"].ToInt(0);
            return(countDownSkuInfo);
        }
Example #4
0
        public CountDownInfo ProductExistsCountDown(int productId, string skuId = "", int storeId = 0, bool isOpenMultStore = false)
        {
            CountDownInfo countDownInfo = null;
            string        text          = "SELECT * FROM Hishop_CountDown WHERE ProductId = @ProductId AND getdate () BETWEEN startDate AND EndDate";

            if (isOpenMultStore)
            {
                text = ((storeId <= 0) ? (text + "  AND  (storeType=0 OR storeType=1 OR CountDownId IN (SELECT ActivityId FROM Hishop_StoreActivitys WHERE ActivityId=Hishop_CountDown.CountDownId and ActivityType=2 and StoreId=0))  ") : (text + " AND  (storeType=1 OR CountDownId IN (SELECT ActivityId FROM Hishop_StoreActivitys where ActivityId=Hishop_CountDown.CountDownId and ActivityType=2 and StoreId=@StoreId))"));
            }
            DbCommand sqlStringCommand = base.database.GetSqlStringCommand(text);

            base.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, productId);
            base.database.AddInParameter(sqlStringCommand, "StoreId", DbType.Int32, storeId);
            using (IDataReader dataReader = base.database.ExecuteReader(sqlStringCommand))
            {
                if (dataReader.Read())
                {
                    countDownInfo = DataMapper.PopulateCountDown(dataReader);
                }
            }
            if (!string.IsNullOrEmpty(skuId) && countDownInfo != null && storeId == 0 && !isOpenMultStore)
            {
                sqlStringCommand = base.database.GetSqlStringCommand("select CountDownSkuId, SkuId, SalePrice, TotalCount, CountDownId, BoughtCount  From  Hishop_CountDownSku where  CountDownId=@CountDownId and SkuId=@SkuId");
                base.database.AddInParameter(sqlStringCommand, "CountDownId", DbType.Int32, countDownInfo.CountDownId);
                base.database.AddInParameter(sqlStringCommand, "SkuId", DbType.String, skuId);
                using (IDataReader dataReader2 = base.database.ExecuteReader(sqlStringCommand))
                {
                    if (dataReader2.Read())
                    {
                        CountDownSkuInfo countDownSkuInfo = DataMapper.PopulateCountDownSku(dataReader2);
                        return((countDownSkuInfo.TotalCount > countDownSkuInfo.BoughtCount) ? countDownInfo : null);
                    }
                }
            }
            return(countDownInfo);
        }
Example #5
0
        private void btnAddCountDown_Click(object sender, EventArgs e)
        {
            CountDownInfo           countDownInfo = new CountDownInfo();
            List <CountDownSkuInfo> list          = new List <CountDownSkuInfo>();

            if (this.productId == 0)
            {
                this.ShowMsg(Formatter.FormatErrorMessage("请选择商品"), false);
            }
            else
            {
                countDownInfo.ProductId = this.productId;
                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
                    };
                    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
                {
                    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 (this.txtMaxCount.Text.Trim().ToInt(0) == 0)
                        {
                            this.ShowMsg("请填写每人限购数量", false);
                        }
                        else
                        {
                            countDownInfo.MaxCount = this.txtMaxCount.Text.ToInt(0);
                            if (PromoteHelper.ProductCountDownExist(countDownInfo.ProductId))
                            {
                                this.ShowMsg("已经存在此商品的限时抢购活动", false);
                            }
                            else
                            {
                                int num = 0;
                                num = ((this.rptProductSkus.Items.Count == 0) ? this.txtTotalCount.Text.Trim().ToInt(0) : list.Sum((CountDownSkuInfo c) => c.TotalCount));
                                if (!this.site.OpenMultStore && countDownInfo.MaxCount > num)
                                {
                                    this.ShowMsg(Formatter.FormatErrorMessage("每人限购数量不能大于活动库存"), false);
                                }
                                else if (!this.site.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 (!this.site.OpenMultStore && productDetails.Stock < countDownInfo.MaxCount)
                                        {
                                            this.ShowMsg("库存小于每人限购数量", false);
                                            return;
                                        }
                                        if (!this.site.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 (!this.site.OpenMultStore && countDownSkuInfo.TotalCount > sku.Value.Stock)
                                                {
                                                    this.ShowMsg("商品规格库存不足", false);
                                                    return;
                                                }
                                            }
                                        }
                                    }
                                    if (list.Count == 0)
                                    {
                                        DataTable skusByProductId = ProductHelper.GetSkusByProductId(this.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()
                                            };
                                            list.Add(item2);
                                        }
                                    }
                                    if (this.site.OpenMultStore)
                                    {
                                        if (string.IsNullOrEmpty(this.hidStoreIds.Value))
                                        {
                                            this.ShowMsg("请选择门店范围", false);
                                            return;
                                        }
                                        countDownInfo.StoreType = 2;
                                        countDownInfo.StoreIds  = this.hidStoreIds.Value;
                                    }
                                    else
                                    {
                                        countDownInfo.StoreType = 0;
                                    }
                                    PromoteHelper.AddCountDown(countDownInfo, list);
                                    if (countDownInfo.StartDate < DateTime.Now && countDownInfo.EndDate > DateTime.Now)
                                    {
                                        this.ShowMsg("添加限时抢购活动成功", true, "countdowns.aspx");
                                    }
                                    else
                                    {
                                        this.ShowMsg("添加限时抢购活动成功", true, "countdowns.aspx?State=1");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
 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();
         }
     }
 }