/// <summary>
        /// 修改商品属性状态
        /// </summary>
        /// <param name="skuId"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public bool ModifySkuStatus(GoodsSkuInfo skuEntity, GoodsSkuInfo checkEntity, GoodsInfo infoEntity, GoodsSkuInout inoutEntity)
        {
            if (skuEntity == null)
            {
                return(false);
            }

            using (var db = DbService.GetInstance())
            {
                try
                {
                    db.BeginTran();
                    var result = db.Update <GoodsSkuInfo>(skuEntity);
                    if (checkEntity != null && checkEntity.Skuid > 0)
                    {
                        checkEntity.IsDefault = true;
                        db.Update <GoodsSkuInfo>(checkEntity);
                    }
                    if (result)
                    {
                        RealTimeCacheHelper.IncreaseAreaVersion("Goodsid", skuEntity.Goodsid);
                        db.Insert(inoutEntity, true);
                        db.Update <GoodsInfo>(new { stock = infoEntity.Stock }, w => w.Goodsid == infoEntity.Goodsid);

                        db.CommitTran();
                        return(true);
                    }
                    db.RollbackTran();
                    return(false);
                }
                catch
                {
                    db.RollbackTran();
                    return(false);
                }
            }
        }
        /// <summary>
        /// 设置商品属性
        /// </summary>
        public bool SetGoodsSkuInfo(GoodsInfo entity, List <GoodsSkuInfo> skuEntitys, long userId)
        {
            var errorCount = 0;
            List <GoodsSkuInout> inoutEntitys = new List <GoodsSkuInout>();
            var result = goodsInfoRepository.UpdateCache(entity);

            if (result)
            {
                goodsSkuInfoRepository.UpdateCacheByParame("Goodsid", entity.Goodsid);
                foreach (var skuEntity in skuEntitys)
                {
                    GoodsSkuInout inoutEntity = GoodsSkuInout.New();
                    inoutEntity.Goodsid     = entity.Goodsid;
                    inoutEntity.DateCreated = DateTime.Now;
                    GoodsSkuInfo goodsSkuInfo = goodsSkuInfoRepository.GetByCache(w => w.Skuid == skuEntity.Skuid, skuEntity.Skuid);
                    if (goodsSkuInfo != null && goodsSkuInfo.Skuid > 0)
                    {
                        if (goodsSkuInfo.Stock != skuEntity.Stock)
                        {
                            inoutEntity.Skuid       = skuEntity.Skuid;
                            inoutEntity.IsOut       = goodsSkuInfo.Stock - skuEntity.Stock > 0 ? true : false;
                            inoutEntity.InoutNumber = Math.Abs(goodsSkuInfo.Stock - skuEntity.Stock);
                            var formatOut = inoutEntity.IsOut ? "出库" + inoutEntity.InoutNumber : "入库" + inoutEntity.InoutNumber;
                            inoutEntity.Operation = string.Format("管理用户:{0}、编辑商品属性:“{1}”、规格:“{2}”、{3} 时间:{4}", userId, entity.GoodsName, skuEntity.SkuName, formatOut, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                            inoutEntitys.Add(inoutEntity);

                            result = goodsSkuInfoRepository.UpdateByEntity(skuEntity);
                            if (result)
                            {
                                if (!goodsSkuInoutRepository.AddByCache(inoutEntitys))
                                {
                                    errorCount++;
                                }
                                else
                                {
                                    if (!inoutEntity.IsOut)
                                    {
                                        entity.Stock += inoutEntity.InoutNumber;
                                    }
                                    else
                                    {
                                        if (entity.Stock - inoutEntity.InoutNumber < 0)
                                        {
                                            entity.Stock = 0;
                                        }
                                        else
                                        {
                                            entity.Stock -= inoutEntity.InoutNumber;
                                        }
                                    }

                                    if (!goodsInfoRepository.UpdateCache(entity, new { stock = entity.Stock }, w => w.Goodsid == entity.Goodsid))
                                    {
                                        errorCount++;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (!goodsSkuInfoRepository.UpdateByEntity(skuEntity))
                            {
                                errorCount++;
                            }
                        }
                    }
                    else
                    {
                        object objId = goodsSkuInfoRepository.AddByCache(skuEntity, true);
                        var    skuId = 0;
                        int.TryParse(objId.ToString(), out skuId);
                        inoutEntity.Skuid       = skuId;
                        inoutEntity.IsOut       = false;
                        inoutEntity.InoutNumber = skuEntity.Stock;
                        inoutEntity.Operation   = string.Format("管理用户:{0}、新增商品属性:“{1}”、规格:“{2}”、入库{3}  时间:{4}", userId, entity.GoodsName, skuEntity.SkuName, inoutEntity.InoutNumber, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        inoutEntitys.Add(inoutEntity);
                        if (!goodsSkuInoutRepository.AddByCache(inoutEntitys))
                        {
                            errorCount++;
                        }
                        else
                        {
                            entity.Stock += skuEntity.Stock;
                            if (!goodsInfoRepository.UpdateCache(entity, new { stock = entity.Stock }, w => w.Goodsid == entity.Goodsid))
                            {
                                errorCount++;
                            }
                        }
                    }
                }
            }
            return(errorCount == 0 ? true : false);
        }