public ActionResult ReDisableShops(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; IShopsService shopsService = ServiceFactory.Create <IShopsService>(); using (TransactionScope scope = TransactionScopeHelper.GetTran()) { foreach (var item in list) { var data = shopsService.GetEntity(item); data.Disabled = false; shopsService.UpdateEntity(data); } scope.Complete(); flag = true; } return(Json(new Result(flag, ResultType.Other), JsonRequestBehavior.AllowGet)); }
public ActionResult GetShopsByID(int ID) { IUsersService usersService = ServiceFactory.Create <IUsersService>(); IShopsService shopsService = ServiceFactory.Create <IShopsService>(); IStoresService storesService = ServiceFactory.Create <IStoresService>(); ShopModel shopModel = new ShopModel(); var shops = shopsService.GetEntity(ID); var users = ServiceHelper.GetUsersService.GetEntity(shops.AdminUserID);// shops.Users; var stores = users.Stores; shopModel.ID = shops.ID; shopModel.ShopName = shops.ShopName; shopModel.AdminUserID = users.ID; shopModel.Disabled = shops.Disabled; shopModel.Domain = shops.Domain; shopModel.DomainName = shops.DomainName; shopModel.ShopVersionID = shops.ShopVersionID == null ? 0 : Convert.ToInt32(shops.ShopVersionID); shopModel.DueDate = shops.DueDate; shopModel.TotalMoney = shops.TotalMoney; shopModel.Remark = shops.Remark; shopModel.ShopType = shops.ShopType; shopModel.SalespersonID = shops.SalespersonID; shopModel.Deposit = shops.Deposit; shopModel.FinalPayment = shops.FinalPayment; shopModel.Province = shops.Province; shopModel.ProvinceCode = shops.ProvinceCode; shopModel.City = shops.City; shopModel.CityCode = shops.CityCode; shopModel.County = shops.County; shopModel.CountyCode = shops.CountyCode; shopModel.AfterSales = shops.AfterSales; shopModel.LogoUrl = shops.LogoUrl; shopModel.AnnualFee = shops.AnnualFee; shopModel.SiteName = shops.SiteName; //shopModel. shopModel.RealName = users.RealName; shopModel.UserName = users.UserName; shopModel.Password = users.Password; shopModel.Idcard = users.Idcard; shopModel.Phone = users.Phone; return(Json(shopModel, JsonRequestBehavior.AllowGet)); }
public JsonResult ResetShopVersion(int shopsID, int shopVersionID) { //如果不是管理员,拒绝调用此方法 if (!CurrentInfo.IsAdministrator) { return(Json(new Result(false, ResultType.Update), JsonRequestBehavior.AllowGet)); } //这边要取出这个版本所有菜单,然后加到用户菜单关系表 和 商家菜单关系表中 IRelationShopVersionModuleService relationShopVersionModuleService = ServiceFactory.Create <IRelationShopVersionModuleService>(); var listModuleID = relationShopVersionModuleService.GetEntities(t => t.ShopVersionID == shopVersionID).Select(t => t.ModuleID).ToList(); var strModuleID = string.Join(",", listModuleID.ToArray()); IShopsService shopsService = ServiceHelper.GetShopsService; IStoresService storesService = ServiceHelper.GetStoresService; var modelStore = storesService.GetTopEntities(1, t => t.ID, t => t.ShopId == shopsID, true).FirstOrDefault(); int shopAdminUserID = shopsService.GetEntity(shopsID).AdminUserID; Role roleModel = ServiceHelper.GetRoleService.GetFirstOrDefault(t => t.StoreID == modelStore.ID); //添加商家和菜单的关系 AddRelationShopModule(shopsID.ToString(), strModuleID); //添加门店和菜单的关系 AddRelationStoreModule(modelStore.ID.ToString(), strModuleID); //添加用户和菜单的关系 AddRelationUsersModule(shopAdminUserID.ToString(), strModuleID); //如果店家有添加角色 if (roleModel != null) { //添加角色和菜单的关系 AddRelationRoleModule(roleModel.ID.ToString(), strModuleID); } //System.Threading.Thread.Sleep(2000); return(Json(new Result(true, ResultType.Update), JsonRequestBehavior.AllowGet)); }
public ActionResult EditShops(ShopModel shopModel) { IUsersService usersService = ServiceFactory.Create <IUsersService>(); IShopsService shopsService = ServiceFactory.Create <IShopsService>(); IStoresService storesService = ServiceFactory.Create <IStoresService>(); if (string.IsNullOrWhiteSpace(shopModel.ProvinceCode) || string.IsNullOrWhiteSpace(shopModel.CityCode) || string.IsNullOrWhiteSpace(shopModel.CountyCode)) { return(Json(new Result(false, "省、市、县必填"), JsonRequestBehavior.AllowGet)); } bool flage = shopsService.Exists(t => t.ID != shopModel.ID && t.ShopName == shopModel.ShopName); if (flage) { return(Json(new Result(false, "已经存在同名商家,请修改"), JsonRequestBehavior.AllowGet)); } //判断是改变了版本 bool versionHasChange = false; bool saveSuccess = false; //用事务来更新一个商家 using (TransactionScope scope = TransactionScopeHelper.GetTran()) { //商家信息 Shops shops = shopsService.GetEntity(shopModel.ID); shops.ShopName = shopModel.ShopName; shops.Domain = shopModel.Domain; shops.DomainName = shopModel.DomainName; //如果版本改变了,则需要重置商家的菜单 if (shops.ShopVersionID != shopModel.ShopVersionID) { versionHasChange = true; } shops.ShopVersionID = shopModel.ShopVersionID; shops.DueDate = shopModel.DueDate; shops.TotalMoney = shopModel.TotalMoney; shops.Remark = shopModel.Remark; shops.Disabled = shopModel.Disabled; shops.ShopType = shopModel.ShopType; shops.SalespersonID = shopModel.SalespersonID; shops.Deposit = shopModel.Deposit; shops.FinalPayment = shopModel.FinalPayment; shops.Province = shopModel.Province; shops.ProvinceCode = shopModel.ProvinceCode; shops.City = shopModel.City; shops.CityCode = shopModel.CityCode; shops.County = shopModel.County; shops.CountyCode = shopModel.CountyCode; shops.AfterSales = shopModel.AfterSales; shops.LogoUrl = shopModel.LogoUrl; shops.AnnualFee = shopModel.AnnualFee; shops.SiteName = shopModel.SiteName; bool update1 = shopsService.UpdateEntity(shops); //商家账号 Users users = usersService.GetEntity(shops.AdminUserID); users.RealName = shopModel.RealName; users.UserName = shopModel.UserName; //如果用户修改了密码,则要重新生成密码规则 if (users.Password != shopModel.Password) { //修改账号PasswordSalt要判断是否是管理员 users.PasswordSalt = Common.TextFilter.GetPasswordSalt(UserIsAdministrator(users));// Common.TextFilter.Substring(Guid.NewGuid().ToString("N"), 10, false); string endPassword = shopModel.Password + users.PasswordSalt; users.Password = Common.SecureHelper.MD5(endPassword); } users.Idcard = shopModel.Idcard; users.Phone = shopModel.Phone; users.Disabled = shopModel.Disabled; bool update2 = usersService.UpdateEntity(users); //如果版本修改了 if (versionHasChange) { ResetShopVersion(shopModel.ID, shopModel.ShopVersionID); } scope.Complete(); saveSuccess = update1 && update2; } return(Json(new Result(saveSuccess, ResultType.Add), JsonRequestBehavior.AllowGet)); //IShopsService shopsService = ServiceFactory.Create<IShopsService>(); //bool flag = shopsService.Exists(t => t.ID != shopModel.ID && string.Equals(t.ShopName, shopModel.ShopName, StringComparison.OrdinalIgnoreCase)); //if (flag) //{ // return Json(new Result(false, "该商家已存在"), JsonRequestBehavior.AllowGet); //} //bool IsSuccess = shopsService.UpdateEntity(shopModel); //return Json(new Result(IsSuccess, ResultType.Update), JsonRequestBehavior.AllowGet); }