public ActionResult EditShopUser(int id) { IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); //获取要编辑的门店用户 T_ShopUser shopUser = shopUserBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (shopUser != null) { //初始化返回页面的模型 ShopUserModel model = new ShopUserModel() { Id = shopUser.Id, UserName = shopUser.UserName, TrueName = shopUser.TrueName, Phone = shopUser.Phone, Gender = shopUser.Gender, GenderList = GetGenderList(), Email = shopUser.Email, Memo = shopUser.Memo }; return(View(model)); } else { return(RedirectToAction("ShopUserList")); } }
public JsonResult AddShopUser(ShopUserModel Model) { JsonModel jm = new JsonModel(); //如果表单验证成功 if (ModelState.IsValid) { IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser shopUser = new T_ShopUser() { UserName = Model.UserName, TrueName = Model.TrueName, Phone = Model.Phone, Gender = Model.Gender, Email = Model.Email, Password = PropertyUtils.GetMD5Str(Model.Password), Memo = Model.Memo }; //保存到数据库 shopUserBll.Save(shopUser); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(Model); } else { //保存异常日志 jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult SetShopUserInfo() { // 获取Session Model UserSessionModel model = (UserSessionModel)Session[ConstantParam.SESSION_USERINFO]; var id = model.UserID; IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); var userInfo = shopUserBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (userInfo != null) { LoggedInAccountModel shopUserModel = new LoggedInAccountModel(); shopUserModel.UserId = userInfo.Id; shopUserModel.UserName = userInfo.UserName; shopUserModel.TrueName = userInfo.TrueName; shopUserModel.Phone = userInfo.Phone; shopUserModel.Email = userInfo.Email; shopUserModel.Memo = userInfo.Memo; shopUserModel.HeadPath = userInfo.HeadPath; return(View(shopUserModel)); } else { return(RedirectToAction("Index", "ShopPlatform")); } }
public ApiResultModel EditGoodsCategory(GoodsCategoryInfoModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前商家用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果商家用户存在 if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); if (model.Id.HasValue) { IGoodsCategoryBLL goodsBLL = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); if (goodsBLL.Exist(m => m.Name == model.Name && m.Id != model.Id && m.ShopId == model.ShopId)) { resultModel.Msg = "该商品类别已经存在"; } else { var goodsCategory = goodsBLL.GetEntity(g => g.Id == model.Id.Value); //修改商品分类 if (goodsCategory != null) { goodsCategory.Name = model.Name; goodsBLL.Update(goodsCategory); } else { resultModel.Msg = "不存在当前商品分类"; } } } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiResultModel GetShopInfo([FromUri] ShopInfoModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); //调用商家BLL层获取商家信息 IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL"); var shop = shopBll.GetEntity(s => s.Id == model.ShopId); //如果商家信息不为空 if (shop != null) { resultModel.result = new { ShopName = shop.ShopName, ShopContent = string.Format("MobilePage/StoreIntroduce?ShopId={0}", shop.Id), ShopMainSale = shop.MainSale, StartBusinessTime = shop.StartBusinessTime, EndBusinessTime = shop.EndBusinessTime, ShopAddress = shop.Address, Phone = shop.Phone, ShopPicList = shop.ImgPath }; } else { resultModel.Msg = APIMessage.NO_APP; } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public JsonResult ResetPassword(int id) { JsonModel jm = new JsonModel(); IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); // 根据指定id值获取实体对象 var shopUser = shopUserBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (shopUser != null) { Random r = new Random(); int radVal = r.Next(100, 1000); shopUser.Password = PropertyUtils.GetMD5Str(shopUser.UserName + radVal); //重置密码 shopUserBll.Update(shopUser); //给门店用户发送邮件 PropertyUtils.SendEmail(shopUser.Email, shopUser.UserName, "物业生活管理系统 用户密码重置", "您的用户密码已重置为" + shopUser.UserName + radVal + ", 请及时修改密码!"); //操作日志 jm.Content = "门店用户" + shopUser.TrueName + "密码一键重置成功"; } else { jm.Msg = "该门店用户不存在"; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ApiResultModel DeleteOrder(DetailSearchModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前商家用户 IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); var user = shopUserBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (user == null) { resultModel.Msg = APIMessage.NO_USER; return(resultModel); } //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); shopUserBll.Update(user); //获取指定订单 IOrderBLL orderBll = BLLFactory <IOrderBLL> .GetBLL("OrderBLL"); var order = orderBll.GetEntity(o => o.Id == model.Id && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && o.IsStoreHided == ConstantParam.DEL_FLAG_DEFAULT); if (order != null) { if (order.OrderStatus == ConstantParam.OrderStatus_FINISH || order.OrderStatus == ConstantParam.OrderStatus_EXIT || order.OrderStatus == ConstantParam.OrderStatus_CLOSE) { order.IsStoreHided = ConstantParam.DEL_FLAG_DELETE; //删除订单 if (!orderBll.Update(order)) { resultModel.Msg = "订单删除失败"; } } else { resultModel.Msg = "当前状态的订单不能被删除"; } } else { resultModel.Msg = APIMessage.ORDER_NOEXIST; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiResultModel GetVersionInfo([FromUri] TokenModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前用户 IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); var user = shopUserBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); shopUserBll.Update(user); //调用版本信息BLL层获取最新的版本信息 IMobileVersionBLL versionBll = BLLFactory <IMobileVersionBLL> .GetBLL("MobileVersionBLL"); var Versions = versionBll.GetList(v => v.Type == ConstantParam.MOBILE_TYPE_SHOP, "VersionCode", false); //如果版本信息不为空 if (Versions != null && Versions.Count() > 0) { var highestVersion = Versions.First(); if (highestVersion != null) { resultModel.result = new { VersionCode = highestVersion.VersionCode, VersionName = highestVersion.VersionName, Desc = highestVersion.Desc, ApkFilePath = highestVersion.ApkFilePath }; } } else { resultModel.Msg = APIMessage.NO_APP; } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiResultModel GetShopUserInfo([FromUri] TokenModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); var shop = user.Shops.FirstOrDefault(); //如果商家信息不为空 if (shop != null) { resultModel.result = new { ShopUserName = user.UserName, ShopUserImage = user.HeadPath, ShopName = shop.ShopName, TrueName = user.TrueName, UserGender = user.Gender.HasValue ? user.Gender.Value == 1 ? "男" : "女" : "", PhoneNumber = user.Phone, Email = user.Email }; } else { resultModel.Msg = APIMessage.SHOP_NOEXIST; } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiResultModel SetShopInfo(ShopInfoModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); //调用商家BLL层获取商家信息 IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL"); var shop = shopBll.GetEntity(s => s.Id == model.ShopId); //设置主营内容 if (shop != null) { shop.ShopName = model.ShopName; //shop.Content = model.ShopContent; shop.MainSale = model.MainSale; shop.StartBusinessTime = model.StartBusinessTime; shop.EndBusinessTime = model.EndBusinessTime; shop.Address = model.Address; shop.Phone = model.Phone; shop.UpdateTime = DateTime.Now; shopBll.Update(shop); } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiPageResultModel GetGoodsCategoryList([FromUri] GoodsCategorySearchModel model) { ApiPageResultModel resultModel = new ApiPageResultModel(); try { //获取当前用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果业主存在 if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); IGoodsCategoryBLL goodsBLL = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); Expression <Func <T_GoodsCategory, bool> > where = g => g.ShopId == model.ShopId; // 获取商家的商品分类 var list = goodsBLL.GetPageList(where, model.PageIndex).Select( g => new { Id = g.Id, Name = g.Name, Count = g.ShopSales.Count() }).ToList(); resultModel.result = list; resultModel.Total = goodsBLL.Count(g => g.ShopId == model.ShopId); } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
/// <summary> /// 保存门店用户的session信息 /// </summary> /// <param name="user">登录的时候取出数据再赋值</param> private void SetUserSessiong(T_ShopUser user, IShopUserBLL bll) { //用户session模型 UserSessionModel sessionInfo = new UserSessionModel(); //设置基本信息 sessionInfo.UserID = user.Id; sessionInfo.UserName = user.UserName; sessionInfo.TrueName = user.TrueName; sessionInfo.UserType = ConstantParam.USER_TYPE_SHOP; sessionInfo.HeadPath = user.HeadPath; //设置session信息 Session[ConstantParam.SESSION_USERINFO] = sessionInfo; }
/// <summary> /// 远程验证门店用户名称是否存在 /// </summary> /// <param name="UserName">门店用户名称</param> /// <param name="UserId">用户id,新增时恒为0,修改用户信息时不为0</param> public ContentResult RemoteCheckExist(int Id, string userName) { IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); // 用户名已存在 if (shopUserBll.Exist(m => m.UserName == userName && m.Id != Id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT)) { // 校验不通过 return(Content("false")); } else { return(Content("true")); } }
public ActionResult ShopUserList(SearchModel model) { IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); Expression <Func <T_ShopUser, bool> > where = u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT; if (!string.IsNullOrEmpty(model.Kword)) { where = PredicateBuilder.And(where, u => u.UserName.Contains(model.Kword) || u.TrueName.Contains(model.Kword) || u.Email.Contains(model.Kword)); } //排序 var sortModel = this.SettingSorting("Id", false); var list = shopUserBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex); return(View(list)); }
public ApiResultModel ChangePassword(OwnerChangePasswordModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取要修改密码的商家用户 IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); var user = shopUserBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); shopUserBll.Update(user); string OldMd5Pwd = PropertyUtils.GetMD5Str(model.OldPwd); //如果输入的旧密码与数据库中不一致 if (OldMd5Pwd != user.Password) { resultModel.Msg = APIMessage.OLD_PWD_ERROR; } else { //修改密码并保存 user.Password = PropertyUtils.GetMD5Str(model.NewPwd); shopUserBll.Update(user); } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ActionResult ShopPlatformLogin(AccountModel model) { //判断提交模型数据是否正确 if (!ModelState.IsValid) { return(View(model)); } string code = (string)Session["ValidateCode"]; if (model.CheckCode != code) { ModelState.AddModelError("CheckCode", "验证码不正确"); return(View(model)); } //根据用户名查找门店平台用户 IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = shopUserBll.GetEntity(u => u.UserName == model.UserName.Trim() && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //1.判断用户名是否正确 if (user == null) { ModelState.AddModelError("UserName", "用户名不存在"); return(View(model)); } //2.判断密码是否正确 string md5Str = PropertyUtils.GetMD5Str(model.Password); if (user.Password != md5Str) { ModelState.AddModelError("Password", "密码不正确"); return(View(model)); } //3.保存基本信息到session中 this.SetUserSessiong(user, shopUserBll); BreadCrumb.ClearState(); //4.跳转到 return(RedirectToAction("Index", "ShopPlatform")); }
public ActionResult SetShopUserInfo(LoggedInAccountModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { // 获取Session Model UserSessionModel sessionModel = (UserSessionModel)Session[ConstantParam.SESSION_USERINFO]; var id = sessionModel.UserID; IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser shopUser = shopUserBll.GetEntity(m => m.Id == model.UserId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);//查询 //如果数据为空,将输入数据写入 if (shopUser != null) { shopUser.TrueName = model.TrueName; shopUser.Phone = model.Phone; shopUser.Email = model.Email; shopUser.Memo = model.Memo; // 保存到数据库 shopUserBll.Update(shopUser); //更新SessionModel中的最新个人信息 sessionModel.TrueName = model.TrueName; //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = "该用户不存在"; } } else { // 保存异常日志 jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult EditShopUserPwd() { UserSessionModel sessionModel = (UserSessionModel)Session[ConstantParam.SESSION_USERINFO]; var id = sessionModel.UserID; IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); var userInfo = shopUserBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (userInfo != null) { AccountPasswordChangeModel shopUserModel = new AccountPasswordChangeModel(); shopUserModel.UserId = userInfo.Id; shopUserModel.UserName = userInfo.UserName; return(View(shopUserModel)); } else { return(RedirectToAction("Index", "ShopPlatform")); } }
public JsonResult EditShopUser(ShopUserModel model) { JsonModel jm = new JsonModel(); //如果表单验证成功 if (ModelState.IsValid) { IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser shopUser = shopUserBll.GetEntity(m => m.Id == model.Id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (shopUser != null) { shopUser.UserName = model.UserName; shopUser.TrueName = model.TrueName; shopUser.Email = model.Email; shopUser.Gender = model.Gender; shopUser.Phone = model.Phone; shopUser.Memo = model.Memo; //保存到数据库 if (shopUserBll.Update(shopUser)) { //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = "编辑失败"; } } else { jm.Msg = "该门店用户不存在"; } } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取当前登录用户的头像图片路径 /// </summary> /// <param name="html">HTML对象</param> /// <returns></returns> public static string GetLoginUserHeadImgPath(this HtmlHelper html) { //获取session对象 var session = HttpContext.Current.Session; var model = (UserSessionModel)session[ConstantParam.SESSION_USERINFO]; if (model != null) { if (model.UserType == ConstantParam.USER_TYPE_PROPERTY) { IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); var user = userBll.GetEntity(u => u.Id == model.UserID); return(user.HeadPath); } else if (model.UserType == ConstantParam.USER_TYPE_SHOP) { IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); var user = userBll.GetEntity(u => u.Id == model.UserID); return(user.HeadPath); } else if (model.UserType == ConstantParam.USER_TYPE_PLATFORM) { IPlatformUserBLL userBll = BLLFactory <IPlatformUserBLL> .GetBLL("PlatformUserBLL"); var user = userBll.GetEntity(u => u.Id == model.UserID); return(user.HeadPath); } else if (model.UserType == ConstantParam.USER_TYPE_COMPANY) { ICompanyUserBLL userBll = BLLFactory <ICompanyUserBLL> .GetBLL("CompanyUserBLL"); var user = userBll.GetEntity(u => u.Id == model.UserID); return(user.HeadPath); } } return(null); }
public ActionResult EditShopUserPwd(AccountPasswordChangeModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { UserSessionModel sessionModel = (UserSessionModel)Session[ConstantParam.SESSION_USERINFO]; var id = sessionModel.UserID; // 若当前登录用户为门店用户 IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser shopUser = shopUserBll.GetEntity(m => m.Id == model.UserId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (shopUser != null) { shopUser.Password = PropertyUtils.GetMD5Str(model.Password); shopUser.Token = null; shopUser.TokenInvalidTime = null; // 保存到数据库 shopUserBll.Update(shopUser); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = "该门店用户不存在"; } } else { // 保存异常日志 jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteShopUser(int id) { JsonModel jm = new JsonModel(); //获取要删除的门店用户 IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser shopUser = shopUserBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果该门店用户存在 if (shopUser == null) { jm.Msg = "该门店用户不存在"; } else { //修改门店用户中的已删除标识 shopUser.DelFlag = ConstantParam.DEL_FLAG_DELETE; shopUserBll.DeleteShopUser(shopUser); //操作日志 jm.Content = "删除门店用户" + shopUser.UserName; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult AddShop(int Id) { IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser shopUser = shopUserBll.GetEntity(m => m.Id == Id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (shopUser != null) { ShopModel model = new ShopModel(); model.TypeList = GetTypeList(); model.ProvinceList = GetProvinceList(); model.CityList = new List <SelectListItem>(); model.CountyList = new List <SelectListItem>(); model.TimeList = GetBusinessTimeList(); model.ShopUserId = Id; model.ShopUserName = shopUser.UserName; return(View(model)); } else { return(RedirectToAction("ShopUserList")); } }
public ActionResult UploadShopPic(int id) { JsonModel jm = new JsonModel(); IShopUserBLL UserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); var user = UserBll.GetEntity(m => m.DelFlag == 0 && m.Id == id); //用户存在 if (user != null) { LoggedInAccountModel userModel = new LoggedInAccountModel() { UserId = user.Id, HeadPath = user.HeadPath }; return(View(userModel)); } //用户不存在 else { jm.Msg = "用户不存在"; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ApiResultModel SetOnSale(GoodsInfoModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前商家用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果商家用户存在 if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); if (model.Id.HasValue) { IShopSaleBLL shopSaleBll = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL"); var goods = shopSaleBll.GetEntity(g => g.Id == model.Id.Value); //修改商品上/下架 if (goods != null) { goods.InSales = model.InSales; if (goods.InSales == 0) { goods.UnShelveTime = DateTime.Now; } else { goods.CreateTime = DateTime.Now; } shopSaleBll.Update(goods); } else { resultModel.Msg = "不存在当前商品分类"; } } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiResultModel DelGoods(GoodsInfoModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前商家用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果商家用户存在 if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); if (model.Id.HasValue) { IShopSaleBLL shopSaleBll = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL"); var goods = shopSaleBll.GetEntity(g => g.Id == model.Id.Value); if (goods == null) { resultModel.Msg = "该商品不存在"; } else { if (goods.OrderDetails.Count > 0) { resultModel.Msg = "该商品已被订购,无法删除"; } else { var imagePath = goods.ImgPath; var imgThumbnail = goods.ImgThumbnail; shopSaleBll.Delete(goods); if (!string.IsNullOrWhiteSpace(imagePath)) { if (imagePath.Contains(";")) { foreach (var path in imagePath.Split(';')) { DelFile(path); } } else { DelFile(imagePath); } } if (!string.IsNullOrWhiteSpace(imgThumbnail)) { if (imgThumbnail.Contains(";")) { foreach (var path in imgThumbnail.Split(';')) { DelFile(path); } } else { DelFile(imgThumbnail); } } } } } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiResultModel EditGoods(GoodsInfoModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前商家用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果商家用户存在 if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); if (model.Id.HasValue) { IShopSaleBLL shopSaleBll = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL"); var goods = shopSaleBll.GetEntity(g => g.Id == model.Id.Value); //修改商品分类 if (goods != null) { //基础信息 goods.Title = model.Name; goods.Content = model.Content; goods.Price = model.Price; goods.RemainingAmout = model.RemainingAmount; goods.GoodsCategoryId = model.GoodCategoryId; //图片和压缩图 var sourceImgList = goods.ImgPath == null ? null : goods.ImgPath.Split(';').ToList(); var sourceImgThumbnailArray = goods.ImgThumbnail == null ? null : goods.ImgThumbnail.Split(';').ToArray(); var remainingImgList = goods.ImgPath == null ? new List <string>() : goods.ImgPath.Split(';').ToList(); var remainingImgThumbnailList = goods.ImgThumbnail == null ? new List <string>() : goods.ImgThumbnail.Split(';').ToList(); //要删除的缩略图列表 var delImgThumbnailList = new List <string>(); if (sourceImgList != null) { //对要删除的图片列表进行删除 if (!string.IsNullOrWhiteSpace(model.delPicList)) { foreach (var path in model.delPicList.Split(';')) { int index = sourceImgList.FindIndex(m => m == path); if (index < sourceImgThumbnailArray.Count()) { delImgThumbnailList.Add(sourceImgThumbnailArray[index]); } remainingImgList.Remove(path); DelFile(path); } } } foreach (var path in delImgThumbnailList) { remainingImgThumbnailList.Remove(path); DelFile(path); } var strRemainedImg = ""; foreach (var item in remainingImgList) { if (!string.IsNullOrEmpty(item.Trim())) { strRemainedImg = strRemainedImg + item + ";"; } } var strReminedThumbnailImg = ""; foreach (var item in remainingImgThumbnailList) { if (!string.IsNullOrEmpty(item.Trim())) { strReminedThumbnailImg = strReminedThumbnailImg + item + ";"; } } //图片上传 if (!string.IsNullOrEmpty(model.PicList)) { //文件资源保存目录 string dir = HttpContext.Current.Server.MapPath(ConstantParam.SHOP_Sales); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var fileName = DateTime.Now.ToFileTime().ToString() + ".zip"; string filepath = Path.Combine(dir, fileName); using (FileStream fs = new FileStream(filepath, FileMode.Create)) { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] datas = Convert.FromBase64String(model.PicList); bw.Write(datas); bw.Close(); } } var imgZipParth = PropertyUtils.UnZip(filepath, dir, ConstantParam.SHOP_Sales); //图片集路径保存 goods.ImgPath = strRemainedImg + imgZipParth; StringBuilder imgsSB = new StringBuilder(); //生成缩略图保存 foreach (var path in imgZipParth.Split(';')) { string thumpFile = DateTime.Now.ToFileTime().ToString() + ".jpg"; string thumpPath = Path.Combine(HttpContext.Current.Server.MapPath(ConstantParam.SHOP_Sales_ThumIMG), thumpFile); PropertyUtils.getThumImage(Path.Combine(HttpContext.Current.Server.MapPath(path)), 18, 3, thumpPath); imgsSB.Append(ConstantParam.SHOP_Sales_ThumIMG + "/" + thumpFile + ";"); } goods.ImgThumbnail = imgsSB.ToString(); goods.ImgThumbnail = strReminedThumbnailImg + goods.ImgThumbnail.Substring(0, goods.ImgThumbnail.Length - 1); } else { goods.ImgPath = strRemainedImg; goods.ImgThumbnail = strReminedThumbnailImg; } shopSaleBll.Update(goods); } else { resultModel.Msg = "不存在当前商品"; } } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiResultModel AddGoods(GoodsInfoModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前商家用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果商家用户存在 if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); //商品分类实例化 T_ShopSale goods = new T_ShopSale() { Title = model.Name, Content = model.Content, CreateTime = DateTime.Now, GoodsCategoryId = model.GoodCategoryId, Price = model.Price, RemainingAmout = model.RemainingAmount, InSales = 1 }; //话题文件资源保存目录 string dir = HttpContext.Current.Server.MapPath(ConstantParam.SHOP_Sales); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } //图片上传 if (!string.IsNullOrEmpty(model.PicList)) { var fileName = DateTime.Now.ToFileTime().ToString() + ".zip"; string filepath = Path.Combine(dir, fileName); using (FileStream fs = new FileStream(filepath, FileMode.Create)) { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] datas = Convert.FromBase64String(model.PicList); bw.Write(datas); bw.Close(); } } //图片集路径保存 goods.ImgPath = PropertyUtils.UnZip(filepath, dir, ConstantParam.SHOP_Sales); StringBuilder imgsSB = new StringBuilder(); //生成缩略图保存 foreach (var path in goods.ImgPath.Split(';')) { string thumpFile = DateTime.Now.ToFileTime() + ".jpg"; string thumpPath = Path.Combine(HttpContext.Current.Server.MapPath(ConstantParam.SHOP_Sales_ThumIMG), thumpFile); PropertyUtils.getThumImage(Path.Combine(HttpContext.Current.Server.MapPath(path)), 18, 3, thumpPath); imgsSB.Append(ConstantParam.SHOP_Sales_ThumIMG + "/" + thumpFile + ";"); } goods.ImgThumbnail = imgsSB.ToString(); goods.ImgThumbnail = goods.ImgThumbnail.Substring(0, goods.ImgThumbnail.Length - 1); } //保存商品 IShopSaleBLL goodsBLL = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL"); goodsBLL.Save(goods); //绿色直供推送 if (model.IsPush == 1) { IShopBLL shopBLL = BLLFactory <IShopBLL> .GetBLL("ShopBLL"); string shopName = shopBLL.GetEntity(s => s.Id == model.ShopId).ShopName; //推送给业主客户端 IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL"); var registrationIds = userPushBLL.GetList(p => !string.IsNullOrEmpty(p.RegistrationId)).Select(p => p.RegistrationId).ToArray(); string alert = shopName + "的商品" + goods.Title + "上架了"; bool flag = PropertyUtils.SendPush("商品上架", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationIds); if (!flag) { resultModel.Msg = "推送发生异常"; } } } else { resultModel.Msg = APIMessage.NO_USER; } } catch (Exception ex) { PropertyUtils.WriteLogInfo("test"); PropertyUtils.WriteLogError(ex); resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiResultModel GetGoods([FromUri] GoodsInfoModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前商家用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果商家用户存在 if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); if (model.Id.HasValue) { IShopSaleBLL shopSaleBll = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL"); var goods = shopSaleBll.GetEntity(g => g.Id == model.Id.Value); //商品详情 if (goods != null) { resultModel.result = new { Name = goods.Title, Content = goods.Content, Price = goods.Price, RemaintAmount = goods.RemainingAmout, GoodsCategoryId = goods.GoodsCategoryId, GoodsCategoryName = goods.GoodsCategory.Name, ImgPath = goods.ImgPath, ImgThumbnail = goods.ImgThumbnail }; } else { resultModel.Msg = "不存在当前商品"; } } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiPageResultModel GetGoodsList([FromUri] GoodsSearchModel model) { ApiPageResultModel resultModel = new ApiPageResultModel(); try { //获取当前用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果业主存在 if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); Expression <Func <T_ShopSale, bool> > where = s => s.InSales == model.InSales && s.GoodsCategory.ShopId == model.ShopId; if (model.GoodsCategoryId > 0) { where = PredicateBuilder.And(where, s => s.GoodsCategoryId == model.GoodsCategoryId); } IOrderBLL orderBll = BLLFactory <IOrderBLL> .GetBLL("OrderBLL"); IShopSaleBLL shopSaleBLL = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL"); var list = shopSaleBLL.GetPageList(where, "CreateTime", false, model.PageIndex).Select( s => new { Id = s.Id, ImgThumbnail = string.IsNullOrEmpty(s.ImgThumbnail) ? "" : s.ImgThumbnail.Split(';').FirstOrDefault(), Title = s.Title, Price = s.Price, RemainingAmout = s.RemainingAmout, SaledCount = s.OrderDetails.Where(od => od.Order.OrderStatus == ConstantParam.OrderStatus_FINISH).Select(od => od.SaledAmount).ToArray().Sum(), CreateDate = s.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), UnShelveTime = s.UnShelveTime.HasValue ? s.UnShelveTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", InSales = s.InSales }); resultModel.result = list; resultModel.Total = shopSaleBLL.Count(where); } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }