public ActionResult ShopPermission(OneKeySearchModel searchModel) { //IUsersService usersService = ServiceFactory.Create<IUsersService>(); Expression <Func <Shops, Boolean> > lbdWhere = null; if (searchModel.SearchStr != null) { searchModel.SearchStr = searchModel.SearchStr.Trim(); if (!string.IsNullOrWhiteSpace(searchModel.SearchStr)) { lbdWhere = t => t.ShopName.Contains(searchModel.SearchStr); } } IShopsService shopsService = ServiceFactory.Create <IShopsService>(); var shops = shopsService.GetEntitiesByPage(searchModel.PageIndex, 10, lbdWhere, false, t => t.ID); //转换数据模型 var listData = shops.Models.Select(t => new ShopPermissionListModel { ID = t.ID, ShopName = t.ShopName, RealName = ServiceHelper.GetUsersService.GetEntity(t.AdminUserID).RealName,// t.Users.RealName, Phone = ServiceHelper.GetUsersService.GetEntity(t.AdminUserID).Phone }); var listShop = new PageModel <ShopPermissionListModel> { Models = listData.ToList(), pagingInfo = shops.pagingInfo }; ViewBag.SearchModel = searchModel; return(View(listShop)); }
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 JsonResult GetCommercialTenant(string strIDs) { List <int> shopVersionIDArr = new List <int>(); IShopsService shopsService = ServiceHelper.GetShopsService; DateTime beginDate = Convert.ToDateTime("2016-10-01"); IQueryable <Shops> shopsListTemp; //ShopVersionID=32说明是自由组合的菜单,在刷菜单的时候需要避开这些菜单 if (string.IsNullOrWhiteSpace(strIDs)) { shopsListTemp = shopsService.GetEntities(t => t.CreateTime > beginDate && t.ShopVersionID != 32); } else { shopVersionIDArr = strIDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(t => Convert.ToInt32(t)).ToList(); shopsListTemp = shopsService.GetEntities(t => shopVersionIDArr.Contains((int)t.ShopVersionID) && t.CreateTime > beginDate && t.ShopVersionID != 32); } var shopsList = shopsListTemp.Select(t => new { ShopsID = t.ID, ShopVersionID = t.ShopVersionID, ShopName = t.ShopName, }).ToList(); return(Json(new { success = true, data = shopsList }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 商家给门店分配菜单的方法 /// </summary> /// <returns></returns> public ActionResult ShopPermissionMenu(int?storeID) { IShopsService shopsService = ServiceFactory.Create <IShopsService>(); Shops shop; //必须是管理员,才可以分配指定门店的权限 if (storeID != null) { if (CurrentInfo.IsAdministrator) { var singleStore = ServiceHelper.GetStoresService.GetEntity((int)storeID); shop = shopsService.GetFirstOrDefault(t => t.ID == singleStore.ShopId); } else { return(RedirectToAction("Error403", "Home", new { area = "Admin" })); } } else { shop = shopsService.GetFirstOrDefault(t => t.AdminUserID == CurrentInfo.CurrentUser.ID); } if (shop != null) { IRelationShopsModuleService relationShopsModuleService = ServiceFactory.Create <IRelationShopsModuleService>(); //获取商家拥有的所有菜单 var munes = relationShopsModuleService.GetEntities(t => t.ShopID == shop.ID).Select(t => t.Module); return(View(munes)); } else { return(RedirectToAction("Error403", "Home", new { area = "Admin" })); } }
public WgShopController(IShopsService shopService, ISkuProductsService skuProductsService, ICacheProvider <ProductCategory> productCategoryCache, IProductRecentlyViewedService productRecentlyViewedService, ISkuAttributesService skuAttributesService, ISkuAttributeOptionsService skuAttributeOptionsService, IProductCategoriesService productCategoriesService, IProductsService productsService, ISkuGroupsService skuGroupsService, ISkuVariantsService skuVariantsService) : base(shopService, skuProductsService, productCategoryCache, productRecentlyViewedService, skuAttributesService, skuAttributeOptionsService, productCategoriesService, productsService, skuGroupsService, skuVariantsService) { if (shopService == null) { throw new ArgumentNullException("shopService"); } if (skuProductsService == null) { throw new ArgumentNullException("skuProductsService"); } if (productCategoryCache == null) { throw new ArgumentNullException("productCategoryCache"); } if (productRecentlyViewedService == null) { throw new ArgumentNullException("productRecentlyViewedService"); } if (skuAttributesService == null) { throw new ArgumentNullException("skuAttributesService"); } if (skuAttributeOptionsService == null) { throw new ArgumentNullException("skuAttributeOptionsService"); } if (productCategoriesService == null) { throw new ArgumentNullException("productCategoriesService"); } if (productsService == null) { throw new ArgumentNullException("productsService"); } if (skuGroupsService == null) { throw new ArgumentNullException("skuGroupsService"); } if (skuVariantsService == null) { throw new ArgumentNullException("skuVariantsService"); } _shopsService = shopService; _skuProductsService = skuProductsService; _productCategoryCache = productCategoryCache; _productRecentlyViewedService = productRecentlyViewedService; _skuAttributeOptionsService = skuAttributeOptionsService; _skuAttributeService = skuAttributesService; _productCategoriesService = productCategoriesService; _productsService = productsService; _skuGroupsService = skuGroupsService; _skuVariantsService = skuVariantsService; }
public ShopsController( IShopsService service, IHttpContextAccessor httpContextAccessor ) : base(service) { _service = service; _httpContextAccessor = httpContextAccessor; }
public JsonResult GetShopsJson(int pageindex, int pagesize, string cols, string qtext) { IShopsService shopsService = ServiceFactory.Create <IShopsService>(); int total = 0; //pageindex默认从0开始,也就是第一页是0,所以pageindex + 1 var data = shopsService.GetEntitiesByPage(pageindex + 1, pagesize, out total, t => t.Disabled != true && t.ShopName.Contains(qtext), false, t => t.ID).ToList().Select(t => new //(t => t.DefaultStoreID == CurrentInfo.CurrentUser.DefaultStoreID) { ID = t.ID, ShopName = t.ShopName, DueDate = t.DueDate.ToString("yyyy-MM-dd") }).ToList(); //返回值记得加total前端要用 return(Json(new { total = total, rows = data }, 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)); }
// GET: Admin/Shops public ActionResult Index() { //如果不是管理员,拒绝访问 //if (!CurrentInfo.IsAdministrator) //{ // return RedirectToAction("Error403", "Home", new { area = "Admin" }); //} //TimeSpan ts = new TimeSpan(9, 30, 0); IShopsService shopsService = ServiceHelper.GetShopsService; //下一个商户号,默认从610001开始 string nextMerchantID = "610001"; var dataShop = shopsService.GetTopEntities(1, t => t.ID, t => true, false); if (dataShop != null) { nextMerchantID = "61" + (dataShop.FirstOrDefault().ID + 1).ToString().PadLeft(4, '0'); } ViewBag.NextMerchantID = nextMerchantID; //销售员 IUsersService usersService = ServiceFactory.Create <IUsersService>(); List <SelectListItemModel> storeAllSaleUser = usersService.GetEntities(t => t.DefaultStoreID == CurrentInfo.CurrentStore.ID && t.Disabled == false && t.Remark.Trim() == "奇策内部销售").ToList().Select( t => new SelectListItemModel { Value = t.ID.ToString(), Text = t.RealName } ).ToList(); List <SelectListItemModel> storeAllAfterSales = usersService.GetEntities(t => t.DefaultStoreID == CurrentInfo.CurrentStore.ID && t.Disabled == false && t.Remark.Trim() == "奇策内部售后").ToList().Select( t => new SelectListItemModel { Value = t.ID.ToString(), Text = t.RealName } ).ToList(); //storeAllSaleUser.Insert(0, new SelectListItemModel { Value = "0", Text = "无" }); //SelectList allUserSelect = new SelectList(storeAllSaleUser, "Value", "Text", "0");// CurrentInfo.CurrentStore.ID ViewData["storeAllSaleUser"] = new SelectList(storeAllSaleUser, "Value", "Text", "0"); // CurrentInfo.CurrentStore.ID ViewData["storeAllAfterSales"] = new SelectList(storeAllAfterSales, "Value", "Text", "0"); // CurrentInfo.CurrentStore.ID //SelectList afterSales return(View()); }
public ActionResult GetShopsPage(int pageSize, int pageNumber, string shopName, string MerchantID) { //SearchModel<ShopsParams> searchModel = new SearchModel<ShopsParams> //{ // PageIndex = pageNumber, // PageSize = pageSize, // Model = new ShopsParams() { ShopName = shopName } //}; var expr = BuildSearchCriteria(shopName, MerchantID); int total; //WhereHelper<Shops> where = new WhereHelper<Shops>(); //if (!string.IsNullOrEmpty(shopName)) //{ // where.Contains("ShopName", shopName); //} IShopsService shopsService = ServiceFactory.Create <IShopsService>(); var data = shopsService.GetEntitiesByPage(pageNumber, pageSize, out total, expr, false, t => t.ID).ToList().Select(t => new { ID = t.ID, MerchantID = "61" + t.ID.ToString().PadLeft(4, '0'), ShopName = t.ShopName, UserID = t.AdminUserID, //ThisUser = ServiceHelper.GetUsersService.GetEntity(t.AdminUserID), UserName = ServiceHelper.GetUsersService.GetEntity(t.AdminUserID).UserName, TotalMoney = t.TotalMoney, Phone = ServiceHelper.GetUsersService.GetEntity(t.AdminUserID).Phone, DueDate = t.DueDate.ToString("yyyy-MM-dd"), CreateUser = "******", CreateTime = t.CreateTime.ToString("yyyy-MM-dd"), NoticeOpenID = t.NoticeOpenID, Disabled = t.Disabled == true, ShopType = t.ShopType, ShopVersionName = t.ShopVersion.Name, SalespersonName = "销售员", Deposit = t.Deposit, FinalPayment = t.FinalPayment, RegionText = t.Province + "." + t.City + "." + t.County }).ToList(); return(Json(new { total = total, rows = data }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 门店商家管理页面 /// </summary> /// <returns></returns> public ActionResult CustStoreManage() { IShopsService shopsService = ServiceFactory.Create <IShopsService>(); IStoresService storesService = ServiceFactory.Create <IStoresService>(); //判断当前用户是否是这个商家的管理员,如果不是则拒绝访问 //var shop = shopsService.GetFirstOrDefault(t => t); //bool isIntention = CurrentInfo.CurrentUser.IsIntention == null ? false : Convert.ToBoolean(CurrentInfo.CurrentUser.IsIntention); //if (!CurrentInfo.IsShopAdmin && !isIntention) //{ // return RedirectToAction("Error403", "Home", new { area = "Admin" }); //} //判断是否已经设置过主店,如果设置了,则不允许用户再次修改 var hasMainStore = storesService.Exists(t => t.ShopId == CurrentInfo.CurrentUser.ShopsID && t.IsMainStore == true); ViewBag.HasMainStore = hasMainStore; return(View()); }
public WgShopController(IShopsService shopService, ISkuProductsService skuProductsService, ICacheProvider <ProductCategory> productCategoryCache, IProductRecentlyViewedService productRecentlyViewedService, ISkuAttributesService skuAttributesService, ISkuAttributeOptionsService skuAttributeOptionsService, IProductCategoriesService productCategoriesService, IProductsService productsService, ISkuGroupsService skuGroupsService, ISkuVariantsService skuVariantsService, ISkuColourService skuColourService, ICustomSearchTermService customSearchTermService, IDeliveryChargeService deliveryChargeService, ISkuService skuService, ISkuPricesService skuPricesService) : base( shopService, skuProductsService, productCategoryCache, productRecentlyViewedService, skuAttributesService, skuAttributeOptionsService, productCategoriesService, productsService, skuGroupsService, skuVariantsService, skuColourService, deliveryChargeService, skuService, skuPricesService) { _customSearchTermService = customSearchTermService; _b2bCheckoutService = new B2BCheckoutService( GetService <ITransactionService>(), CommerceContext, GetService <IShopsService>(), VisitorTrackingContext, GetService <ICurrencyService>(), ColonyContext); }
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 StoresOpeningController(IShopsService shopsService) { _shopService = shopsService; }
public AddProductsByFactory(IShopsService shopsService) : base(shopsService) { }
public ShopsBaseConsumer(IShopsService shopsService) { ShopsService = shopsService; }
public GetAllShops(IShopsService shopsService) : base(shopsService) { }
public ShopsController(IShopsService repository) { this.shopsService = repository; }
public GetProductsByShop(IShopsService shopsService) : base(shopsService) { }
public ShopsController(IMapper mapper, IShopsService shopsService) { _mapper = mapper; _shopsService = shopsService; }
/// <summary> /// 系统管理员使用的方法 /// </summary> /// <param name="pageSize"></param> /// <param name="username"></param> /// <param name="pageNumber"></param> /// <returns></returns> public ActionResult GetStores(int pageSize, string username, int pageNumber, int?shopID) { //SearchModel<StoresParams> searchModel = new SearchModel<StoresParams> //{ // PageIndex = pageNumber, // PageSize = pageSize, // Model = new StoresParams() { StoreName = username } //}; IShopsService shopsService = ServiceFactory.Create <IShopsService>(); //var shop = shopsService.GetFirstOrDefault(t => t.AdminUserID == CurrentInfo.CurrentUser.ID); DynamicLambda <Stores> bulider = new DynamicLambda <Stores>(); Expression <Func <Stores, Boolean> > expr = null; ////如果是商家本人的账号,则显示商家自己的门店 //if (shop != null) //{ // Expression<Func<Stores, Boolean>> tmp = t => t.ShopId == shop.ID; // expr = bulider.BuildQueryAnd(expr, tmp); //} if (shopID != null) { if (shopID > 0) { Expression <Func <Stores, Boolean> > tmp = t => t.ShopId == shopID; expr = bulider.BuildQueryAnd(expr, tmp); } else { Expression <Func <Stores, Boolean> > tmp = t => t.VirtualShopsID == shopID; expr = bulider.BuildQueryAnd(expr, tmp); } } if (!string.IsNullOrWhiteSpace(username)) { username = username.Trim(); Expression <Func <Stores, Boolean> > tmp = t => t.StoreName.Contains(username) || t.Shops.ShopName.Contains(username); expr = bulider.BuildQueryAnd(expr, tmp); } IStoresService storesService = ServiceFactory.Create <IStoresService>(); int total; var data = storesService.GetEntitiesByPage(pageNumber, pageSize, out total, expr, false, t => t.ID).Select(t => new { ID = t.ID, ShopsName = t.Shops.ShopName, ShopsID = t.ShopId, StoreName = t.StoreName, Adress = t.Adress, Phone = t.Phone, IsShowWeiXin = t.IsShowWeiXin == true ? "显示" : "不显示", IsMainStore = t.IsMainStore, Disabled = t.Disabled, VirtualShopsID = t.VirtualShopsID }).ToList(); return(Json(new { total = total, rows = data }, JsonRequestBehavior.AllowGet)); }
public ShopsController(IShopsService shopsService) { this.shopsService = shopsService; }
public GetProductsByCategory(IShopsService shopsService) : base(shopsService) { }
public BuyProducts(IShopsService shopsService, IBusControl busControl) : base(shopsService) { _busControl = busControl; }
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); }
//public int nowAddShopID = 0; public Shops CreateShop(ShopModel shopModel, int createUserID = 0) { IUsersService usersService = ServiceFactory.Create <IUsersService>(); IShopsService shopsService = ServiceFactory.Create <IShopsService>(); IStoresService storesService = ServiceFactory.Create <IStoresService>(); if (createUserID == 0) { createUserID = CurrentInfo.CurrentUser.ID; } //bool saveSuccess = false; Shops shops = null; //用事务来添加一个商家 using (TransactionScope scope = TransactionScopeHelper.GetTran(TransactionScopeOption.Required, TimeSpan.FromSeconds(20))) { //商家账号 Users users = new Users(); users.RealName = shopModel.RealName; users.UserName = shopModel.UserName; //添加账号PasswordSalt随机 users.PasswordSalt = Common.TextFilter.GetPasswordSalt(); //Common.TextFilter.Substring(Guid.NewGuid().ToString("N"), 10, false); string endPassword = shopModel.Password + users.PasswordSalt; users.Password = Common.SecureHelper.MD5(endPassword); users.NeedAccount = true; users.Idcard = shopModel.Idcard; users.Phone = shopModel.Phone; users.DefaultStoreID = null; users.CreateUserID = createUserID; users.CreateTime = DateTime.Now; users.Disabled = shopModel.Disabled; users = usersService.AddEntity(users); //商家信息 shops = new Shops(); shops.ShopName = shopModel.ShopName; shops.Domain = shopModel.Domain; shops.DomainName = shopModel.DomainName; shops.DueDate = shopModel.DueDate; shops.TotalMoney = shopModel.TotalMoney; shops.Remark = shopModel.Remark; shops.AdminUserID = users.ID; shops.CreateUserID = createUserID; shops.CreateTime = DateTime.Now; shops.Disabled = shopModel.Disabled; shops.ShopVersionID = shopModel.ShopVersionID; 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; //默认赋值 { shops.DueDate = DateTime.MaxValue; shops.TotalMoney = 0; shops.Disabled = false; shops.ShopVersionID = 1; } shops = shopsService.AddEntity(shops); //门店(开通商家的时候默认开通一号店) Stores stores = new Stores(); stores.ShopId = shops.ID; stores.StoreName = "一号部门"; stores.IsShare = false; stores.IsShowWeiXin = false; stores.IsMainStore = false; stores = storesService.AddEntity(stores); users.ShopsID = shops.ID; users.DefaultStoreID = stores.ID; usersService.UpdateEntity(users); //Category categoryModel = new Category(); //categoryModel.Name = "总仓"; //categoryModel.Sort = 1; //categoryModel.CategoryType = 3; //categoryModel.Name = categoryModel.Name.Trim(); //categoryModel.UserID = users.ID; //categoryModel.CreateTime = DateTime.Now; //categoryModel.StoreID = stores.ID; //categoryModel = categoryModel.Add(); //Role roleModel = new Role(); //roleModel.Name = "经理"; //roleModel.Sort = 1; //roleModel.ShopsID = shops.ID; //roleModel.StoreID = stores.ID; //roleModel.CreateUserID = users.ID; //roleModel.CreateTime = DateTime.Now; //roleModel = roleModel.Add(); //这边要取出这个版本所有菜单,然后加到用户菜单关系表 和 商家菜单关系表中 IRelationShopVersionModuleService relationShopVersionModuleService = ServiceFactory.Create <IRelationShopVersionModuleService>(); var listModuleID = relationShopVersionModuleService.GetEntities(t => t.ShopVersionID == shopModel.ShopVersionID).Select(t => t.ModuleID).ToList(); var strModuleID = string.Join(",", listModuleID.ToArray()); //添加商家和菜单的关系 AddRelationShopModule(shops.ID.ToString(), strModuleID, createUserID); //添加门店和菜单的关系 AddRelationStoreModule(stores.ID.ToString(), strModuleID, createUserID); //添加用户和菜单的关系 AddRelationUsersModule(users.ID.ToString(), strModuleID, createUserID); ////添加角色和菜单的关系 //AddRelationRoleModule(roleModel.ID.ToString(), strModuleID, createUserID); scope.Complete(); } return(shops); }