Exemple #1
0
        /// <summary>
        /// 添加商品至购物车
        /// </summary>
        /// <param name="productSysNo">商品系统编号</param>
        /// <param name="quantity">商品数量</param>
        /// <param name="source">购物车商品来源</param>
        /// <param name="sysNo">系统编号</param>
        /// <returns>购物车商品明细</returns>
        /// <remarks>2013-08-13 吴文强 创建</remarks>
        private CBCrShoppingCartItem ProductToCartItem(int productSysNo, int quantity, CustomerStatus.购物车商品来源 source = CustomerStatus.购物车商品来源.PC网站,
                                                       CustomerStatus.商品销售类型 productSalesType = CustomerStatus.商品销售类型.普通,
                                                       CustomerStatus.是否选中 isChecked          = CustomerStatus.是否选中.是, int sysNo = 0, string promotions = null)
        {
            var shoppingCartItem = new CBCrShoppingCartItem();

            var productPrices = PdPriceBo.Instance.GetProductPrice(productSysNo,
                                                                   new ProductStatus.产品价格来源[] { ProductStatus.产品价格来源.会员等级价 });
            var firstOrDefault = productPrices.FirstOrDefault(p => p.SourceSysNo == CustomerLevel.初级);

            if (firstOrDefault != null)
            {
                shoppingCartItem = new CBCrShoppingCartItem
                {
                    SysNo            = sysNo,
                    IsChecked        = (int)isChecked,
                    CustomerSysNo    = -1,
                    ProductSysNo     = productSysNo,
                    ProductName      = "",
                    Quantity         = quantity,
                    OriginPrice      = firstOrDefault.Price,
                    IsLock           = (int)CustomerStatus.购物车是否锁定.否,
                    IsExpireReset    = (int)CustomerStatus.购物车是否过期重置.是,
                    CreateDate       = DateTime.Now,
                    Source           = (int)source,
                    ProductSalesType = (int)productSalesType,
                    Promotions       = promotions,
                    UsedPromotions   = promotions,
                };
            }

            return(shoppingCartItem);
        }
Exemple #2
0
        /// <summary>
        /// 选择/取消选择购物车所有明细项目
        /// </summary>
        /// <param name="customerSysNo">客户系统编号</param>
        /// <param name="isChecked">是否选中(CustomerStatus.是否选中)</param>
        /// <returns></returns>
        /// <remarks>2013-08-27 吴文强 创建</remarks>
        public override void UpdateCheckedItem(int customerSysNo, CustomerStatus.是否选中 isChecked)
        {
            const string strSql = @"
                        update CrShoppingCartItem 
                        set IsChecked = @IsChecked
                        where customersysno = @customersysno 
                          and ProductSalesType != @ProductSalesType";

            Context.Sql(strSql)
            .Parameter("IsChecked", (int)isChecked)
            .Parameter("customersysno", customerSysNo)
            .Parameter("ProductSalesType", (int)CustomerStatus.商品销售类型.赠品).Execute();
        }
Exemple #3
0
        /// <summary>
        /// 选择/取消选择购物车明细项目
        /// </summary>
        /// <param name="customerSysNo">客户系统编号</param>
        /// <param name="sysNo">购物车明细系统编号</param>
        /// <param name="isChecked">是否选中(CustomerStatus.是否选中)</param>
        /// <returns></returns>
        /// <remarks>2013-08-27 吴文强 创建</remarks>
        public override void UpdateCheckedItem(int customerSysNo, int[] sysNo, CustomerStatus.是否选中 isChecked)
        {
            if (sysNo == null || sysNo.Count() == 0)
            {
                return;
            }

            const string strSql = @"
                        update CrShoppingCartItem 
                        set IsChecked = @IsChecked
                        where customersysno = @customersysno 
                          and sysno in(@sysNo)";

            Context.Sql(strSql)
            .Parameter("IsChecked", (int)isChecked)
            .Parameter("customersysno", customerSysNo)
            .Parameter("sysNo", sysNo).Execute();
        }
        /// <summary>
        /// 将组促销转换为购物车明细
        /// </summary>
        /// <param name="cacheKey">缓存Key</param>
        /// <param name="customerSysNo">客户系统编号</param>
        /// <param name="groupSysNo">组系统编号(组合,团购主表系统编号)</param>
        /// <param name="quantity">组数量</param>
        /// <param name="promotionSysNo">促销系统编号</param>
        /// <param name="source">购物车商品来源</param>
        /// <param name="isChecked">是否选中商品</param>
        /// <returns>购物车明细集合</returns>
        /// <remarks>2013-09-01 吴文强 创建</remarks>
        public void Add(string cacheKey, int customerSysNo, int groupSysNo, int quantity, int promotionSysNo, CustomerStatus.购物车商品来源 source, CustomerStatus.是否选中 isChecked = CustomerStatus.是否选中.是)
        {
            _cacheKey = cacheKey;

            #region 计算并写入Cache

            var items      = CacheItems;
            var groupItems = InitGroupToCartItem(customerSysNo, groupSysNo, quantity, promotionSysNo, source);

            //检查是否已存在未锁定商品,存在+1,不存在新增

            foreach (var shoppingCartItem in groupItems)
            {
                var item = items.FirstOrDefault(sci => sci.ProductSysNo == shoppingCartItem.ProductSysNo &&
                                                sci.CustomerSysNo == customerSysNo && sci.IsLock == shoppingCartItem.IsLock &&
                                                sci.GroupCode == shoppingCartItem.GroupCode && sci.Promotions == shoppingCartItem.Promotions);

                if (item == null)
                {
                    shoppingCartItem.SysNo = SeqSysNo;

                    items.Add(shoppingCartItem);
                }
                else
                {
                    item.Quantity = item.Quantity + quantity;
                }
            }

            CacheItems = items;

            #endregion
        }
        /// <summary>
        /// 添加商品至购物车
        /// </summary>
        /// <param name="cacheKey">缓存Key</param>
        /// <param name="customerSysNo">客户系统编号</param>
        /// <param name="productSysNo">商品系统编号</param>
        /// <param name="quantity">商品数量</param>
        /// <param name="source">购物车商品来源</param>
        /// <param name="isChecked">是否选中商品</param>
        /// <remarks>2013-08-13 吴文强 创建</remarks>
        public void Add(string cacheKey, int customerSysNo, int productSysNo, int quantity, CustomerStatus.购物车商品来源 source, CustomerStatus.是否选中 isChecked = CustomerStatus.是否选中.是)
        {
            _cacheKey = cacheKey;

            var productPrices = PdPriceBo.Instance.GetProductPrice(productSysNo,
                                                                   new ProductStatus.产品价格来源[] { ProductStatus.产品价格来源.会员等级价 });
            var customer       = CrCustomerBo.Instance.GetModel(customerSysNo);
            var firstOrDefault = productPrices.FirstOrDefault(p => customer != null ? p.SourceSysNo == customer.LevelSysNo : p.SourceSysNo == CustomerLevel.初级);

            if (firstOrDefault != null)
            {
                var shoppingCartItem = new CBCrShoppingCartItem
                {
                    SysNo            = SeqSysNo,
                    IsChecked        = (int)isChecked,
                    CustomerSysNo    = customerSysNo,
                    ProductSysNo     = productSysNo,
                    ProductName      = "",
                    Quantity         = quantity,
                    OriginPrice      = firstOrDefault.Price,
                    IsLock           = (int)CustomerStatus.购物车是否锁定.否,
                    IsExpireReset    = (int)CustomerStatus.购物车是否过期重置.是,
                    CreateDate       = DateTime.Now,
                    Source           = (int)source,
                    ProductSalesType = (int)CustomerStatus.商品销售类型.普通,
                };

                #region 计算并写入Cache

                var items = CacheItems;
                var item  = items.FirstOrDefault(sci => sci.ProductSysNo == shoppingCartItem.ProductSysNo);
                if (item == null)
                {
                    items.Add(shoppingCartItem);
                }
                else
                {
                    item.Quantity = item.Quantity + quantity;
                }
                CacheItems = items;

                #endregion
            }
        }
        /// <summary>
        /// 将组促销转换为购物车明细
        /// </summary>
        /// <param name="customerSysNo">客户系统编号</param>
        /// <param name="groupSysNo">组系统编号(组合,团购主表系统编号)</param>
        /// <param name="quantity">组数量</param>
        /// <param name="promotionSysNo">促销系统编号</param>
        /// <param name="source">购物车商品来源</param>
        /// <param name="isChecked">是否选中商品</param>
        /// <returns>购物车明细集合</returns>
        /// <remarks>2013-09-01 吴文强 创建</remarks>
        private IList <CBCrShoppingCartItem> InitGroupToCartItem(int customerSysNo, int groupSysNo, int quantity,
                                                                 int promotionSysNo, CustomerStatus.购物车商品来源 source, CustomerStatus.是否选中 isChecked = CustomerStatus.是否选中.是)
        {
            var result    = new List <CBCrShoppingCartItem>();
            var promotion = SpPromotionBo.Instance.GetPromotions(new[] { promotionSysNo }).FirstOrDefault();

            if (promotion == null)
            {
                return(result);
            }

            switch (promotion.PromotionType)
            {
            case (int)PromotionStatus.促销应用类型.组合套餐:
                //获取套餐明细
                var comboItems = ISpComboItemDao.Instance.GetListByComboSysNo(groupSysNo);

                //将明细添加至购物车明细集合
                result.AddRange(comboItems.Select(item => new CBCrShoppingCartItem
                {
                    ProductName           = item.ProductName,
                    CustomerSysNo         = customerSysNo,
                    ProductSysNo          = item.ProductSysNo,
                    Quantity              = quantity,
                    OriginPrice           = 0,
                    IsChecked             = (int)isChecked,
                    IsLock                = (int)CustomerStatus.购物车是否锁定.是,
                    IsExpireReset         = (int)CustomerStatus.购物车是否过期重置.是,
                    CreateDate            = DateTime.Now,
                    Source                = (int)CustomerStatus.购物车商品来源.PC网站,
                    ProductSalesType      = (int)CustomerStatus.商品销售类型.组合,
                    Promotions            = promotionSysNo.ToString(),
                    UsedPromotions        = promotionSysNo.ToString(),
                    GroupCode             = groupSysNo.ToString(),
                    ProductSalesTypeSysNo = item.SysNo,
                }));

                break;

            case (int)PromotionStatus.促销应用类型.团购:
                //获取套餐明细
                var groupShoppingItem = IGsGroupShoppingItemDao.Instance.GetItem(groupSysNo);

                //将明细添加至购物车明细集合
                result.AddRange(groupShoppingItem.Select(item => new CBCrShoppingCartItem
                {
                    ProductName           = item.ProductName,
                    CustomerSysNo         = customerSysNo,
                    ProductSysNo          = item.ProductSysNo,
                    Quantity              = quantity,
                    OriginPrice           = 0,
                    IsChecked             = (int)isChecked,
                    IsLock                = (int)CustomerStatus.购物车是否锁定.是,
                    IsExpireReset         = (int)CustomerStatus.购物车是否过期重置.是,
                    CreateDate            = DateTime.Now,
                    Source                = (int)CustomerStatus.购物车商品来源.PC网站,
                    ProductSalesType      = (int)CustomerStatus.商品销售类型.团购,
                    Promotions            = promotionSysNo.ToString(),
                    UsedPromotions        = promotionSysNo.ToString(),
                    GroupCode             = groupSysNo.ToString(),
                    ProductSalesTypeSysNo = item.SysNo,
                }));
                break;
            }
            return(result);
        }
Exemple #7
0
 /// <summary>
 /// 根据赠品转购物车明细
 /// </summary>
 /// <param name="productSysNo">商品系统编号</param>
 /// <param name="quantity">数量</param>
 /// <param name="source">购物车商品来源</param>
 /// <param name="isChecked">是否选中</param>
 /// <returns>购物车明细</returns>
 /// <remarks>2013-11-14 吴文强 创建</remarks>
 public CBCrShoppingCartItem GetCartItemByProduct(int productSysNo, int quantity,
                                                  CustomerStatus.购物车商品来源 source, CustomerStatus.是否选中 isChecked = CustomerStatus.是否选中.是)
 {
     return(new CBCrShoppingCartItem
     {
         IsChecked = (int)isChecked,
         ProductSysNo = productSysNo,
         ProductName = "",
         Quantity = quantity,
         OriginPrice = 0,
         IsLock = (int)CustomerStatus.购物车是否锁定.否,
         CreateDate = DateTime.Now,
         Source = (int)source,
         ProductSalesType = (int)CustomerStatus.商品销售类型.普通,
     });
 }
Exemple #8
0
        /// <summary>
        /// 选择购物车明细项目
        /// </summary>
        /// <param name="customerSysNo">客户系统编号</param>
        /// <param name="groupCode">组代码</param>
        /// <param name="promotionSysNo">促销系统编号</param>
        /// <param name="isChecked">是否选中(CustomerStatus.是否选中)</param>
        /// <returns></returns>
        /// <remarks>2013-08-27 吴文强 创建</remarks>
        public override void UpdateCheckedItem(int customerSysNo, string groupCode, string promotionSysNo, CustomerStatus.是否选中 isChecked)
        {
            if (groupCode == null || promotionSysNo == null)
            {
                return;
            }

            const string strSql = @"
                        update CrShoppingCartItem 
                        set IsChecked = @IsChecked
                        where customersysno = @customersysno 
                          and IsLock = @islock
                          and GroupCode = @groupcode
                          and promotions = @promotions";

            Context.Sql(strSql)
            .Parameter("IsChecked", (int)isChecked)
            .Parameter("customersysno", customerSysNo)
            .Parameter("islock", (int)CustomerStatus.购物车是否锁定.是)
            .Parameter("groupcode", groupCode)
            .Parameter("promotions", promotionSysNo).Execute();
        }
 /// <summary>
 /// 选择购物车明细项目
 /// </summary>
 /// <param name="customerSysNo">客户系统编号</param>
 /// <param name="groupCode">组代码</param>
 /// <param name="promotionSysNo">促销系统编号</param>
 /// <param name="isChecked">是否选中(CustomerStatus.是否选中)</param>
 /// <returns></returns>
 /// <remarks>2013-08-27 吴文强 创建</remarks>
 public abstract void UpdateCheckedItem(int customerSysNo, string groupCode, string promotionSysNo, CustomerStatus.是否选中 isChecked);
 /// <summary>
 /// 选择购物车明细项目
 /// </summary>
 /// <param name="customerSysNo">客户系统编号</param>
 /// <param name="sysNo">购物车明细系统编号</param>
 /// <param name="isChecked">是否选中(CustomerStatus.是否选中)</param>
 /// <returns></returns>
 /// <remarks>2013-08-27 吴文强 创建</remarks>
 public abstract void UpdateCheckedItem(int customerSysNo, int[] sysNo, CustomerStatus.是否选中 isChecked);