예제 #1
0
        /// <summary>
        /// 获取购物车列表 新增了对giftList的支持
        /// </summary>
        /// <param name="member"></param>
        /// <returns></returns>
        public List <ShoppingCartInfo> GetShoppingCartList(MemberInfo member)
        {
            List <ShoppingCartInfo> list = new List <ShoppingCartInfo>();
            ShoppingCartInfo        info = new ShoppingCartInfo();
            DbCommand sqlStringCommand   = this.database.GetSqlStringCommand("SELECT * FROM Hishop_ShoppingCarts WHERE UserId = @UserId;SELECT * FROM Hishop_GiftShoppingCarts gc JOIN Hishop_Gifts g ON gc.GiftId = g.GiftId WHERE gc.UserId = @UserId");

            this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, member.UserId);
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                while (reader.Read())
                {
                    ShoppingCartItemInfo item = this.GetCartItemInfo(member, (string)reader["SkuId"], (int)reader["Quantity"]);
                    if (item != null)
                    {
                        info.LineItems.Add(item);
                    }
                }
                reader.NextResult();
                while (reader.Read())
                {
                    ShoppingCartGiftInfo info3 = DataMapper.PopulateGiftCartItem(reader);
                    info3.Quantity = (int)reader["Quantity"];
                    info.LineGifts.Add(info3);
                }
                list.Add(info);
            }
            return(list);
        }
예제 #2
0
        public ShoppingCartInfo GetShoppingCart(int userId)
        {
            ShoppingCartInfo shoppingCartInfo = new ShoppingCartInfo();
            DbCommand        sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Ecshop_ShoppingCarts WHERE UserId = @UserId;SELECT * FROM Ecshop_GiftShoppingCarts gc JOIN Ecshop_Gifts g ON gc.GiftId = g.GiftId WHERE gc.UserId = @UserId");

            this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, userId);
            using (IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                Member member = HiContext.Current.User as Member;
                while (dataReader.Read())
                {
                    int storeId = 0;
                    if (dataReader["storeId"] != System.DBNull.Value)
                    {
                        storeId = (int)dataReader["storeId"];
                    }
                    ShoppingCartItemInfo cartItemInfo = this.GetCartItemInfo(member, (string)dataReader["SkuId"], (int)dataReader["Quantity"], storeId);
                    if (cartItemInfo != null)
                    {
                        shoppingCartInfo.LineItems.Add(cartItemInfo);
                    }
                }
                dataReader.NextResult();
                while (dataReader.Read())
                {
                    ShoppingCartGiftInfo shoppingCartGiftInfo = DataMapper.PopulateGiftCartItem(dataReader);
                    shoppingCartGiftInfo.Quantity = (int)dataReader["Quantity"];
                    shoppingCartInfo.LineGifts.Add(shoppingCartGiftInfo);
                }
            }
            return(shoppingCartInfo);
        }
예제 #3
0
        public ShoppingCartInfo GetShoppingCart(Member member)
        {
            ShoppingCartInfo shoppingCartInfo = new ShoppingCartInfo();

            DbCommand sqlStringCommand = this.database.GetSqlStringCommand(@"SELECT * FROM Ecshop_ShoppingCarts WHERE UserId = @UserId;SELECT * FROM Ecshop_GiftShoppingCarts gc JOIN Ecshop_Gifts g ON gc.GiftId = g.GiftId WHERE gc.UserId = @UserId;
select pp.ProductId as PromotionProductId, s.SkuId,ppp.ProductId,pro.ProductName,s.SKU,0 as ShipmentQuantity,s.CostPrice,s.SalePrice as ItemListPrice,0 as ItemAdjustedPrice,'' as SKUContent,
s.FactStock,p.ActivityId as PromotionId,p.Name as PromotionName,p.IsAscend,case when isnull(p.IsAscend,0) = 0 then p.DiscountValue when p.IsAscend = 1 then c.Quantity /p.Condition *  p.DiscountValue end  as DiscountValue,pro.ThumbnailUrl40,0 as storeId,pro.SupplierId,sp.SupplierName,sp.ShopName,sp.ShopOwner 
from Ecshop_PromotionProductsPresent   ppp 
inner join Ecshop_Promotions p  on ppp.ActivityId = p.ActivityId 
inner join Ecshop_PromotionProducts pp on ppp.ActivityId = pp.ActivityId 
left join Ecshop_SKUs s on s.ProductId = ppp.ProductId 
left join Ecshop_Skus ss on ss.ProductId = pp.ProductId 
left join Ecshop_Products pro on pro.ProductId = ppp.ProductId 
left join Ecshop_Supplier sp on pro.SupplierId = sp.SupplierId 
inner join Ecshop_ShoppingCarts  c on c.skuid = ss.skuid and userid =@UserId ");

            this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, member.UserId);
            using (IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                //Member member = HiContext.Current.User as Member;
                while (dataReader.Read())
                {
                    int storeId = 0;
                    if (dataReader["storeId"] != System.DBNull.Value)
                    {
                        storeId = (int)dataReader["storeId"];
                    }
                    ShoppingCartItemInfo cartItemInfo = this.GetCartItemInfo(member, (string)dataReader["SkuId"], (int)dataReader["Quantity"], storeId);
                    if (cartItemInfo != null)
                    {
                        shoppingCartInfo.LineItems.Add(cartItemInfo);
                    }
                }
                dataReader.NextResult();
                while (dataReader.Read())
                {
                    ShoppingCartGiftInfo shoppingCartGiftInfo = DataMapper.PopulateGiftCartItem(dataReader);
                    shoppingCartGiftInfo.Quantity = (int)dataReader["Quantity"];
                    shoppingCartInfo.LineGifts.Add(shoppingCartGiftInfo);
                }
                // 促销活动(商品)中的赠送商品
                if (dataReader.NextResult())
                {
                    while (dataReader.Read())
                    {
                        ShoppingCartPresentInfo present = DataMapper.PopulatePresentCartItem(dataReader);
                        shoppingCartInfo.LinePresentPro.Add(present);
                    }
                }
            }
            return(shoppingCartInfo);
        }
예제 #4
0
        private void LoadCartGift(ShoppingCartInfo cartInfo, Dictionary <int, int> giftQuantityList, string giftIds)
        {
            DbCommand sqlStringCommand = base.database.GetSqlStringCommand($"SELECT * FROM Hishop_Gifts WHERE GiftId in {giftIds.TrimEnd(',')}");

            using (IDataReader dataReader = base.database.ExecuteReader(sqlStringCommand))
            {
                while (dataReader.Read())
                {
                    ShoppingCartGiftInfo shoppingCartGiftInfo = DataMapper.PopulateGiftCartItem(dataReader);
                    shoppingCartGiftInfo.Quantity = giftQuantityList[shoppingCartGiftInfo.GiftId];
                    cartInfo.LineGifts.Add(shoppingCartGiftInfo);
                }
            }
        }
예제 #5
0
        void LoadCartGift(ShoppingCartInfo cartInfo, Dictionary <int, int> giftIdList, Dictionary <int, int> giftQuantityList, string giftIds)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand(string.Format("SELECT * FROM Hishop_Gifts WHERE GiftId in {0}", giftIds.TrimEnd(new char[] { ',' })));

            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                while (reader.Read())
                {
                    ShoppingCartGiftInfo item = DataMapper.PopulateGiftCartItem(reader);
                    item.Quantity = giftQuantityList[item.GiftId];
                    cartInfo.LineGifts.Add(item);
                }
            }
        }
예제 #6
0
        void LoadCartGift(ShoppingCartInfo cartInfo, Dictionary <int, int> giftIdList, Dictionary <int, int> giftQuantityList, string giftIds)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand(string.Format("SELECT g.*,hg.Unit,hg.LongDescription,hg.CostPrice,hg.ImageUrl,hg.ThumbnailUrl40,hg.ThumbnailUrl60,hg.ThumbnailUrl100,hg.PurchasePrice,hg.MarketPrice,hg.IsDownLoad FROM distro_Gifts g ON gc.GiftId = g.GiftId join Hishop_Gifts hg on hg.GiftId=g.GiftId WHERE g.GiftId IN ({0}) g.DistributorUserId={1}", giftIds.TrimEnd(new char[] { ',' }), HiContext.Current.SiteSettings.UserId.Value));

            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                while (reader.Read())
                {
                    ShoppingCartGiftInfo item = DataMapper.PopulateGiftCartItem(reader);
                    item.Quantity = giftQuantityList[item.GiftId];
                    cartInfo.LineGifts.Add(item);
                }
            }
        }
예제 #7
0
        public static ShoppingCartGiftInfo PopulateGiftCartItem(IDataReader reader)
        {
            ShoppingCartGiftInfo shoppingCartGiftInfo = new ShoppingCartGiftInfo();

            shoppingCartGiftInfo.UserId = (int)((IDataRecord)reader)["UserId"];
            shoppingCartGiftInfo.GiftId = (int)((IDataRecord)reader)["GiftId"];
            shoppingCartGiftInfo.Name   = (string)((IDataRecord)reader)["Name"];
            if (((IDataRecord)reader)["MarketPrice"] != DBNull.Value)
            {
                shoppingCartGiftInfo.CostPrice = ((IDataRecord)reader)["MarketPrice"].F2ToString("f2").ToDecimal(0);
            }
            shoppingCartGiftInfo.NeedPoint = (int)((IDataRecord)reader)["NeedPoint"];
            if (((IDataRecord)reader)["ThumbnailUrl40"] != DBNull.Value)
            {
                shoppingCartGiftInfo.ThumbnailUrl40 = (string)((IDataRecord)reader)["ThumbnailUrl40"];
            }
            if (((IDataRecord)reader)["ThumbnailUrl60"] != DBNull.Value)
            {
                shoppingCartGiftInfo.ThumbnailUrl60 = (string)((IDataRecord)reader)["ThumbnailUrl60"];
            }
            if (((IDataRecord)reader)["ThumbnailUrl100"] != DBNull.Value)
            {
                shoppingCartGiftInfo.ThumbnailUrl100 = (string)((IDataRecord)reader)["ThumbnailUrl100"];
            }
            if (((IDataRecord)reader)["ThumbnailUrl180"] != DBNull.Value)
            {
                shoppingCartGiftInfo.ThumbnailUrl180 = (string)((IDataRecord)reader)["ThumbnailUrl180"];
            }
            if (((IDataRecord)reader)["PromoType"] != DBNull.Value)
            {
                shoppingCartGiftInfo.PromoType = (int)((IDataRecord)reader)["PromoType"];
            }
            shoppingCartGiftInfo.ShippingTemplateId = ((IDataRecord)reader)["ShippingTemplateId"].ToInt(0);
            if (((IDataRecord)reader)["IsExemptionPostage"] != DBNull.Value)
            {
                bool isExemptionPostage = false;
                bool.TryParse(((IDataRecord)reader)["IsExemptionPostage"].ToString(), out isExemptionPostage);
                shoppingCartGiftInfo.IsExemptionPostage = isExemptionPostage;
            }
            else
            {
                shoppingCartGiftInfo.IsExemptionPostage = false;
            }
            shoppingCartGiftInfo.Weight = ((IDataRecord)reader)["Weight"].ToDecimal(0);
            shoppingCartGiftInfo.Volume = ((IDataRecord)reader)["Volume"].ToDecimal(0);
            return(shoppingCartGiftInfo);
        }
예제 #8
0
 private void BindSendGifts()
 {
     if (HiContext.Current.User.UserId != 0)
     {
         List <ShoppingCartGiftInfo> list = new List <ShoppingCartGiftInfo>();
         list.AddRange((from s in this.cart.LineGifts
                        where s.PromoType != 0
                        select s).ToList());
         if (!this.isGroupBuy && !this.isCountDown)
         {
             foreach (ShoppingCartItemInfo lineItem in this.cart.LineItems)
             {
                 PromotionInfo productPromotionInfo = ProductBrowser.GetProductPromotionInfo(lineItem.ProductId);
                 if (productPromotionInfo != null && productPromotionInfo.PromoteType == PromoteType.SentGift && this.storeId <= 0)
                 {
                     IList <GiftInfo> giftDetailsByGiftIds = ProductBrowser.GetGiftDetailsByGiftIds(productPromotionInfo.GiftIds);
                     foreach (GiftInfo item in giftDetailsByGiftIds)
                     {
                         ShoppingCartGiftInfo shoppingCartGiftInfo = new ShoppingCartGiftInfo();
                         shoppingCartGiftInfo.GiftId             = item.GiftId;
                         shoppingCartGiftInfo.Quantity           = lineItem.ShippQuantity;
                         shoppingCartGiftInfo.ShippingTemplateId = item.ShippingTemplateId;
                         shoppingCartGiftInfo.CostPrice          = (item.CostPrice.HasValue ? item.CostPrice.Value : decimal.Zero);
                         shoppingCartGiftInfo.Name               = item.Name;
                         shoppingCartGiftInfo.NeedPoint          = item.NeedPoint;
                         shoppingCartGiftInfo.PromoType          = (int)productPromotionInfo.PromoteType;
                         shoppingCartGiftInfo.Volume             = item.Volume;
                         shoppingCartGiftInfo.Weight             = item.Weight;
                         shoppingCartGiftInfo.ThumbnailUrl100    = item.ThumbnailUrl100;
                         shoppingCartGiftInfo.ThumbnailUrl180    = item.ThumbnailUrl180;
                         shoppingCartGiftInfo.ThumbnailUrl40     = item.ThumbnailUrl40;
                         shoppingCartGiftInfo.ThumbnailUrl60     = item.ThumbnailUrl60;
                         shoppingCartGiftInfo.IsExemptionPostage = item.IsExemptionPostage;
                         shoppingCartGiftInfo.ShippingTemplateId = item.ShippingTemplateId;
                         list.Add(shoppingCartGiftInfo);
                     }
                 }
             }
         }
         this.rptCartGifts.DataSource = list;
         this.rptCartGifts.DataBind();
         this.divlinegifts.Visible = (list.Count > 0);
     }
 }
예제 #9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            string text = context.Request["action"].ToNullString();

            if (string.IsNullOrEmpty(text) || text == "")
            {
                string text2 = string.Empty;
                string text3 = context.Request["ckids"];
                if (!string.IsNullOrEmpty(text3))
                {
                    text2 = text3;
                }
                string           a2 = context.Request["client"].ToNullString();
                ShoppingCartInfo shoppingCartInfo = (!(a2 == "wap")) ? ShoppingCartProcessor.GetShoppingCart(text2, false, false, -1) : ShoppingCartProcessor.GetMobileShoppingCart(text2, false, false, -1);
                if (shoppingCartInfo != null)
                {
                    string[] source = text2.Split(',');
                    bool     flag   = false;
                    bool     flag2  = true;
                    bool     flag3  = true;
                    foreach (ShoppingCartItemInfo lineItem in shoppingCartInfo.LineItems)
                    {
                        if (source.Contains(lineItem.SkuId) || source.Contains(lineItem.SkuId + "|" + lineItem.StoreId))
                        {
                            int skuStock = ShoppingCartProcessor.GetSkuStock(lineItem.SkuId, lineItem.StoreId);
                            if (skuStock < lineItem.Quantity)
                            {
                                flag = true;
                                break;
                            }
                            if (HiContext.Current.SiteSettings.OpenMultStore && lineItem.StoreId > 0)
                            {
                                StoresInfo storeById = StoresHelper.GetStoreById(lineItem.StoreId);
                                if (storeById != null)
                                {
                                    if (!SettingsManager.GetMasterSettings().Store_IsOrderInClosingTime)
                                    {
                                        DateTime dateTime = DateTime.Now;
                                        string   str      = dateTime.ToString("yyyy-MM-dd");
                                        dateTime = storeById.OpenStartDate;
                                        DateTime value = (str + " " + dateTime.ToString("HH:mm")).ToDateTime().Value;
                                        dateTime = DateTime.Now;
                                        string str2 = dateTime.ToString("yyyy-MM-dd");
                                        dateTime = storeById.OpenEndDate;
                                        DateTime dateTime2 = (str2 + " " + dateTime.ToString("HH:mm")).ToDateTime().Value;
                                        if (dateTime2 <= value)
                                        {
                                            dateTime2 = dateTime2.AddDays(1.0);
                                        }
                                        if (DateTime.Now < value || DateTime.Now > dateTime2)
                                        {
                                            flag3 = false;
                                        }
                                    }
                                    if (!storeById.CloseStatus && storeById.CloseEndTime.HasValue && storeById.CloseBeginTime.HasValue && storeById.CloseEndTime.Value > DateTime.Now && storeById.CloseBeginTime.Value < DateTime.Now)
                                    {
                                        flag2 = false;
                                    }
                                }
                            }
                        }
                    }
                    if (flag)
                    {
                        context.Response.ContentType = "text/json";
                        context.Response.Write("{\"status\":\"false\",\"msg\":\"有商品库存不足,不能结算\"}");
                        context.Response.End();
                    }
                    if (!flag3)
                    {
                        context.Response.ContentType = "text/json";
                        context.Response.Write("{\"status\":\"StoreNotInTime\",\"msg\":\"非营业时间\"}");
                        context.Response.End();
                    }
                    if (!flag2)
                    {
                        context.Response.ContentType = "text/json";
                        context.Response.Write("{\"status\":\"StoreNotOpen\",\"msg\":\"歇业中\"}");
                        context.Response.End();
                    }
                    if (shoppingCartInfo != null)
                    {
                        ShoppingCartGiftInfo shoppingCartGiftInfo = (from a in shoppingCartInfo.LineGifts
                                                                     where a.PromoType == 5
                                                                     select a).FirstOrDefault();
                        shoppingCartInfo.SendGiftPromotionId = (shoppingCartGiftInfo?.GiftId ?? 0);
                        if (!shoppingCartInfo.IsSendGift && shoppingCartInfo.LineGifts.Count > 0)
                        {
                            foreach (ShoppingCartGiftInfo lineGift in shoppingCartInfo.LineGifts)
                            {
                                ShoppingCartProcessor.RemoveGiftItem(lineGift.GiftId, PromoteType.SentGift);
                            }
                        }
                    }
                    string s = JsonConvert.SerializeObject(shoppingCartInfo);
                    context.Response.ContentType = "text/json";
                    context.Response.Write(s);
                }
            }
            else if (text == "ClearCart")
            {
                string text4 = context.Request.Form["ck_productId"].ToNullString();
                if (string.IsNullOrEmpty(text4))
                {
                    context.Response.Write("{\"status\":\"false\",\"msg\":\"请选择要清除的商品\"}");
                }
                else
                {
                    string[] array = text4.Split(',');
                    foreach (string text5 in array)
                    {
                        string[] array2 = text5.Split('|');
                        if (array2.Length == 2)
                        {
                            ShoppingCartProcessor.RemoveLineItem(array2[0], array2[1].ToInt(0));
                        }
                        else
                        {
                            ShoppingCartProcessor.RemoveLineItem(text5, 0);
                        }
                    }
                    context.Response.Write("{\"status\":\"true\",\"msg\":\"清除成功\"}");
                }
                context.Response.End();
            }
            else if (text == "HasStore")
            {
                string       text6          = context.Request.Form["skuId"].ToNullString();
                SiteSettings masterSettings = SettingsManager.GetMasterSettings();
                if (string.IsNullOrEmpty(text6) || !masterSettings.OpenMultStore)
                {
                    context.Response.Write("{\"status\":\"false\"}");
                }
                else if (ShoppingCartProcessor.HasStoreSkuStocks(text6))
                {
                    context.Response.Write("{\"status\":\"true\"}");
                }
                else
                {
                    context.Response.Write("{\"status\":\"false\"}");
                }
            }
            else if (text == "ProductsHasStore")
            {
                string       text7           = context.Request.Form["productIds"];
                SiteSettings masterSettings2 = SettingsManager.GetMasterSettings();
                if (string.IsNullOrEmpty(text7) || !masterSettings2.OpenMultStore)
                {
                    context.Response.Write("{\"status\":\"false\"}");
                }
                else
                {
                    string str3 = ShoppingCartProcessor.HasStoreByProducts(text7);
                    context.Response.Write("{\"status\":\"true\",\"productIds\":\"" + str3 + "\"}");
                }
            }
            else if (text == "updateBuyNum")
            {
                string               skuid                = context.Request.Form["SkuId"].ToNullString().Trim();
                int                  num                  = context.Request.Form["BuyNum"].ToNullString().Trim().ToInt(0);
                string               a3                   = context.Request.Form["client"].ToNullString().Trim();
                ShoppingCartInfo     shoppingCartInfo2    = (!(a3 == "wap")) ? ShoppingCartProcessor.GetShoppingCart(null, false, false, -1) : ShoppingCartProcessor.GetMobileShoppingCart(null, false, false, -1);
                ShoppingCartItemInfo shoppingCartItemInfo = shoppingCartInfo2.LineItems.FirstOrDefault((ShoppingCartItemInfo a) => a.SkuId == skuid);
                int                  num2                 = shoppingCartItemInfo?.Quantity ?? 1;
                if (num <= 0)
                {
                    context.Response.Write("{\"status\":\"numError\",\"msg\":\"购买数量必须为大于0的整数\",\"oldNumb\":\"" + num2 + "\"}");
                }
                else if (ShoppingCartProcessor.GetSkuStock(skuid, 0) < num)
                {
                    context.Response.Write("{\"status\":\"StockError\",\"msg\":\"该商品库存不足\",\"oldNumb\":\"" + num2 + "\"}");
                }
                else
                {
                    ShoppingCartProcessor.UpdateLineItemQuantity(skuid, num, 0);
                    PromotionInfo productQuantityDiscountPromotion = ShoppingCartProcessor.GetProductQuantityDiscountPromotion(skuid, HiContext.Current.User.GradeId);
                    if (productQuantityDiscountPromotion != null && (decimal)num >= productQuantityDiscountPromotion.Condition)
                    {
                        shoppingCartItemInfo.AdjustedPrice = shoppingCartItemInfo.MemberPrice * productQuantityDiscountPromotion.DiscountValue;
                    }
                    else
                    {
                        shoppingCartItemInfo.AdjustedPrice = shoppingCartItemInfo.MemberPrice;
                    }
                    context.Response.Write("{\"status\":\"true\",\"adjustedPrice\":" + shoppingCartItemInfo.AdjustedPrice.F2ToString("f2") + "}");
                }
            }
            else if (text == "updateGiftBuyNum")
            {
                string               giftId                = context.Request.Form["giftId"].ToNullString().Trim();
                int                  num3                  = context.Request.Form["BuyNum"].ToNullString().Trim().ToInt(0);
                string               a4                    = context.Request.Form["client"].ToNullString().Trim();
                ShoppingCartInfo     shoppingCartInfo3     = (!(a4 == "wap")) ? ShoppingCartProcessor.GetShoppingCart(null, false, false, -1) : ShoppingCartProcessor.GetMobileShoppingCart(null, false, false, -1);
                ShoppingCartGiftInfo shoppingCartGiftInfo2 = shoppingCartInfo3.LineGifts.FirstOrDefault((ShoppingCartGiftInfo a) => a.GiftId == giftId.ToInt(0));
                if (shoppingCartGiftInfo2 == null)
                {
                    context.Response.Write("{\"status\":\"nullError\",\"msg\":\"该礼品不存在或已删除\",\"oldNumb\":\"" + 0 + "\"}");
                }
                else if (num3 <= 0)
                {
                    context.Response.Write("{\"status\":\"numError\",\"msg\":\"购买数量必须为大于0的整数\",\"oldNumb\":\"" + shoppingCartGiftInfo2.Quantity + "\"}");
                }
                else
                {
                    ShoppingCartProcessor.UpdateGiftItemQuantity(giftId.ToInt(0), num3, PromoteType.NotSet);
                    context.Response.Write("{\"status\":\"true\"}");
                }
            }
            else if (text == "deleteGift")
            {
                string text8 = context.Request.Form["giftId"].ToNullString().Trim();
                text8 = text8.TrimStart(',').TrimEnd(',');
                string[] array3 = text8.Split(',');
                foreach (string text9 in array3)
                {
                    ShoppingCartProcessor.RemoveGiftItem(text8.ToInt(0), PromoteType.NotSet);
                }
                context.Response.Write("{\"status\":\"true\"}");
            }
            else if (text == "deletestore")
            {
                string skuId   = context.Request.Form["SkuId"].ToNullString().Trim();
                int    storeId = context.Request.Form["StoreId"].ToInt(0);
                ShoppingCartProcessor.RemoveLineItem(skuId, storeId);
                context.Response.Write("{\"status\":\"true\"}");
            }
            else if (text == "delete")
            {
                string skuId2 = context.Request.Form["SkuId"].ToNullString().Trim();
                ShoppingCartProcessor.RemoveLineItem(skuId2, 0);
                context.Response.Write("{\"status\":\"true\"}");
            }
            else if (text == "deleteall")
            {
                string text10 = context.Request.Form["SkuIdList"].ToNullString().Trim();
                if (!string.IsNullOrEmpty(text10.ToNullString().Trim()))
                {
                    text10 = text10.TrimStart(',').TrimEnd(',');
                    string[] array4 = text10.Split(',');
                    foreach (string skuId3 in array4)
                    {
                        ShoppingCartProcessor.RemoveLineItem(skuId3, 0);
                    }
                }
                context.Response.Write("{\"status\":\"true\"}");
            }
            else if (text == "reducedpromotion")
            {
                decimal       amount           = context.Request.Form["Amount"].ToDecimal(0);
                int           quantity         = context.Request.Form["Quantity"].ToInt(0);
                MemberInfo    user             = HiContext.Current.User;
                decimal       num4             = default(decimal);
                PromotionInfo reducedPromotion = new PromotionDao().GetReducedPromotion(user.GradeId, amount, quantity, out num4, 0);
                if (reducedPromotion != null)
                {
                    context.Response.Write("{\"ReducedPromotionAmount\":\"" + num4 + "\",\"ReducedPromotionCondition\":\"" + reducedPromotion.Condition + "\"}");
                }
                else
                {
                    context.Response.Write("{\"ReducedPromotionAmount\":\"0\",\"ReducedPromotionCondition\":\"0\"}");
                }
            }
        }
예제 #10
0
 protected void rptCartStore_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         Control  control  = e.Item.Controls[0];
         Literal  literal  = control.FindControl("ltlTop") as Literal;
         Literal  literal2 = control.FindControl("ltlBottom") as Literal;
         Control  control2 = control.FindControl("divStoreTitle");
         Literal  literal3 = control.FindControl("ltlSKUContent") as Literal;
         Repeater repeater = control.FindControl("repProductGifts") as Repeater;
         string[] array    = literal3.Text.Split(';');
         string   text     = string.Empty;
         string[] array2   = array;
         foreach (string text2 in array2)
         {
             string[] array3 = text2.Split(':');
             if (array3.Length == 2)
             {
                 text = text + " " + array3[1] + " /";
             }
         }
         string text3     = text;
         char[] trimChars = new char[1]
         {
             '/'
         };
         text = (literal3.Text = text3.TrimEnd(trimChars));
         ShoppingCartItemInfo itemInfo = e.Item.DataItem as ShoppingCartItemInfo;
         int itemIndex = e.Item.ItemIndex;
         if (itemInfo.StoreId == this.nowStoreId)
         {
             literal.Visible  = false;
             control2.Visible = false;
         }
         else
         {
             literal.Visible  = true;
             control2.Visible = true;
             this.nowStoreId  = itemInfo.StoreId;
         }
         if (this.liststore.Count - 1 == itemIndex || this.liststore[itemIndex + 1].StoreId != itemInfo.StoreId)
         {
             literal2.Visible = true;
         }
         else
         {
             literal2.Visible = false;
         }
         PromotionInfo productPromotionInfo = ProductBrowser.GetProductPromotionInfo(itemInfo.ProductId);
         if (productPromotionInfo != null && productPromotionInfo.PromoteType == PromoteType.SentGift)
         {
             List <ShoppingCartGiftInfo> cartGiftList         = new List <ShoppingCartGiftInfo>();
             IList <GiftInfo>            giftDetailsByGiftIds = ProductBrowser.GetGiftDetailsByGiftIds(productPromotionInfo.GiftIds);
             giftDetailsByGiftIds.ForEach(delegate(GiftInfo gift)
             {
                 ShoppingCartGiftInfo shoppingCartGiftInfo = new ShoppingCartGiftInfo();
                 shoppingCartGiftInfo.GiftId             = gift.GiftId;
                 shoppingCartGiftInfo.CostPrice          = (gift.CostPrice.HasValue ? gift.CostPrice.Value : decimal.Zero);
                 shoppingCartGiftInfo.PromoType          = 5;
                 shoppingCartGiftInfo.Quantity           = itemInfo.ShippQuantity;
                 shoppingCartGiftInfo.Weight             = gift.Weight;
                 shoppingCartGiftInfo.Volume             = gift.Volume;
                 shoppingCartGiftInfo.NeedPoint          = gift.NeedPoint;
                 shoppingCartGiftInfo.Name               = gift.Name;
                 shoppingCartGiftInfo.ThumbnailUrl100    = gift.ThumbnailUrl100;
                 shoppingCartGiftInfo.ThumbnailUrl180    = gift.ThumbnailUrl180;
                 shoppingCartGiftInfo.ThumbnailUrl40     = gift.ThumbnailUrl40;
                 shoppingCartGiftInfo.ThumbnailUrl60     = gift.ThumbnailUrl60;
                 shoppingCartGiftInfo.IsExemptionPostage = gift.IsExemptionPostage;
                 shoppingCartGiftInfo.ShippingTemplateId = gift.ShippingTemplateId;
                 cartGiftList.Add(shoppingCartGiftInfo);
             });
             repeater.DataSource = cartGiftList;
             repeater.DataBind();
         }
     }
 }
예제 #11
0
 private void rptCartProducts_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (HiContext.Current.User.UserId != 0 && (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem))
     {
         Control              control  = e.Item.Controls[0];
         Literal              literal  = control.FindControl("ltlSKUContent") as Literal;
         Repeater             repeater = control.FindControl("repProductGifts") as Repeater;
         Control              control2 = control.FindControl("divChangeAmount");
         Control              control3 = control.FindControl("ck_productId");
         Control              control4 = control.FindControl("lblNoStock");
         Control              control5 = control.FindControl("lblInValid");
         Control              control6 = control.FindControl("divQuantity");
         ShoppingCartItemInfo itemInfo = e.Item.DataItem as ShoppingCartItemInfo;
         if (!itemInfo.IsValid)
         {
             control2.Visible = false;
             control6.Visible = true;
             control3.Visible = false;
             control4.Visible = false;
             control5.Visible = true;
         }
         else
         {
             control5.Visible = false;
             string[] array  = itemInfo.SkuContent.Split(';');
             string   text   = string.Empty;
             string[] array2 = array;
             foreach (string text2 in array2)
             {
                 string[] array3 = text2.Split(':');
                 if (array3.Length == 2)
                 {
                     text = text + " " + array3[1] + " /";
                 }
             }
             string text3     = text;
             char[] trimChars = new char[1]
             {
                 '/'
             };
             text = (literal.Text = text3.TrimEnd(trimChars));
             int skuStock = ShoppingCartProcessor.GetSkuStock(itemInfo.SkuId, 0);
             if (skuStock < itemInfo.Quantity || skuStock <= 0)
             {
                 control2.Visible = false;
                 control3.Visible = false;
                 control4.Visible = true;
                 control6.Visible = true;
             }
             else
             {
                 control4.Visible = false;
                 control6.Visible = false;
             }
         }
         PromotionInfo productPromotionInfo = ProductBrowser.GetProductPromotionInfo(itemInfo.ProductId);
         if (productPromotionInfo != null && productPromotionInfo.PromoteType == PromoteType.SentGift)
         {
             List <ShoppingCartGiftInfo> cartGiftList         = new List <ShoppingCartGiftInfo>();
             IList <GiftInfo>            giftDetailsByGiftIds = ProductBrowser.GetGiftDetailsByGiftIds(productPromotionInfo.GiftIds);
             giftDetailsByGiftIds.ForEach(delegate(GiftInfo gift)
             {
                 ShoppingCartGiftInfo shoppingCartGiftInfo = new ShoppingCartGiftInfo();
                 shoppingCartGiftInfo.GiftId             = gift.GiftId;
                 shoppingCartGiftInfo.CostPrice          = (gift.CostPrice.HasValue ? gift.CostPrice.Value : decimal.Zero);
                 shoppingCartGiftInfo.PromoType          = 5;
                 shoppingCartGiftInfo.Quantity           = itemInfo.ShippQuantity;
                 shoppingCartGiftInfo.Weight             = gift.Weight;
                 shoppingCartGiftInfo.Volume             = gift.Volume;
                 shoppingCartGiftInfo.NeedPoint          = gift.NeedPoint;
                 shoppingCartGiftInfo.Name               = gift.Name;
                 shoppingCartGiftInfo.ThumbnailUrl100    = gift.ThumbnailUrl100;
                 shoppingCartGiftInfo.ThumbnailUrl180    = gift.ThumbnailUrl180;
                 shoppingCartGiftInfo.ThumbnailUrl40     = gift.ThumbnailUrl40;
                 shoppingCartGiftInfo.ThumbnailUrl60     = gift.ThumbnailUrl60;
                 shoppingCartGiftInfo.IsExemptionPostage = gift.IsExemptionPostage;
                 shoppingCartGiftInfo.ShippingTemplateId = gift.ShippingTemplateId;
                 cartGiftList.Add(shoppingCartGiftInfo);
             });
             repeater.DataSource = cartGiftList;
             repeater.DataBind();
         }
     }
 }