/// <summary>
        /// 更新门店信息
        /// </summary>
        /// <param name="shopInfo">门店信息</param>
        /// <returns>操作结果</returns>
        public Result UpdateShopInfo(Shop shopInfo)
        {
            Result result = new Result()
            {
                Status  = true,
                Message = "更新门店成功"
            };

            try
            {
                bool cannext = false;

                ShopInfo info = shopInfo.Copy <ShopInfo>();
                if (info == null)
                {
                    throw new ArgumentNullException("更新门店,参数不能为空");
                }

                IShopCache shopservice = ServiceObjectContainer.Get <IShopCache>();
                IDishCache dishservice = ServiceObjectContainer.Get <IDishCache>();

                info.UpdateDate = DateTime.Now;
                //更新门店信息
                cannext = DBConnectionManager.Instance.Writer.Update(new ShopUpdateSpefication(info).Satifasy());
                //门店信息更新成功,更新关联食物的门店名称
                if (cannext)
                {
                    cannext = false;
                    cannext = DBConnectionManager.Instance.Writer.Update(new DishShopNameUpdateSpefication(info.ShopId, info.ShopName).Satifasy());
                }
                result.Status = cannext;

                if (!cannext)
                {
                    DBConnectionManager.Instance.Writer.Rollback();
                    result.Message = "更新门店失败,请确认参数合法";
                }
                else
                {
                    DBConnectionManager.Instance.Writer.Commit();
                    //同步缓存
                    shopservice.SaveInfo(info);
                    dishservice.UpdateDishInfoByChangeShopName(shopInfo.ShopId, shopInfo.ShopName);
                }
            }
            catch (Exception ex)
            {
                DBConnectionManager.Instance.Writer.Rollback();
                result.Status  = false;
                result.Message = "更新门店出错:" + ex.Message;
                LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:UpdateShopInfo() .ShopService"), LogType.ErrorLog);
            }

            return(result);
        }
        /// <summary>
        /// 创建门店信息
        /// </summary>
        /// <param name="shopInfo"></param>
        /// <returns></returns>
        public Result CreatShopInfo(Shop shopInfo)
        {
            Result result = new Result()
            {
                Status  = true,
                Message = "创建门店成功"
            };

            try
            {
                ShopInfo info = shopInfo.Copy <ShopInfo>();
                if (info == null)
                {
                    throw new ArgumentNullException("创建门店,参数不能为空");
                }

                IShopCache shopservice = ServiceObjectContainer.Get <IShopCache>();

                info.UpdateDate = DateTime.Now;
                result.Status   = DBConnectionManager.Instance.Writer.Insert(new ShopAddSpefication(info).Satifasy());

                if (result.Status)
                {
                    DBConnectionManager.Instance.Writer.Commit();
                    //同步缓存
                    shopservice.SaveInfo(info);
                }
                else
                {
                    DBConnectionManager.Instance.Writer.Rollback();
                    result.Message = "创建门店失败,请确认参数合法";
                }
            }
            catch (Exception ex)
            {
                DBConnectionManager.Instance.Writer.Rollback();
                result.Status  = false;
                result.Message = "创建门店出错:" + ex.Message;
                LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:CreatShopInfo() .ShopService"), LogType.ErrorLog);
            }

            return(result);
        }
        /// <summary>
        /// 根据门店编号删除门店信息 (禁用门店信息)
        /// </summary>
        /// <param name="shopId">门店编号</param>
        /// <returns>操作结果</returns>
        public Result RemoveShopInfoById(int shopId)
        {
            Result result = new Result()
            {
                Status  = true,
                Message = "删除门店成功"
            };

            try
            {
                if (shopId == 0)
                {
                    throw new ArgumentException("查询门店信息,参数非法");
                }
                IShopCache shopservice = ServiceObjectContainer.Get <IShopCache>();

                bool execstatus = DBConnectionManager.Instance.Writer.Update(new ShopDeleteSpefication(shopId).Satifasy());

                if (!execstatus)
                {
                    result.Status  = false;
                    result.Message = "删除门店操作失败,请检查参数数据";
                    DBConnectionManager.Instance.Writer.Rollback();
                }
                else
                {
                    //提交
                    DBConnectionManager.Instance.Writer.Commit();
                    //同步缓存
                    shopservice.SetShopInfoEnable(shopId, false);
                }
            }
            catch (Exception ex)
            {
                DBConnectionManager.Instance.Writer.Rollback();
                result.Status  = false;
                result.Message = "获取门店信息出错:" + ex.Message;
                LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:RemoveShopInfoById() .ShopService"), LogType.ErrorLog);
            }

            return(result);
        }
        /// <summary>
        /// 根据门店编号获取信息
        /// </summary>
        /// <param name="shopId">门店编号</param>
        /// <returns>操作结果</returns>
        public Result <Shop> GetShopInfoById(int shopId)
        {
            Result <Shop> result = new Result <Shop>()
            {
                Status  = false,
                Message = "没有获取到对应信息"
            };

            try
            {
                if (shopId == 0)
                {
                    throw new ArgumentException("查询门店信息,参数非法");
                }
                IShopCache shopservice = ServiceObjectContainer.Get <IShopCache>();

                ShopInfo shopcache = shopservice.GetshopInfoByShopId(shopId);

                if (shopcache != null)
                {
                    result.Data   = shopcache.Copy <Shop>();
                    result.Status = true;
                }
                else
                {
                    result.Data    = null;
                    result.Status  = false;
                    result.Message = "没有获取到对应信息";
                }
            }
            catch (Exception ex)
            {
                result.Data    = null;
                result.Status  = false;
                result.Message = "获取门店信息出错:" + ex.Message;
                LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:GetShopInfoById() .ShopService"), LogType.ErrorLog);
            }

            return(result);
        }
        /// <summary>
        /// 分享单品食物信息
        /// </summary>
        /// <param name="share"></param>
        /// <returns></returns>
        public Result ShareDishInfo(DishShare share)
        {
            Result result = new Result()
            {
                Status     = true,
                StatusCode = "SSD000",
                Message    = "分享单品食物成功"
            };

            try
            {
                //新增一条单品记录
                bool        cannext                 = false;
                DishInfo    dishinfo                = share.DishInfo.Copy <DishInfo>();
                ShopInfo    updateshop              = share.ShopInfo.Copy <ShopInfo>();
                RecipesInfo updaterecipes           = share.RecipesInfo.Copy <RecipesInfo>();
                IList <RelationShareInfo> shareinfo = null;
                if (dishinfo == null)
                {
                    throw new ArgumentNullException("创建食物,单品食物参数不能为空");
                }
                if (updateshop == null)
                {
                    throw new ArgumentNullException("创建食物,门店信息参数不能为空");
                }
                if (updaterecipes == null)
                {
                    throw new ArgumentNullException("创建食物,食谱参数不能为空");
                }

                cannext = DBConnectionManager.Instance.Writer.Insert(new DishAddSpefication(dishinfo).Satifasy());

                //新增一条单品与食谱关系记录
                if (cannext)
                {
                    cannext   = false;
                    shareinfo = new List <RelationShareInfo>();
                    RelationShareInfo sharerelation = new RelationShareInfo()
                    {
                        DishId     = dishinfo.DIshId,
                        Phone      = share.RecipesInfo.Phone,
                        RecipesId  = share.RecipesInfo.RecipesId,
                        UpdateDate = DateTime.Now
                    };
                    shareinfo.Add(sharerelation);
                    cannext = DBConnectionManager.Instance.Writer.Insert(new RelationShareAddSpefication(shareinfo).Satifasy());
                }
                //更新门店信息(更新操作时间)
                if (cannext)
                {
                    updateshop.UpdateDate = DateTime.Now;
                    cannext = DBConnectionManager.Instance.Writer.Update(new ShopUpdateSpefication(updateshop).Satifasy());
                }
                //更新食谱信息(更新操作时间)
                if (cannext)
                {
                    updaterecipes.UpdateDate = DateTime.Now;
                    cannext = DBConnectionManager.Instance.Writer.Update(new RecipesUpdateSpefication(updaterecipes).Satifasy());
                }

                if (!cannext)
                {
                    DBConnectionManager.Instance.Writer.Rollback();
                    result.Status  = false;
                    result.Message = "分享单品食物失败,请确保请求数据合法";
                }
                else
                {
                    DBConnectionManager.Instance.Writer.Commit();

                    //更新缓存
                    IRelationShareInfoCache shareservice = ServiceObjectContainer.Get <IRelationShareInfoCache>();
                    foreach (RelationShareInfo item in shareinfo)
                    {
                        shareservice.SaveInfo(item);
                    }


                    IDishCache dishservice = ServiceObjectContainer.Get <IDishCache>();
                    dishservice.SaveInfo(dishinfo);

                    IShopCache shopservice = ServiceObjectContainer.Get <IShopCache>();
                    shopservice.SaveInfo(updateshop);

                    IRecipesCache recipesservice = ServiceObjectContainer.Get <IRecipesCache>();
                    recipesservice.SaveInfo(updaterecipes);
                }
            }
            catch (Exception ex)
            {
                DBConnectionManager.Instance.Writer.Rollback();
                result.Status     = false;
                result.Message    = "分享单品食物失败:" + ex.Message;
                result.StatusCode = "SSD001";
                LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:ShareDishInfo() .DishService"), LogType.ErrorLog);
            }
            return(result);
        }