public JsonResult BindUser(string username, string password, string headimgurl, string serviceProvider, string openId, Entities.MemberOpenIdInfo.AppIdTypeEnum appidtype = Entities.MemberOpenIdInfo.AppIdTypeEnum.Normal, string unionid = null, string sex = null, string city = null, string province = null, string country = null, string nickName = null) { var service = _iMemberService; var member = service.Login(username, password); if (member == null) { throw new Mall.Core.MallException("用户名和密码不匹配"); } //Log.Debug("BindUser unionid=" + (string.IsNullOrWhiteSpace(unionid) ? "null" : unionid)); headimgurl = System.Web.HttpUtility.UrlDecode(headimgurl); nickName = System.Web.HttpUtility.UrlDecode(nickName); city = System.Web.HttpUtility.UrlDecode(city); province = System.Web.HttpUtility.UrlDecode(province); OAuthUserModel model = new OAuthUserModel() { AppIdType = appidtype, UserId = member.Id, LoginProvider = serviceProvider, OpenId = openId, Headimgurl = headimgurl, UnionId = unionid, Sex = sex, NickName = nickName, City = city, Province = province }; service.BindMember(model); base.SetUserLoginCookie(member.Id); WebHelper.SetCookie(CookieKeysCollection.Mall_ACTIVELOGOUT, "0", DateTime.MaxValue); SellerLoginIn(username, password); BizAfterLogin.Run(member.Id);//执行登录后初始化相关操作 return(Json(new { success = true })); }
public JsonResult Index(string serviceProvider, string openId, string username, string password, string checkCode, string mobilecheckCode, string headimgurl, long introducer = 0, string unionid = null, string sex = null, string city = null, string province = null, string country = null, string nickName = null, string email = "", string emailcheckCode = "") { var mobilepluginId = "Himall.Plugin.Message.SMS"; var emailpluginId = "Himall.Plugin.Message.Email"; string systemCheckCode = Session[CHECK_CODE_KEY] as string; if (systemCheckCode.ToLower() != checkCode.ToLower()) { throw new Core.HimallException("验证码错误"); } if (Core.Helper.ValidateHelper.IsMobile(username)) { var cache = CacheKeyCollection.MemberPluginCheck(username, mobilepluginId); var cacheCode = Core.Cache.Get <string>(cache); if (string.IsNullOrEmpty(mobilecheckCode) || mobilecheckCode.ToLower() != cacheCode.ToLower()) { throw new Core.HimallException("手机验证码错误"); } } if (!string.IsNullOrEmpty(email) && Core.Helper.ValidateHelper.IsMobile(email)) { var cache = CacheKeyCollection.MemberPluginCheck(username, emailpluginId); var cacheCode = Core.Cache.Get <string>(cache); if (string.IsNullOrEmpty(emailcheckCode) || emailcheckCode.ToLower() != cacheCode.ToLower()) { throw new Core.HimallException("手机验证码错误"); } } headimgurl = System.Web.HttpUtility.UrlDecode(headimgurl); nickName = System.Web.HttpUtility.UrlDecode(nickName); province = System.Web.HttpUtility.UrlDecode(province); city = System.Web.HttpUtility.UrlDecode(city); Entities.MemberInfo member; var mobile = ""; if (Core.Helper.ValidateHelper.IsMobile(username)) { mobile = username; } var platform = PlatformType.GetHashCode();//注册终端来源 if (!string.IsNullOrWhiteSpace(serviceProvider) && !string.IsNullOrWhiteSpace(openId)) { OAuthUserModel userModel = new OAuthUserModel { UserName = username, Password = password, LoginProvider = serviceProvider, OpenId = openId, Headimgurl = headimgurl, Sex = sex, NickName = nickName, Email = email, UnionId = unionid, introducer = introducer, Province = province, City = city, Platform = platform, SpreadId = CurrentSpreadId }; member = _iMemberService.Register(userModel); } else { member = _iMemberService.Register(username, password, platform, mobile, email, introducer, spreadId: CurrentSpreadId); } if (member != null) { Session.Remove(CHECK_CODE_KEY); MessageHelper helper = new MessageHelper(); helper.ClearErrorTimes(member.UserName); if (!string.IsNullOrEmpty(email)) { helper.ClearErrorTimes(member.Email); } ClearDistributionSpreadCookie(); } //TODO:ZJT 在用户注册的时候,检查此用户是否存在OpenId是否存在红包,存在则添加到用户预存款里 _iBonusService.DepositToRegister(member.Id); //用户注册的时候,检查是否开启注册领取优惠券活动,存在自动添加到用户预存款里 int num = CouponApplication.RegisterSendCoupon(member.Id, member.UserName); base.SetUserLoginCookie(member.Id); Application.MemberApplication.UpdateLastLoginDate(member.Id); _iMemberService.AddIntegel(member); //给用户加积分//执行登录后初始化相关操作 return(Json <dynamic>(success: true, data: new { memberId = member.Id, num = num })); }
public static void BindMember(OAuthUserModel model) { _iMemberService.BindMember(model); }
/// <summary> /// 注册并绑定一个会员(传model) /// </summary> /// <param name="model"></param> /// <returns></returns> public static UserMemberInfo Register(OAuthUserModel model) { return(_iMemberService.Register(model)); }