/// <summary> /// 更新门店信息、管理员密码 /// </summary> /// <param name="shopBranch"></param> public static void UpdateShopBranch(ShopBranch shopBranch) { if (isRepeatBranchName(shopBranch.ShopId, shopBranch.Id, shopBranch.ShopBranchName)) { throw new HimallException("门店名称不能重复!"); } AutoMapper.Mapper.CreateMap <ShopBranch, ShopBranchInfo>(); var shopBranchInfo = AutoMapper.Mapper.Map <ShopBranch, ShopBranchInfo>(shopBranch); shopBranchInfo.AddressPath = RegionApplication.GetRegionPath(shopBranchInfo.AddressId); //默认在结尾增加分隔符 shopBranchInfo.AddressPath = shopBranchInfo.AddressPath + CommonConst.ADDRESS_PATH_SPLIT; Service.UpdateShopBranch(shopBranchInfo); if (!string.IsNullOrEmpty(shopBranch.PasswordOne)) { if (shopBranch.PasswordOne != shopBranch.PasswordTwo) { throw new MessageException("两次密码输入不一致"); } //设置门店管理密码 SetShopBranchManagerPassword(shopBranchInfo.Id, shopBranch.PasswordOne); } }
/// <summary> /// 根据分店id获取分店信息 /// </summary> /// <param name="ids"></param> /// <returns></returns> public static List <ShopBranch> GetShopBranchs(IEnumerable <long> ids) { var shopBranchs = _shopBranchService.GetShopBranchs(ids).Map <List <ShopBranch> >(); //补充地址详细信息,地址库采用了缓存,循环取 foreach (var b in shopBranchs) { b.AddressFullName = RegionApplication.GetFullName(b.AddressId); b.RegionIdPath = RegionApplication.GetRegionPath(b.AddressId); } return(shopBranchs); }
/// <summary> /// 更新门店信息、管理员密码 /// </summary> /// <param name="shopBranch"></param> public static void UpdateShopBranch(ShopBranch shopBranch) { if (isRepeatBranchName(shopBranch.ShopId, shopBranch.Id, shopBranch.ShopBranchName)) { throw new HimallException("门店名称不能重复!"); } Mapper.CreateMap <ShopBranch, ShopBranchInfo>(); ShopBranchInfo info = Mapper.Map <ShopBranch, ShopBranchInfo>(shopBranch); info.AddressPath = RegionApplication.GetRegionPath(info.AddressId); info.AddressPath = info.AddressPath + ","; _shopBranchService.UpdateShopBranch(info); if (!(string.IsNullOrWhiteSpace(shopBranch.PasswordOne) || string.IsNullOrWhiteSpace(shopBranch.PasswordTwo))) { string salt = GetSalt(); string passwrodEncode = GetPasswrodEncode(shopBranch.PasswordOne, salt); _shopBranchService.UpdateShopBranchManagerPwd(shopBranch.Id, shopBranch.UserName, passwrodEncode, salt); } }
/// <summary> /// 更新门店信息、管理员密码 /// </summary> /// <param name="shopBranch"></param> public static void UpdateShopBranch(ShopBranch shopBranch) { if (isRepeatBranchName(shopBranch.ShopId, shopBranch.Id, shopBranch.ShopBranchName)) { throw new HimallException("门店名称不能重复!"); } AutoMapper.Mapper.CreateMap <ShopBranch, ShopBranchInfo>(); var shopBranchInfo = AutoMapper.Mapper.Map <ShopBranch, ShopBranchInfo>(shopBranch); shopBranchInfo.AddressPath = RegionApplication.GetRegionPath(shopBranchInfo.AddressId); //默认在结尾增加分隔符 shopBranchInfo.AddressPath = shopBranchInfo.AddressPath + CommonConst.ADDRESS_PATH_SPLIT; _shopBranchService.UpdateShopBranch(shopBranchInfo); if (!string.IsNullOrWhiteSpace(shopBranch.PasswordOne) && !string.IsNullOrWhiteSpace(shopBranch.PasswordTwo)) { //编辑时可以不输入密码 var salt = GetSalt(); //取salt var encodePwd = GetPasswrodEncode(shopBranch.PasswordOne, salt); _shopBranchService.UpdateShopBranchManagerPwd(shopBranch.Id, shopBranch.UserName, encodePwd, salt); } }
/// <summary> /// 新增门店 /// </summary> public static void AddShopBranch(ShopBranch shopBranch, out long shopBranchId) { if (isRepeatBranchName(shopBranch.ShopId, shopBranch.Id, shopBranch.ShopBranchName)) { throw new HimallException("此门店名称已存在,请设置其他名称!"); } var branchManangerInfo = Service.GetShopBranchManagersByName(shopBranch.UserName); if (branchManangerInfo != null) { throw new HimallException("此门店管理员账号已存在,请设置其他名称!"); } if (ManagerApplication.CheckUserNameExist(shopBranch.UserName)) { throw new HimallException("此门店管理员账号已存在,请设置其他名称!"); } AutoMapper.Mapper.CreateMap <ShopBranch, Entities.ShopBranchInfo>(); var shopBranchInfo = AutoMapper.Mapper.Map <ShopBranch, Entities.ShopBranchInfo>(shopBranch); shopBranchInfo.AddressPath = RegionApplication.GetRegionPath(shopBranchInfo.AddressId); //默认在结尾增加分隔符 shopBranchInfo.AddressPath = shopBranchInfo.AddressPath + CommonConst.ADDRESS_PATH_SPLIT; Service.AddShopBranch(shopBranchInfo); shopBranchId = shopBranchInfo.Id; var salt = GetSalt(); var shopBranchManagerInfo = new Entities.ShopBranchManagerInfo { CreateDate = DateTime.Now, UserName = shopBranch.UserName, ShopBranchId = shopBranchInfo.Id, PasswordSalt = salt, Password = GetPasswrodEncode(shopBranch.PasswordOne, salt) }; Service.AddShopBranchManagers(shopBranchManagerInfo); shopBranch.Id = shopBranchInfo.Id; }