/// <summary>
        /// 获取一个商家的第一家门店
        /// </summary>
        /// <param name="shopID">商家</param>
        /// <returns></returns>
        public Stores GetShopFirstStore(int shopID)
        {
            Stores         firstStore = null;
            IStoresService service    = ServiceFactory.Create <IStoresService>();

            if (shopID > 0)
            {
                firstStore = service.GetEntities(o => o.ShopId == shopID && o.VirtualShopsID == null).OrderBy(t => t.ID).FirstOrDefault();
            }
            else
            {
                firstStore = service.GetEntities(o => o.VirtualShopsID == shopID).OrderBy(t => t.ID).FirstOrDefault();
            }
            return(firstStore);
        }
        public ActionResult GetRolesByStoreID(int?shopType)
        {
            IStoresService storesService = ServiceFactory.Create <IStoresService>();
            IRoleService   roleService   = ServiceFactory.Create <IRoleService>();

            List <KeyValuePair <Stores, List <Role> > > StoresRoleKeyValueList = new List <KeyValuePair <Stores, List <Role> > >();

            //如果是商家管理员则显示所有门店的角色
            if (CurrentInfo.IsShopAdmin)
            {
                int ShopID = CurrentInfo.CurrentShop.ID;
                //这边是销售的测试账号开户,给客户分配角色所用的商家ID
                if (shopType != null)
                {
                    if (shopType == (int)ShopTypeEnum.汽车美容)
                    {
                        ShopID = 4;
                    }
                    else if (shopType == (int)ShopTypeEnum.美容美发)
                    {
                        ShopID = 66;
                    }
                }

                var storesList = storesService.GetEntities(t => t.ShopId == ShopID && t.Disabled == false);
                foreach (var item in storesList)
                {
                    var data = roleService.GetEntities(t => t.StoreID == item.ID && t.Disabled == false).ToList();
                    if (data.Count > 0)
                    {
                        KeyValuePair <Stores, List <Role> > singleKeyValue = new KeyValuePair <Stores, List <Role> >(item, data);
                        StoresRoleKeyValueList.Add(singleKeyValue);
                    }
                }
            }
            else
            {
                int StoreID = CurrentInfo.CurrentStore.ID;

                //这边是销售的测试账号开户,给客户分配角色所用的门店ID
                if (shopType != null)
                {
                    if (shopType == (int)ShopTypeEnum.汽车美容)
                    {
                        StoreID = 45;
                    }
                    else if (shopType == (int)ShopTypeEnum.美容美发)
                    {
                        StoreID = 101;
                    }
                }

                var data = roleService.GetEntities(t => t.StoreID == StoreID && t.Disabled == false).ToList();
                KeyValuePair <Stores, List <Role> > singleKeyValue = new KeyValuePair <Stores, List <Role> >(CurrentInfo.CurrentStore, data);
                StoresRoleKeyValueList.Add(singleKeyValue);
            }

            return(View(StoresRoleKeyValueList));
        }
Beispiel #3
0
        /// <summary>
        /// 共享不可见门店
        /// </summary>
        /// <returns></returns>
        public ActionResult EditNoShareStore(int storeID)
        {
            IStoresService storesService = ServiceFactory.Create <IStoresService>();
            int            shopID        = CurrentInfo.CurrentShop.ID;
            var            storeIDList   = storesService.GetEntities(t => t.ShopId == shopID).ToList();

            ViewBag.CurrentStoreID = CurrentInfo.CurrentStore.ID;
            return(View(storeIDList));
        }
Beispiel #4
0
        public ActionResult CusRoleManage(RoleSearchModel searchModel)
        {
            var          expr        = BuildSearchCriteria(searchModel);
            IRoleService roleService = ServiceFactory.Create <IRoleService>();
            var          roles       = roleService.GetEntitiesByPage(searchModel.PageIndex, 10, expr, false, t => t.ID);

            ViewBag.SearchModel = searchModel;

            IStoresService storesService   = ServiceFactory.Create <IStoresService>();
            List <Stores>  allStores       = storesService.GetEntities(t => t.ShopId == CurrentInfo.CurrentShop.ID && t.Disabled == false).ToList();
            SelectList     allStoresSelect = new SelectList(allStores, "ID", "StoreName", CurrentInfo.CurrentStore.ID);

            ViewData["allStoresSelect"] = allStoresSelect;
            ViewData["showStores"]      = CurrentInfo.IsShopAdmin;
            return(View(roles));
        }
Beispiel #5
0
        public ActionResult AddTestAccount()
        {
            InitInfo.Instance.SetCurrentModule("Admin", "User", "AddTestAccount");
            Entity.Users editUser = null;
            //有ID说明是编辑状态
            if (Request["ID"] != null && !string.IsNullOrWhiteSpace(Request["ID"].ToString()))
            {
                IUsersService usersService = ServiceFactory.Create <IUsersService>();
                editUser = usersService.GetEntity(Convert.ToInt32(Request["ID"]));
                //如果不是管理员,也不是内部销售,也不是本店的员工,则无权限修改
                if (!CurrentInfo.IsAdministrator && CurrentInfo.CurrentUser.Remark != "B4内部销售" && editUser.DefaultStoreID != CurrentInfo.CurrentStore.ID)
                {
                    return(RedirectToAction("Error403", "Home", new { area = "Admin" }));
                }
            }
            //editUser为null的时候说明是添加
            int?shopID  = editUser == null ? CurrentInfo.CurrentShop.ID : editUser.ShopsID;
            int?storeID = editUser == null ? CurrentInfo.CurrentStore.ID : editUser.DefaultStoreID;

            IStoresService storesService   = ServiceFactory.Create <IStoresService>();
            List <Stores>  allStores       = storesService.GetEntities(t => t.ShopId == shopID && t.Disabled == false).ToList(); // CurrentInfo.CurrentShop.ID
            SelectList     allStoresSelect = new SelectList(allStores, "ID", "StoreName", storeID);                              // CurrentInfo.CurrentStore.ID

            ViewData["allStoresSelect"] = allStoresSelect;
            //在添加测试账号的时候则默认不显示,只允许添加到测试门店里面
            ViewData["showStores"] = false;
            ViewBag.IsIntention    = true;

            //账号版本,测试账号开户用得到,其他无用
            List <SelectListItem> listShopType = new List <SelectListItem>();

            foreach (var item in Enum.GetValues(typeof(ShopTypeEnum)))
            {
                listShopType.Add(new SelectListItem
                {
                    Text  = item.ToString(),
                    Value = ((int)item).ToString()
                });
            }
            //InventoryDetailsType.Insert(0, new SelectListItem { Text = "所有类别", Value = "0" });
            //InventoryDetailsType[6].Selected = true;
            ViewData["ListShopType"] = new SelectList(listShopType, "Value", "Text", "1");

            ViewBag.BackUrl = "/Admin/IntentionUser/Index";

            return(View("ShowAddUser"));
        }
Beispiel #6
0
        public ActionResult ShowAddUser()
        {
            InitInfo.Instance.SetCurrentModule("Admin", "User", "Index");
            Entity.Users editUser = null;
            //有ID说明是编辑状态
            if (Request["ID"] != null)
            {
                IUsersService usersService = ServiceFactory.Create <IUsersService>();
                editUser = usersService.GetEntity(Convert.ToInt32(Request["ID"]));
                //如果不是管理员,并且不是店铺内部人员,禁止修改改员工信息
                if (!CurrentInfo.IsAdministrator && CurrentInfo.CurrentUser.Remark != "B4内部销售" && editUser.Stores.ShopId != CurrentInfo.CurrentShop.ID)
                {
                    return(RedirectToAction("Error403", "Home", new { area = "Admin" }));
                }
            }

            //editUser为null的时候说明是添加
            int?shopID  = editUser == null ? CurrentInfo.CurrentShop.ID : editUser.ShopsID;
            int?storeID = editUser == null ? CurrentInfo.CurrentStore.ID : editUser.DefaultStoreID;

            IStoresService storesService   = ServiceFactory.Create <IStoresService>();
            List <Stores>  allStores       = storesService.GetEntities(t => t.ShopId == shopID && t.Disabled == false).ToList(); // CurrentInfo.CurrentShop.ID
            SelectList     allStoresSelect = new SelectList(allStores, "ID", "StoreName", storeID);                              // CurrentInfo.CurrentStore.ID

            ViewData["allStoresSelect"] = allStoresSelect;

            //只有管理员才能给所有店铺添加人员
            ViewData["showStores"] = CurrentInfo.IsShopAdmin;
            ViewBag.IsIntention    = false;

            //账号版本,测试账号开户用得到,其他无用
            List <SelectListItem> listShopType = new List <SelectListItem>();

            foreach (var item in Enum.GetValues(typeof(ShopTypeEnum)))
            {
                listShopType.Add(new SelectListItem
                {
                    Text  = item.ToString(),
                    Value = ((int)item).ToString()
                });
            }
            //InventoryDetailsType.Insert(0, new SelectListItem { Text = "所有类别", Value = "0" });
            //InventoryDetailsType[6].Selected = true;
            ViewData["ListShopType"] = new SelectList(listShopType, "Value", "Text", "1");

            return(View());
        }
        protected void InitUserInfo(Users currentUser, Stores switchCurrentSore = null)
        {
            InitInfo initInfo = CurrentInfo;

            //当前用户
            //IUsersService usersService = ServiceFactory.Create<IUsersService>();
            //var currentUser = usersService.GetEntity(1);
            initInfo.CurrentUser = currentUser;

            //当前用户的所属门店
            IStoresService storesService = ServiceFactory.Create <IStoresService>();
            var            currentSore   = switchCurrentSore == null ? currentUser.Stores : switchCurrentSore;//soresService.GetEntity(1);

            initInfo.CurrentStore = currentSore;

            //当前商家
            initInfo.CurrentShop = currentUser.Stores.Shops;

            //该用户在当前门店下的所有角色
            var userAllRole = currentUser.RelationUserRole;
            //用户所有的门店
            List <Entity.Stores> allStore = null;

            List <Entity.Module> sidebar = new List <Entity.Module>();

            //如果是系统管理员,则默认加载所有的菜单//否则就加载用户拥有的权限菜单
            if (initInfo.IsAdministrator)//userAllRole.Any(t => t.RoleID == 1)
            {
                //当前用户使用的角色名称
                initInfo.CurrentRoleName = "超级管理员";
                //左侧菜单(全部获取)
                IModuleService moduleService = ServiceFactory.Create <IModuleService>();
                sidebar = moduleService.GetEntities(t => t.Disabled == false).ToList();

                //管理员可以查看所有门店
                allStore = storesService.GetEntities(t => t.ShopId == initInfo.CurrentShop.ID && t.Disabled == false).ToList();
                //initInfo.Sidebar = sidebar;
            }
            else if (initInfo.CurrentShop.AdminUserID == currentUser.ID)
            {
                //如果是商家,则获取商家的所有菜单
                ////当前用户使用的角色名称
                //initInfo.CurrentRoleName = "店铺管理员";
                //IRelationShopsModuleService relationShopsModuleService = ServiceFactory.Create<IRelationShopsModuleService>();
                //var shopAllModule = relationShopsModuleService.GetEntities(t => t.ShopID == initInfo.CurrentShop.ID).Select(t => t.Module).ToList();
                //foreach (var itemShopModule in shopAllModule)
                //{
                //    //菜单没有被禁用,并且之前没有添加到菜单列表里面
                //    if (!itemShopModule.Disabled && !sidebar.Any(t => t.ID == itemShopModule.ID))
                //    {
                //        sidebar.Add(itemShopModule);
                //    }
                //}

                //如果是商家,则获取商家的对应门店的所有菜单,因为商家下面的门店有可能购买的版本不一样
                //当前用户使用的角色名称
                initInfo.CurrentRoleName = "系统管理员";
                IRelationStoresModuleService relationStoresModuleService = ServiceFactory.Create <IRelationStoresModuleService>();
                var storeAllModule = relationStoresModuleService.GetEntities(t => t.StoresID == initInfo.CurrentStore.ID).Select(t => t.Module).ToList();
                foreach (var itemStoreModule in storeAllModule)
                {
                    if (!itemStoreModule.Disabled && !sidebar.Any(t => t.ID == itemStoreModule.ID))
                    {
                        sidebar.Add(itemStoreModule);
                    }
                }

                //商家管理员可以查看所有门店
                allStore = storesService.GetEntities(t => t.ShopId == initInfo.CurrentShop.ID && t.Disabled == false).ToList();
            }
            else
            {
                //根据角色获取到所有门店
                allStore = userAllRole.Select(t => t.Role.Stores).Where(t => t.Disabled == false).Distinct().ToList();

                IRelationUserRoleService relationUserRoleService = ServiceFactory.Create <IRelationUserRoleService>();

                //过滤出用户当前门店的所有角色
                var userCurrentStoreRole = userAllRole.Where(t => t.Role.StoreID == currentSore.ID);

                //当前用户使用的角色名称
                initInfo.CurrentRoleName = string.Join(",", userCurrentStoreRole.Select(t => t.Role.Name).ToList());

                //用户左侧菜单
                foreach (var itemUserRole in userCurrentStoreRole)
                {
                    //单个角色拥有的菜单
                    var singleRoleModule = itemUserRole.Role.RelationRoleModule;
                    foreach (var itemRoleModule in singleRoleModule)
                    {
                        Module singleModule = itemRoleModule.Module;
                        //菜单没有被禁用,并且之前没有添加到菜单列表里面
                        if (!singleModule.Disabled && !sidebar.Any(t => t.ID == singleModule.ID))
                        {
                            sidebar.Add(singleModule);
                        }
                    }
                }
            }

            //首先获取该用户下面的所有菜单
            IRelationUsersModuleService relationUsersModuleService = ServiceFactory.Create <IRelationUsersModuleService>();
            var userAllModule = relationUsersModuleService.GetEntities(t => t.UsersID == currentUser.ID).Select(t => t.Module).ToList();

            foreach (var itemUserModel in userAllModule)
            {
                //菜单没有被禁用,并且之前没有添加到菜单列表里面
                if (!itemUserModel.Disabled && !sidebar.Any(t => t.ID == itemUserModel.ID))
                {
                    sidebar.Add(itemUserModel);
                }
            }

            //System.Web.HttpContext.Current.Session["InitInfo"] = initInfo;
            //设置缓存2小时
            DataCache.SetCache(HttpContext.Session.SessionID, initInfo, TimeSpan.FromMinutes(1)); //
            //更新登录次数
            IUsersService userService = ServiceFactory.Create <IUsersService>();

            currentUser.LoginTimes    = currentUser.LoginTimes == null ? 1 : currentUser.LoginTimes + 1;
            currentUser.LastLoginTime = DateTime.Now;
            currentUser.LastLoginIP   = Request.UserHostAddress;

            //如果是意向客户,则查询一下IP在哪个城市
            if (currentUser.IsIntention == true)
            {
                currentUser.LastLoginArea = Common.IPHelper.GetAreaByIP(Request.UserHostAddress);
            }

            userService.UpdateEntity(currentUser);

            initInfo.AllStore = allStore;
            initInfo.Sidebar  = sidebar;
            initInfo.IsLogin  = true;

            ////确定当前用户显示的首页,如果有首页则显示,没有首页的话,默认显示微信聚客系统的介绍页
            //if (CurrentInfo.Sidebar.Exists(t =>
            //    t.Area != null && t.Area.ToLower() == "admin" &&
            //    t.Controller != null && t.Controller.ToLower() == "home" &&
            //    t.Action != null && t.Action.ToLower() == "index"))
            //{
            //    initInfo.HomeUrl = "/" + JeasuHelper.SubProjectName;
            //}
            //else
            //{
            //    initInfo.HomeUrl = "/Admin/CashCoupon/UseInstructions";
            //}

            initInfo.HomeUrl = "/Mobile/Home/DriftBottleList";
            #region 广告图片提示收年费
            if (string.IsNullOrWhiteSpace(CurrentInfo.HDImgUrl))
            {
            }

            #endregion

            InitSetting();
        }