public JsonResult GetStoresByID(int ID) { IStoresService storesService = ServiceFactory.Create <IStoresService>(); Stores stores = storesService.GetEntity(ID); var jsonData = new { ID = stores.ID, ShopId = stores.Shops.ID, ShopName = stores.Shops.ShopName, StoreName = stores.StoreName, Phone = stores.Phone, Adress = stores.Adress, BankName = stores.BankName, BankCard = stores.BankCard, IsShare = stores.IsShare, IsShowWeiXin = stores.IsShowWeiXin, IsMainStore = stores.IsMainStore, Disabled = stores.Disabled, LatitudeY = stores.LatitudeY == null ? "" : stores.LatitudeY, LongitudeX = stores.LongitudeX == null ? "" : stores.LongitudeX, StoresImage = stores.StoresImage, ReceiptLogo = stores.ReceiptLogo, PrintRemark = stores.PrintRemark }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }
public ActionResult ReDisableStores(string SID) { string[] strIds = SID.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); List <int> list = new List <int>(); foreach (string id in strIds) { list.Add(int.Parse(id)); } var flag = false; IStoresService storesService = ServiceFactory.Create <IStoresService>(); using (TransactionScope scope = TransactionScopeHelper.GetTran()) { foreach (var item in list) { var data = storesService.GetEntity(item); data.Disabled = false; storesService.UpdateEntity(data); } scope.Complete(); flag = true; } return(Json(new Result(flag, ResultType.Other), JsonRequestBehavior.AllowGet)); }
//public JsonResult GetNoShareStoreID(int ID) //{ // IShareStroreSettingService shareStroreSettingService = ServiceFactory.Create<IShareStroreSettingService>(); // List<int> ids = new List<int>(); // string idStrs = "";//得到共享配置表 // var data = shareStroreSettingService.GetEntities(t => t.CurrentStoreID == ID).FirstOrDefault(); // if (data != null) // { // idStrs = data.NoShowStoreID; // } // List<string> listStr = idStrs.Split(',').ToList(); // foreach (var i in listStr) // { // ids.Add(TypeHelper.ObjectToInt(i)); // } // return Json(ids, JsonRequestBehavior.AllowGet); //} //public JsonResult AddNoShareStore(int ID, string storeIDSs) //{ // IShareStroreSettingService shareStroreSettingService = ServiceFactory.Create<IShareStroreSettingService>(); // var data = shareStroreSettingService.GetEntities(t => t.CurrentStoreID == ID).FirstOrDefault(); // if (data != null) // { // data.NoShowStoreID = storeIDSs; // bool IsSuccess = shareStroreSettingService.UpdateEntity(data); // return Json(new Result() { success = IsSuccess, msg = "设置成功" }, JsonRequestBehavior.AllowGet); // } // else // { // data = new ShareStroreSetting(); // data.NoShowStoreID = storeIDSs; // data.OperateUser = CurrentInfo.CurrentUser.ID; // data.ShopsID = CurrentInfo.CurrentShop.ID; // data.CurrentStoreID = ID; // data.CreateTime = DateTime.Now; // data = shareStroreSettingService.AddEntity(data); // return Json(new Result() { success = data.ID != 0, msg = "设置成功" }, JsonRequestBehavior.AllowGet); // } //} /// <summary> /// 编辑门店简介 /// </summary> /// <returns></returns> public ActionResult EditProfile(int storeID) { IStoresService storesService = ServiceFactory.Create <IStoresService>(); var store = storesService.GetEntity(storeID); ViewBag.Profile = store.Profile; return(View()); }
public JsonResult EditStores(Stores storesModel) { //var stores = strStores.FromJson<Stores>(); IStoresService storesService = ServiceFactory.Create <IStoresService>(); var dbData = storesService.GetEntity(storesModel.ID, false); bool flage = storesService.Exists(t => t.ID != storesModel.ID && t.ShopId == storesModel.ShopId && t.StoreName == storesModel.StoreName); if (flage) { return(Json(new Result(false, "已经存在同名门店请修改"), JsonRequestBehavior.AllowGet)); } //如果用户有传文件,并且文件和数据库中保存的不一样,则需要保存,如果和数据库中一致,无需保存 if (!string.IsNullOrWhiteSpace(storesModel.StoresImage) && storesModel.StoresImage != dbData.StoresImage) { storesModel.StoresImage = FileHelper.Move(storesModel.StoresImage, "/Upload/Reality/" + CurrentInfo.CurrentStore.ID + "/storeImage/"); } if (!string.IsNullOrWhiteSpace(storesModel.ReceiptLogo) && storesModel.ReceiptLogo != dbData.ReceiptLogo) { string newRoute = ServiceHelper.GetCommonService.ThumbnailImage(storesModel.ReceiptLogo, CurrentInfo.CurrentStore.ID, 128, 128, "CUT", "ReceiptLogo"); storesModel.ReceiptLogo = newRoute; } if (storesModel.LongitudeX == "NaN") { storesModel.LongitudeX = "0"; } if (storesModel.LatitudeY == "NaN") { storesModel.LatitudeY = "0"; } dbData.StoreName = storesModel.StoreName; dbData.Phone = storesModel.Phone; dbData.Adress = storesModel.Adress; dbData.LatitudeY = storesModel.LatitudeY; dbData.LongitudeX = storesModel.LongitudeX; dbData.BankName = storesModel.BankName; dbData.BankCard = storesModel.BankCard; dbData.IsMainStore = storesModel.IsMainStore; dbData.IsShare = storesModel.IsShare; dbData.IsShowWeiXin = storesModel.IsShowWeiXin; dbData.StoresImage = storesModel.StoresImage; dbData.PrintRemark = storesModel.PrintRemark; dbData.Disabled = storesModel.Disabled; bool isSuccess = dbData.Update(); return(Json(new Result(isSuccess, ResultType.Update), JsonRequestBehavior.AllowGet)); }
public JsonResult SaveProfile(int storeID, string profile) { bool result = false; IStoresService storesService = ServiceFactory.Create <IStoresService>(); var store = storesService.GetEntity(storeID); if (store.ShopId == CurrentInfo.CurrentShop.ID) { store.Profile = profile; result = storesService.UpdateEntity(store); } return(Json(new Result() { success = result, msg = "" }, JsonRequestBehavior.AllowGet)); }
//public JsonResult GetVirtualShops(int shopID) //{ // var virtualShops = ServiceHelper.GetCommonService.GetVirtualShops(shopID); // return Json(new { success = true, VirtualShops = virtualShops }, JsonRequestBehavior.AllowGet); //} //门店绑定公众号和解绑公众号操作 public JsonResult ToggleVirtualShops(int storeID, int?virtualShopsID) { IStoresService storesService = ServiceFactory.Create <IStoresService>(); bool result = false; var storeModel = storesService.GetEntity(storeID); if (storeModel != null) { if (virtualShopsID != null) { storeModel.VirtualShopsID = virtualShopsID; } else { storeModel.VirtualShopsID = null; } result = storesService.UpdateEntity(storeModel); } //设置成功 return(Json(new Result(result, result ? (virtualShopsID != null ? "绑定成功" : "解绑成功") : "操作失败"), JsonRequestBehavior.AllowGet)); }
protected override void OnAuthorization(AuthorizationContext filterContext) { //如果是单机版,需要检查数据是否合法 //if (CurrentInfo.Settings.IsSingleVersion) //{ // //如果是单机版登录,判断门店数量是否正确,而且不能使用管理账号登录,管理员账号有另一个路口 // var falge = SingleVersion.Instance.CheckVersion(CurrentInfo.Settings.ShopPhone); // //如果验证未通过,则直接返回首页 // if (falge == false) // { // ClearLoginInfo(); // filterContext.Result = new RedirectResult("/Admin/Home/Login"); // } //} //测试环境自动登录 //if (!CurrentInfo.IsLogin && QiCeHelper.IsTest(Request.Url.Host.ToString())) //{ // DebugLogin(); //} //如果需要身份验证 if (NeedAuthorization(filterContext)) { //string requestUrl = Server.UrlEncode(Session["SiteName"].ToString().PathAndQuery); string area = filterContext.RouteData.DataTokens["area"].ToString().ToLower(); string controller = filterContext.RouteData.Values["controller"].ToString().ToLower(); string action = filterContext.RouteData.Values["action"].ToString().ToLower(); if (CurrentInfo.IsLogin) { #region 人为BUG代码 //客户要求来点BUG //if (CurrentInfo.CurrentUser.UserName == "qcgjsj") //{ // Random rd = new Random(DateTime.Now.Millisecond); // int tempInt = rd.Next(1, 11); // Thread.Sleep(tempInt * 500); // if (tempInt <= 2) // { // throw new Exception("发生未知错误X29I3P5K6"); // } //} #endregion CurrentInfo.SetCurrentModule(area, controller, action); //ViewBag.InitInfo = CurrentInfo; //保存登录session SaveLoginSession(); } else if (System.Web.HttpContext.Current.Session["LastOperateTime"] != null && (DateTime.Now - Convert.ToDateTime(System.Web.HttpContext.Current.Session["LastOperateTime"])).Minutes < 480)//如果是网站重启了,且用户没有超过8小时没有操作 { int userID = Convert.ToInt32(System.Web.HttpContext.Current.Session["Jeasu_UserID"]); int storeID = Convert.ToInt32(System.Web.HttpContext.Current.Session["Jeasu_StoreID"]); IUsersService userService = ServiceFactory.Create <IUsersService>(); var su = userService.GetEntity(userID); //当前门店 IStoresService storesService = ServiceFactory.Create <IStoresService>(); var cs = storesService.GetEntity(storeID); //如果为空说明已经失效,重新登录 if (su == null && cs == null) { filterContext.Result = new RedirectResult(string.Format("/{0}/Home/Index", JeasuHelper.SubProjectName)); } else { InitUserInfo(su, cs); CurrentInfo.SetCurrentModule(area, controller, action); //保存登录session SaveLoginSession(); } } else { if (WebHelper.IsAjax()) { Result data = new Result { success = false, msg = "登录超时请重新登录" }; filterContext.Result = Json(data, JsonRequestBehavior.AllowGet); filterContext.HttpContext.Response.StatusCode = 200; } else { filterContext.Result = new RedirectResult(string.Format("/{0}/Home/Login", JeasuHelper.SubProjectName)); } } } base.OnAuthorization(filterContext); }
public JsonResult AddUser(Entity.Users user, int?shopType) { //如果是测试账号则默认门店设置在45下面 if (user.IsIntention == true) { if (shopType == 1) { user.DefaultStoreID = 45; } else if (shopType == 2) { user.DefaultStoreID = 101; } else { return(Json(new Result(false, "该版本还未开通,无法添加"), JsonRequestBehavior.AllowGet)); } } IService.IUsersService usersService = ServiceFactory.Create <IUsersService>(); //是否需要账号 if (user.NeedAccount) { if (string.IsNullOrWhiteSpace(user.UserName) || string.IsNullOrWhiteSpace(user.Password)) { return(Json(new Result(false, "用户名和密码不能为空,若无需账号请选择‘不需要登录账号’"), JsonRequestBehavior.AllowGet)); } bool flage = usersService.Exists(t => t.UserName == user.UserName); if (flage) { return(Json(new Result(false, "已经存在同名用户,请更换"), JsonRequestBehavior.AllowGet)); } //添加账号PasswordSalt随机 user.PasswordSalt = Common.TextFilter.GetPasswordSalt();//Common.TextFilter.Substring(Guid.NewGuid().ToString("N"), 10, false); string endPassword = user.Password + user.PasswordSalt; //计算密码 user.Password = Common.SecureHelper.MD5(endPassword); } //user.DefaultStoreID = CurrentInfo.CurrentStore.ID; IStoresService storesService = ServiceFactory.Create <IStoresService>(); var storesModel = storesService.GetEntity(user.DefaultStoreID.ToString().ToInt32()); user.ShopsID = storesModel.ShopId; if (!string.IsNullOrWhiteSpace(user.Photo)) { //生成缩略图 并删除原图 string fileFullName = FileHelper.Move(user.Photo, "/Upload/Reality/" + CurrentInfo.CurrentStore.ID + "/UserImg/"); string extension = System.IO.Path.GetExtension(fileFullName); //缩略图路径 string thumbnailPath = ImgHelper.GetThumbnailPathByWidth(fileFullName, 60); //生成缩略图 ImgHelper.MakeThumbnail( System.Web.HttpContext.Current.Server.MapPath(fileFullName), System.Web.HttpContext.Current.Server.MapPath(thumbnailPath), 60, 60, "W", extension ); FileHelper.DeleteFile(System.Web.HttpContext.Current.Server.MapPath(fileFullName)); user.Photo = thumbnailPath; //user.Photo = FileHelper.Move(user.Photo, "/Upload/Reality/" + CurrentInfo.CurrentStore.ID + "/UserImg/"); } if (!string.IsNullOrWhiteSpace(user.IdcardPhoto)) { user.IdcardPhoto = FileHelper.Move(user.IdcardPhoto, "/Upload/Reality/" + CurrentInfo.CurrentStore.ID + "/UserImg/"); } user.CreateUserID = CurrentInfo.CurrentUser.ID; user.CreateTime = DateTime.Now; user.Disabled = false; bool success = false; using (TransactionScope transactionScope = TransactionScopeHelper.GetTran()) { var data = usersService.AddEntity(user); //if (data.WorkTypeID != null) //{ // AdddRelationUserWorkType(data.ID, Convert.ToInt32(data.WorkTypeID)); //} transactionScope.Complete(); success = data != null; } return(Json(new Result(success, ResultType.Add), JsonRequestBehavior.AllowGet)); }