/// <summary> /// 用户信息页面 /// add by fruitchan /// 2017-2-9 18:37:39 /// </summary> /// <returns>View</returns> public ActionResult UserInfo() { UserInfoExtView userInfo = null; UserInfoView user = ViewBag.UserInfo as UserInfoView; if (user != null) { userInfo = OperateContext.Current.BLLSession.IUserInfoExtViewBLL.GetListBy(m => m.ID == user.ID).FirstOrDefault(); ViewBag.UserInfoCertificate = OperateContext.Current.BLLSession.IUserInfoCertificateBLL.GetListBy(m => m.UserInfoID == user.ID).OrderByDescending(m => m.CreateTime).FirstOrDefault(); } return(View(userInfo)); }
/// <summary> /// 查看房东信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult LandlordInfoView(int?id) { UserInfoExtView userinfo = null; if (id.HasValue) { userinfo = OperateContext.Current.BLLSession.IUserInfoExtViewBLL.GetListBy(h => h.ID == id).FirstOrDefault(); } if (userinfo == null) { userinfo = new UserInfoExtView(); } return(View(userinfo)); }
/// <summary> /// 创建房东 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult CreateLandlordView(long?id) { UserInfoExtView user = null; if (id.HasValue) { user = OperateContext.Current.BLLSession.IUserInfoExtViewBLL.GetListBy(h => h.ID == id).FirstOrDefault(); } if (user == null) { user = new UserInfoExtView(); } if (string.IsNullOrEmpty(user.LoginPwd)) { user.LoginPwd = Encrypt.GetRdNumber().ToString(); } return(View(user)); }
/// <summary> /// 实名认证 /// add by fruitchan /// 2016-12-24 22:27:11 /// </summary> /// <param name="userInfoExt"></param> /// <returns></returns> public ActionResult SaveUserInfoExt(UserInfoExtView userInfoExt) { string status = "fail"; string msg = null; UserInfoView loginUserInfo = OperateContext.Current.UserInfo; #region 校验数据 if (userInfoExt != null) { if (msg == null) { // 真实姓名 msg = Validate.ValidateString(new CustomValidate { FieldName = "真实姓名", FieldValue = userInfoExt.Username, IsRequired = true, MaxLength = 20, MinLength = 2 }); } if (msg == null) { // 身份证号 msg = Validate.ValidateString(new CustomValidate { FieldName = "身份证号", FieldValue = userInfoExt.IDCardNo, IsIdCard = true }); } if (msg == null) { // 身份证正面照 msg = Validate.ValidateString(new CustomValidate { FieldName = "身份证正面照", FieldValue = userInfoExt.IDCardImg1, IsRequired = true, MaxLength = 200 }); } if (msg == null) { // 身份证背面照 msg = Validate.ValidateString(new CustomValidate { FieldName = "身份证背面照", FieldValue = userInfoExt.IDCardImg2, IsRequired = true, MaxLength = 200 }); } if (msg == null) { // 支付宝账号 msg = Validate.ValidateString(new CustomValidate { FieldName = "支付宝账号", FieldValue = userInfoExt.AlipayAccount, IsRequired = true, MaxLength = 40 }); } if (msg == null) { // 微信账号 msg = Validate.ValidateString(new CustomValidate { FieldName = "微信账号", FieldValue = userInfoExt.WeixinAccount, IsRequired = true, MaxLength = 40 }); } if (msg == null) { // 房源地址 msg = Validate.ValidateString(new CustomValidate { FieldName = "房源地址", FieldValue = userInfoExt.HouseAddress, IsRequired = true, MaxLength = 200 }); } if (msg == null) { // 房产证照 msg = Validate.ValidateString(new CustomValidate { FieldName = "房产证照", FieldValue = userInfoExt.Housecertificate, IsRequired = true, MaxLength = 200 }); } } else { msg = "请求数据错误!"; } #endregion if (msg == null) { // 用户信息 int result = OperateContext.Current.BLLSession.IUserInfoBLL.Modify(new UserInfo() { ID = loginUserInfo.ID, Username = userInfoExt.Username, IDCardNo = userInfoExt.IDCardNo, }, "Username", "IDCardNo"); // 扩展信息 if (result == 1) { UserInfoExt oldUserInfoExt = OperateContext.Current.BLLSession.IUserInfoExtBLL.GetListBy(m => m.UserInfoID == loginUserInfo.ID).FirstOrDefault(); if (oldUserInfoExt != null) { // 修改 oldUserInfoExt.IDCardImg1 = userInfoExt.IDCardImg1; oldUserInfoExt.IDCardImg2 = userInfoExt.IDCardImg2; oldUserInfoExt.AlipayAccount = userInfoExt.AlipayAccount; oldUserInfoExt.WeixinAccount = userInfoExt.WeixinAccount; oldUserInfoExt.HouseAddress = userInfoExt.HouseAddress; oldUserInfoExt.Housecertificate = userInfoExt.Housecertificate; result = OperateContext.Current.BLLSession.IUserInfoExtBLL.Modify(oldUserInfoExt, "IDCardImg1", "IDCardImg2", "AlipayAccount", "WeixinAccount", "HouseAddress", "Housecertificate"); } else { // 新增 result = OperateContext.Current.BLLSession.IUserInfoExtBLL.Add(new UserInfoExt() { UserInfoID = loginUserInfo.ID, IsCertification = 0, IDCardImg1 = userInfoExt.IDCardImg1, IDCardImg2 = userInfoExt.IDCardImg2, AlipayAccount = userInfoExt.AlipayAccount, WeixinAccount = userInfoExt.WeixinAccount, HouseAddress = userInfoExt.HouseAddress, Housecertificate = userInfoExt.Housecertificate }); } } // 提交认证 if (result == 1) { result = OperateContext.Current.BLLSession.IUserInfoCertificateBLL.Add(new UserInfoCertificate() { UserInfoID = loginUserInfo.ID, State = 0, CreateTime = DateTime.Now }); } if (result == 1) { // 更新缓存 OperateContext.Current.UserInfo = OperateContext.Current.BLLSession.IUserInfoViewBLL.GetListBy(m => m.ID == loginUserInfo.ID).FirstOrDefault(); status = "ok"; msg = "提交认证申请成功,我们会尽快审核!"; } else { msg = "系统繁忙,请稍后再试!"; } } return(OperateContext.Current.RedirectAjax(status, msg, null, null)); }
public ActionResult SaveLandlord(UserInfoExtView model) { string status = "fail"; string msg = "保存失败!"; if (model != null) { msg = Validate.ValidateString(new CustomValidate { FieldName = "真实姓名", FieldValue = model.Username, IsRequired = true, MaxLength = 100 }, new CustomValidate { FieldName = "登录账号", FieldValue = model.LoginAccount, IsRequired = true }, new CustomValidate { FieldName = "登录密码", FieldValue = model.LoginPwd, IsRequired = true }, new CustomValidate { FieldName = "手机号码", FieldValue = model.PhoneNo, IsRequired = true, IsPhone = true }); //验证备用手机号码 if (msg == null && !string.IsNullOrEmpty(model.PhoneNo2) && !Validate.ValidatePhone(model.PhoneNo2)) { msg = "备注手机号码格式不正确"; } else if (msg == null && !string.IsNullOrEmpty(model.Email) && !Validate.ValidateEmail(model.Email)) { msg = "邮箱格式不正确"; } //验证账号是否重复 var queryObj = OperateContext.Current.BLLSession.IUserInfoBLL.GetListBy(h => h.LoginAccount == model.LoginAccount && h.ID != model.ID).FirstOrDefault(); if (queryObj != null) { msg = "登录账号已经存在!请重新填写。"; } if (msg == null) { if (model.ID > 0) //修改 { var modifyUser = OperateContext.Current.BLLSession.IUserInfoBLL.GetListBy(h => h.ID == model.ID).FirstOrDefault(); modifyUser.Img = model.Img; modifyUser.Nikename = string.IsNullOrEmpty(model.Nikename) ? modifyUser.Nikename : model.Nikename; modifyUser.Username = model.Username; modifyUser.Gender = model.Gender; modifyUser.PhoneNo = model.PhoneNo; modifyUser.PhoneNo2 = model.PhoneNo2; modifyUser.UserType = 2; modifyUser.Email = model.Email; modifyUser.IDCardNo = model.IDCardNo; modifyUser.LoginAccount = model.LoginAccount; var result = OperateContext.Current.BLLSession.IUserInfoBLL.Modify(modifyUser); var userAccount = OperateContext.Current.BLLSession.IUserAccountBLL.GetListBy(h => h.ID == modifyUser.AccountID).FirstOrDefault(); userAccount.PhoneAccount = modifyUser.PhoneNo; OperateContext.Current.BLLSession.IUserAccountBLL.Modify(userAccount); var userExt = OperateContext.Current.BLLSession.IUserInfoExtBLL.GetListBy(h => h.UserInfoID == modifyUser.ID).FirstOrDefault(); if (userExt != null) { userExt.IDCardImg1 = model.IDCardImg1; userExt.IDCardImg2 = model.IDCardImg2; userExt.HouseAddress = model.HouseAddress; userExt.Housecertificate = model.Housecertificate; userExt.WeixinAccount = model.WeixinAccount; userExt.AlipayAccount = model.AlipayAccount; OperateContext.Current.BLLSession.IUserInfoExtBLL.Modify(userExt); } //编辑权限用户表 var user = OperateContext.Current.BLLSession.IUserBLL.GetListBy(h => h.Id == model.ID).FirstOrDefault(); user.LoginName = model.LoginAccount; user.Password = model.LoginPwd; user.Email = model.Email; var editUserTable = OperateContext.Current.BLLSession.IUserBLL.Add(user); if (result == 1 && editUserTable == 1) { status = "ok"; msg = "保存成功!"; } } else //新增 { //用户账户信息 UserAccount userAccount = new UserAccount { PhoneAccount = model.PhoneNo, State = 0, CreateTime = DateTime.Now }; //用户信息 OperateContext.Current.BLLSession.IUserAccountBLL.Add(userAccount); var newUser = new UserInfo(); newUser.AccountID = userAccount.ID; newUser.Img = model.Img; newUser.Nikename = string.IsNullOrEmpty(model.Nikename) ? "我要去度假用户" + userAccount.ID : model.Nikename; newUser.Username = model.Username; newUser.Gender = model.Gender; newUser.PhoneNo = model.PhoneNo; newUser.PhoneNo2 = model.PhoneNo2; newUser.UserType = 2; newUser.Email = model.Email; newUser.IDCardNo = model.IDCardNo; newUser.CreateTime = DateTime.Now; newUser.LoginAccount = model.LoginAccount; newUser.LoginPwd = Encrypt.MD5Encrypt32(model.LoginPwd.Trim()); var result = OperateContext.Current.BLLSession.IUserInfoBLL.Add(newUser); //添加权限用户表 var user = new User(); user.GUIID = Guid.NewGuid(); user.LoginName = model.LoginAccount; user.Password = Common.Encrypt.MD5Encrypt32(model.LoginPwd); user.IsDeleted = false; user.CreateTime = DateTime.Now; user.Description = "主账户,该账户可以分配子账户以及权限!"; user.Email = model.Email; user.ParentId = -1; user.AccountId = newUser.ID; var addUserTable = OperateContext.Current.BLLSession.IUserBLL.Add(user); //认证信息 //UserInfoCertificate uic = new UserInfoCertificate //{ // UserInfoID = newUser.ID, // State = 0, // CreateTime = DateTime.Now //}; //用户扩展信息 UserInfoExt userExt = new UserInfoExt(); userExt.IsCertification = 1; userExt.UserInfoID = newUser.ID; userExt.IDCardImg1 = model.IDCardImg1; userExt.IDCardImg2 = model.IDCardImg2; userExt.HouseAddress = model.HouseAddress; userExt.Housecertificate = model.Housecertificate; userExt.WeixinAccount = model.WeixinAccount; userExt.AlipayAccount = model.AlipayAccount; OperateContext.Current.BLLSession.IUserInfoExtBLL.Add(userExt); if (result == 1 && addUserTable == 1) { status = "ok"; msg = "保存成功!"; } } } } return(OperateContext.Current.RedirectAjax(status, msg, null, null)); }