Пример #1
0
/// <summary>
/// 更新信息
/// </summary>
        public int UpdateInfo(SqlTransaction trans, ProductSpuModel proModel, long SN)
        {
            string key = "Cache_ProductSpu_Model_" + SN;

            CacheHelper.RemoveCache(key);
            return(proDAL.UpdateInfo(trans, proModel, SN));
        }
Пример #2
0
        /// <summary>
        /// 从缓存读取信息
        /// </summary>
        public ProductSpuModel GetCacheModel(SqlTransaction trans, string ProductSpuId)
        {
            string key   = "Cache_ProductSpu_Model_" + ProductSpuId;
            object value = CacheHelper.GetCache(key);

            if (value != null)
            {
                return((ProductSpuModel)value);
            }
            else
            {
                ProductSpuModel proSpuModel = GetModel2(trans, ProductSpuId);
                CacheHelper.AddCache(key, proSpuModel, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20), CacheItemPriority.Normal, null);
                return(proSpuModel);
            }
        }
Пример #3
0
/// <summary>
/// 从缓存读取信息
/// </summary>
        public ProductSpuModel GetCacheInfo(SqlTransaction trans, long SN)
        {
            string key   = "Cache_ProductSpu_Model_" + SN;
            object value = CacheHelper.GetCache(key);

            if (value != null)
            {
                return((ProductSpuModel)value);
            }
            else
            {
                ProductSpuModel proModel = proDAL.GetInfo(trans, SN);
                CacheHelper.AddCache(key, proModel, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20), CacheItemPriority.Normal, null);
                return(proModel);
            }
        }
Пример #4
0
/// <summary>
/// 插入信息
/// </summary>
        public int InsertInfo(SqlTransaction trans, ProductSpuModel proModel)
        {
            return(proDAL.InsertInfo(trans, proModel));
        }
Пример #5
0
        public void CartAdd(string DistributorId, long SessionMemberId, string ProductSpuId, string ProductSkuId, int Quantity, string PortfolioId, out int code, out string msg)
        {
            ProductSpuModel spuModel = Factory.ProductSpu().GetModel(null, ProductSpuId);

            if (spuModel != null)
            {
                if (spuModel.Status == EnumList.ProductSpuStatus.架.ToInt() && (spuModel.OnShelfDate != null && spuModel.OnShelfDate <= DateTimeOffset.Now) && (spuModel.OffShelfDate != null && spuModel.OffShelfDate >= DateTimeOffset.Now))
                {
                    ProductSkuModel skuModel = Factory.ProductSku().GetModel(null, ProductSkuId);
                    if (skuModel != null)
                    {
                        int result = 0;
                        //判断购物车中是否存在
                        CartModel cart = null;
                        if (spuModel.Type == EnumList.ProductProcessType.UploadProcess.ToInt())
                        {
                            cart = Factory.Cart().GetModel(null, SessionMemberId, ProductSkuId);
                        }
                        else if (spuModel.Type == EnumList.ProductProcessType.DiyProcess.ToInt() && !string.IsNullOrEmpty(PortfolioId))
                        {
                            cart = Factory.Cart().GetModelByPortfolioId(null, SessionMemberId, PortfolioId);
                        }
                        if (cart != null)
                        {
                            cart.Quantity       = Math.Min(cart.Quantity + 1, 5000);
                            cart.LastUpdateDate = DateTimeOffset.Now;

                            result = Factory.Cart().UpdateInfo(null, cart, cart.CartId);
                        }
                        else
                        {
                            CartModel carModel = new CartModel()
                            {
                                CreationDate       = DateTimeOffset.Now,
                                DistributorId      = DistributorId,
                                IsInvalid          = EnumList.IsStatus.No.ToInt(),
                                IsSelectOrder      = EnumList.IsStatus.Yes.ToInt(),
                                LastUpdateDate     = DateTimeOffset.Now,
                                MemberId           = SessionMemberId,
                                Price              = skuModel.Price,
                                ProductProcessType = spuModel.Type,
                                ProductSkuId       = ProductSkuId,
                                ProductSpuId       = ProductSpuId,
                                Quantity           = Quantity,
                                Weight             = 0,
                                PortfolioId        = PortfolioId
                            };
                            result = Factory.Cart().InsertInfo(null, carModel);
                        }
                        if (result > 0)
                        {
                            code = 1;
                            msg  = "加入成功!";
                        }
                        else
                        {
                            code = 0;
                            msg  = "加入失败!";
                        }
                    }
                    else
                    {
                        code = 0;
                        msg  = "加入失败!";
                    }
                }
                else
                {
                    code = 0;
                    msg  = "商品已下架!";
                }
            }
            else
            {
                code = 0;
                msg  = "商品信息不存在!";
            }
        }