/// <summary> /// 获取客服电话 /// </summary> /// <param name="context"></param> //public JsonResult<Result<dynamic>> GetServicePhone() //{ // var siteSettings = SiteSettingApplication.SiteSettings; // return JsonResult<dynamic>(new // { // ServicePhone = siteSettings.SitePhone // }); //} /// <summary> /// 获取首页数据 /// </summary> /// <param name="openId"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> //public JsonResult<Result<dynamic>> GetIndexData(string openId = "", int pageIndex = 10, int pageSize = 1) //{ // //CheckUserLogin(); // MemberInfo member = CurrentUser; // var sitesetting = SiteSettingApplication.SiteSettings; // string homejson = Request.RequestUri.Scheme + "://" + Request.RequestUri.Authority + "/AppletHome/data/default.json"; // long vidnumber = sitesetting.XcxHomeVersionCode; // return JsonResult<dynamic>(new // { // HomeTopicPath = homejson, // Vid = vidnumber, // QQMapKey = CommonConst.QQMapKey // }); //} /// <summary> /// 检查版本号 /// </summary> /// <param name="context"></param> //public JsonResult<Result<int>> GetInitVeCode(string vid) //{ // if (string.IsNullOrEmpty(vid)) // { // return Json(ErrorResult<int>("版本号不允许为空", 100, 100)); // } // var sitesetting = SiteSettingApplication.SiteSettings; // long xcxvid = sitesetting.XcxHomeVersionCode; // if (xcxvid > long.Parse(vid)) // { // return Json(ErrorResult("版本需要更新", 101, 101)); // } // else // { // return JsonResult(100, "版本不需要更新", 100); // } //} //public JsonResult<Result<List<dynamic>>> GetIndexProductData(string openId = "", int pageIndex = 1, int pageSize = 10) //{ // var homeProducts = ServiceProvider.Instance<IWXSmallProgramService>.Create.GetWXSmallHomeProducts(pageIndex,pageSize); // decimal discount = 1M; // long SelfShopId = 0; // var CartInfo = new ShoppingCartInfo(); // var ids = homeProducts.Models.Select(p => p.Id).ToList(); // var productList = new List<dynamic>(); // var cartitems = new List<Himall.Entities.ShoppingCartItem>(); // long userId = 0; // if (CurrentUser != null) // { // userId = CurrentUser.Id; // discount = CurrentUser.MemberDiscount; // var shopInfo = ShopApplication.GetSelfShop(); // SelfShopId = shopInfo.Id; // CartInfo = ServiceProvider.Instance<ICartService>.Create.GetCart(CurrentUser.Id); // cartitems = CartApplication.GetCartQuantityByIds(CurrentUser.Id, ids); // } // foreach (var item in homeProducts.Models) // { // long activeId = 0; // int activetype = 0; // item.ImagePath = HimallIO.GetRomoteProductSizeImage(Core.HimallIO.GetImagePath(item.ImagePath), 1, (int)Himall.CommonModel.ImageSize.Size_350); // if (item.ShopId == SelfShopId) // item.MinSalePrice = item.MinSalePrice * discount; // var limitBuy = ServiceProvider.Instance<ILimitTimeBuyService>.Create.GetLimitTimeMarketItemByProductId(item.Id); // if (limitBuy != null) // { // item.MinSalePrice = limitBuy.MinPrice; // activeId = limitBuy.Id; // activetype = 1; // } // int quantity = 0; // quantity = cartitems.Where(d => d.ProductId == item.Id).Sum(d => d.Quantity); // long stock = 0; // var productInfo = ServiceProvider.Instance<IProductService>.Create.GetProduct(item.Id); // if (productInfo != null) // { // var skus = ProductManagerApplication.GetSKUs(productInfo.Id); // stock = skus.Sum(x => x.Stock); // if (productInfo.MaxBuyCount > 0) // { // stock = productInfo.MaxBuyCount; // } // } // if (productInfo.AuditStatus == ProductInfo.ProductAuditStatus.Audited) // { // var ChoiceProducts = new // { // ProductId = item.Id, // ProductName = item.ProductName, // SalePrice = item.MinSalePrice.ToString("0.##"), // ThumbnailUrl160 = item.ImagePath, // MarketPrice = item.MarketPrice.ToString("0.##"), // CartQuantity = quantity, // HasSKU = item.HasSKU, // SkuId = GetSkuIdByProductId(item.Id), // ActiveId = activeId, // ActiveType = activetype,//获取该商品是否参与活动 // Stock = stock // }; // productList.Add(ChoiceProducts); // } // } // return JsonResult(productList); //} private JsonResult <Result <dynamic> > GetMember(Entities.MemberInfo member, string openId) { var model = MemberApplication.GetUserCenterModel(member.Id, false); //获取会员未使用的优惠券数目 int couponsCount = model.UserCoupon; return(JsonResult <dynamic>(new { couponsCount = couponsCount, picture = HimallIO.GetRomoteImagePath(member.Photo), points = model.Intergral, waitPayCount = model.WaitPayOrders, waitSendCount = model.WaitDeliveryOrders, waitFinishCount = model.WaitReceivingOrders, waitReviewCount = model.WaitEvaluationOrders, afterSalesCount = model.RefundCount, realName = string.IsNullOrEmpty(member.ShowNick) ? (string.IsNullOrEmpty(member.RealName) ? member.UserName : member.RealName) : member.ShowNick, gradeId = model.GradeId, gradeName = model.GradeName, UserName = member.UserName, UserId = member.Id, OpenId = openId, ServicePhone = SiteSettingApplication.SiteSettings.SitePhone })); }
public ActionResult OauthCallBack(string oauthId) { try { var oauthPlugin = Core.PluginsManagement.GetPlugin <IOAuthPlugin>(oauthId); var oauthInfo = oauthPlugin.Biz.GetUserInfo(Request.QueryString); Entities.MemberInfo member = null; if (oauthId.Equals("Himall.Plugin.OAuth.Weibo")) { if (!string.IsNullOrEmpty(oauthInfo.OpenId)) { //微博查询是否该OpenId对应的用户已经存在 member = _iMemberService.GetMemberByOpenId(oauthId, oauthInfo.OpenId); } } else { if (!string.IsNullOrWhiteSpace(oauthInfo.UnionId))//检查是否正确返回OpenId { //查询是否该UnionId对应的用户已经存在 member = _iMemberService.GetMemberByUnionId(oauthId, oauthInfo.UnionId); } } if (member != null) {//存在,则直接登录 SellerLoginIn(member.UserName, member.Password); base.SetUserLoginCookie(member.Id); Application.MemberApplication.UpdateLastLoginDate(member.Id); BizAfterLogin.Run(member.Id);//执行登录后初始化相关操作 return(Redirect("/")); } else { if (!string.IsNullOrWhiteSpace(oauthInfo.OpenId)) {//扫码登录 string url = string.Format("/Login/BindUser?oauthId={0}&openId={1}&name={2}&unionid={3}&unionopenid={4}", oauthId, oauthInfo.OpenId, oauthInfo.NickName, oauthInfo.UnionId, oauthInfo.OpenId); return(Redirect(url)); } } ViewBag.Keyword = SiteSettings.Keyword; return(View()); } catch (Exception ex)//出异常(包括取消后回调,直接返回到登录页) { Log.Error(ex.ToString()); return(Content(string.Format("<script type=\"text/javascript\">window.location.href = '{0}'; window.close();</script>", "/login"))); } }
protected override object OnCheckCheckCodeSuccess(string contact) { CheckUserLogin(); string pluginId = PluginsManagement.GetInstalledPluginInfos(Core.Plugins.PluginType.SMS).First().PluginId; var _iMemberIntegralConversionFactoryService = ServiceProvider.Instance <IMemberIntegralConversionFactoryService> .Create; var _iMemberIntegralService = ServiceProvider.Instance <IMemberIntegralService> .Create; var _iMemberInviteService = ServiceProvider.Instance <IMemberInviteService> .Create; var member = CurrentUser; if (Application.MessageApplication.GetMemberContactsInfo(pluginId, contact, Entities.MemberContactInfo.UserTypes.General) != null) { return(new { success = false, msg = contact + "已经绑定过了!" }); } member.CellPhone = contact; MemberApplication.UpdateMember(member.Map <DTO.Members>()); Application.MessageApplication.UpdateMemberContacts(new Entities.MemberContactInfo() { Contact = contact, ServiceProvider = pluginId, UserId = CurrentUser.Id, UserType = Entities.MemberContactInfo.UserTypes.General }); Core.Cache.Remove(CacheKeyCollection.MemberPluginCheck(CurrentUser.UserName, pluginId)); Core.Cache.Remove(CacheKeyCollection.Member(CurrentUser.Id));//移除用户缓存 Core.Cache.Remove("Rebind" + CurrentUser.Id); Entities.MemberInfo inviteMember = MemberApplication.GetMember(member.InviteUserId); var info = new MemberIntegralRecordInfo(); info.UserName = member.UserName; info.MemberId = member.Id; info.RecordDate = DateTime.Now; info.TypeId = MemberIntegralInfo.IntegralType.Reg; info.ReMark = "绑定手机"; var memberIntegral = _iMemberIntegralConversionFactoryService.Create(Himall.Entities.MemberIntegralInfo.IntegralType.Reg); _iMemberIntegralService.AddMemberIntegral(info, memberIntegral); if (inviteMember != null) { _iMemberInviteService.AddInviteIntegel(member, inviteMember, true); } return(base.OnCheckCheckCodeSuccess(contact)); }
/// <summary> /// 获取首页数据 /// </summary> /// <param name="openId"></param> /// <returns></returns> public JsonResult <Result <dynamic> > GetIndexData(string openId = "") { //CheckUserLogin(); Entities.MemberInfo member = CurrentUser; var sitesetting = SiteSettingApplication.SiteSettings; string homejson = Request.RequestUri.Scheme + "://" + Request.RequestUri.Authority + "/AppletHome/data/default.json"; long vidnumber = sitesetting.XcxHomeVersionCode; return(JsonResult <dynamic>(new { HomeTopicPath = homejson, Vid = vidnumber, QQMapKey = CommonConst.QQMapKey })); }
/// <summary> /// 写入登录cookie /// </summary> /// <param name="member"></param> private void WriteLogin(Entities.MemberInfo member) { if (member != null) { base.SetUserLoginCookie(member.Id, DateTime.MaxValue); Core.Helper.WebHelper.SetCookie(CookieKeysCollection.HIMALL_ACTIVELOGOUT, "0", DateTime.MaxValue); var sell = ManagerApplication.GetSellerManager(member.UserName); if (sell != null) { base.SetSellerAdminLoginCookie(sell.Id, DateTime.MaxValue); } else { //多个账号切换时,商家之前登录的cookie可能没有清除掉,当当前账号不存在时再清除下 Core.Helper.WebHelper.DeleteCookie(CookieKeysCollection.SELLER_MANAGER); } } }
public JsonResult Skip(string serviceProvider, string openId, string nickName, string realName, string headimgurl, Entities.MemberOpenIdInfo.AppIdTypeEnum appidtype = Entities.MemberOpenIdInfo.AppIdTypeEnum.Normal, string unionid = null, string sex = null, string city = null, string province = null) { int num = 0; string username = DateTime.Now.ToString("yyMMddHHmmssffffff"); //TODO:DZY[150916]未使用,在方法内会重新生成 nickName = System.Web.HttpUtility.UrlDecode(nickName); realName = System.Web.HttpUtility.UrlDecode(realName); headimgurl = System.Web.HttpUtility.UrlDecode(headimgurl); province = System.Web.HttpUtility.UrlDecode(province); city = System.Web.HttpUtility.UrlDecode(city); Entities.MemberInfo memberInfo = _iMemberService.GetMemberByUnionIdOpenId(unionid, openId); if (memberInfo == null) { memberInfo = _iMemberService.QuickRegister(username, realName, nickName, serviceProvider, openId, PlatformType.GetHashCode(), unionid, sex, headimgurl, appidtype, null, city, province, spreadId: CurrentSpreadId); //TODO:ZJT 在用户注册的时候,检查此用户是否存在OpenId是否存在红包,存在则添加到用户预存款里 _iBonusService.DepositToRegister(memberInfo.Id); //用户注册的时候,检查是否开启注册领取优惠券活动,存在自动添加到用户预存款里 if (memberInfo.IsNewAccount) { num = CouponApplication.RegisterSendCoupon(memberInfo.Id, memberInfo.UserName); } ClearDistributionSpreadCookie(); _iMemberService.AddIntegel(memberInfo); //给用户加积分//执行登录后初始化相关操作 } base.SetUserLoginCookie(memberInfo.Id); Application.MemberApplication.UpdateLastLoginDate(memberInfo.Id); WebHelper.SetCookie(CookieKeysCollection.HIMALL_ACTIVELOGOUT, "0", DateTime.MaxValue); #region 判断是否强制绑定手机号 MemberApplication.UpdateLastLoginDate(memberInfo.Id); var isBind = MessageApplication.IsOpenBindSms(memberInfo.Id); if (!isBind) { return(Json <dynamic>(success: false, data: new { num = num }, code: 99)); } #endregion return(Json <dynamic>(success: true, data: new { num = num })); }
private user_list_model UserMemberInfoMapDTO(Entities.MemberInfo data) { user_list_model result = null; if (data != null) { result = new user_list_model(); var ui = MemberIntegralApplication.GetMemberIntegral(data.Id); if (ui == null) { ui = new Himall.Entities.MemberIntegralInfo { MemberId = data.Id, AvailableIntegrals = 0, HistoryIntegrals = 0 }; } result.uid = (int)data.Id; result.user_name = data.UserName; result.created = data.CreateDate; result.real_name = data.RealName; result.mobile = data.CellPhone; result.email = data.Email; result.avatar = Himall.Core.HimallIO.GetRomoteImagePath(data.Photo); result.sex = data.Sex.ToDescription(); result.birthday = data.BirthDay; result.state = ""; result.city = ""; result.district = ""; result.town = ""; result.address = ""; result.points = ui.AvailableIntegrals; result.trade_count = data.OrderNumber; result.trade_amount = data.NetAmount; } return(result); }
/// <summary> /// 为已登录过的用户(存在cookie),绑定OpenId /// </summary> /// <param name="filterContext"></param> /// <returns></returns> bool BindOpenIdToUser(ActionExecutingContext filterContext) { bool end = true; //处理手动退出后不自动登录 string actlogout = WebHelper.GetCookie(CookieKeysCollection.Mall_ACTIVELOGOUT); //分析当前平台类型,并创建对应的登录接口 IMobileOAuth imobileOauth = null; switch (PlatformType) { case Core.PlatformType.WeiXin: imobileOauth = new WeixinOAuth(); break; } string normalLoginUrl = string.Format("/m-{0}/Login/Entrance?returnUrl={1}", PlatformType.ToString(), WebUtility.UrlEncode(filterContext.HttpContext.Request.Headers["Referer"].ToString())); if (imobileOauth != null && GetRequestType(filterContext.HttpContext.Request) == Core.PlatformType.WeiXin)//找到了支持的登录接口 { //可能的待跳转用户授权地址 string redirectUrl; //string strShopid = WebHelper.GetCookie(CookieKeysCollection.Mall_SHOP); //long shopid = string.IsNullOrEmpty(strShopid) ? 0 : UserCookieEncryptHelper.Decrypt(strShopid, "Mobile"); var settings = new Entities.WXshopInfo(); string strShopid = filterContext.HttpContext.Request.Query["shop"].ToString(); var AppidType = Entities.MemberOpenIdInfo.AppIdTypeEnum.Normal; if (!string.IsNullOrEmpty(strShopid)) { Log.Warn(strShopid + ":" + filterContext.HttpContext.Request.Headers["Referer"].ToString()); long shopid = 0; bool isLong = long.TryParse(strShopid, out shopid); if (shopid > 0) { settings = VshopApplication.GetVShopSetting(shopid); } } else { Log.Warn(filterContext.HttpContext.Request.Headers["Referer"].ToString()); } if (string.IsNullOrEmpty(settings.AppId) || string.IsNullOrEmpty(settings.AppSecret)) { settings = new Entities.WXshopInfo() { AppId = SiteSettings.WeixinAppId, AppSecret = SiteSettings.WeixinAppSecret, Token = SiteSettings.WeixinToken }; AppidType = Entities.MemberOpenIdInfo.AppIdTypeEnum.Payment;//是平台Appid,可以作为付款(微信支付) } //获取当前用户信息 var userInfo = imobileOauth.GetUserInfo_bequiet(filterContext, out redirectUrl, settings); if (string.IsNullOrWhiteSpace(redirectUrl)) //待跳转地址为空,说明已经经过了用户授权页面 { end = false; //不再中断当前action if (userInfo != null && !string.IsNullOrWhiteSpace(userInfo.OpenId)) //用户信息不为空并且OpenId不为空,说明用户已经授权 { if (AppidType == Entities.MemberOpenIdInfo.AppIdTypeEnum.Payment) {//记录平台公众号对应的OpenId var curMenberOpenId = Core.Helper.SecureHelper.AESEncrypt(userInfo.OpenId, "Mobile"); WebHelper.SetCookie(CookieKeysCollection.Mall_USER_OpenID, curMenberOpenId); } //Mall.Core.Log.Debug("BindOpenIdToUser LoginProvider=" + userInfo.LoginProvider); //Mall.Core.Log.Debug("BindOpenIdToUser OpenId=" + userInfo.OpenId); //Mall.Core.Log.Debug("BindOpenIdToUser UnionId=" + userInfo.UnionId); //检查是否已经有用户绑定过该OpenId Entities.MemberInfo existUser = null; //existUser = member.GetMemberByUnionId(userInfo.LoginProvider, userInfo.UnionId); if (existUser == null) { if (actlogout != "1") { //existUser = member.GetMemberByOpenId(userInfo.LoginProvider, userInfo.OpenId); existUser = MemberApplication.GetMemberByUnionId(userInfo.UnionId); } } if (existUser != null) { #region 如它已冻结了则直接跳到登录页 if (existUser.Disabled) { var result = Redirect(normalLoginUrl); end = false; return(end); } #endregion if (!string.IsNullOrEmpty(strShopid)) { base.SetUserLoginCookie(existUser.Id); Application.MemberApplication.UpdateLastLoginDate(existUser.Id); } } else//未绑定过,则绑定当前用户 { MemberApplication.BindMember(CurrentUser.Id, "Mall.Plugin.OAuth.WeiXin", userInfo.OpenId, AppidType, userInfo.Sex, userInfo.Headimgurl, unionid: userInfo.UnionId); //end = false;//不再中断当前action } } } else {//立即跳转到用户授权页面 var result = Redirect(redirectUrl); filterContext.Result = result; } } else { end = false; } return(end); }
/// <summary> /// 处理普通页面请求的情况 /// </summary> /// <param name="filterContext"></param> /// <returns>是否中断当前action提前结束</returns> bool ProcessInvalidUser_NormalRequest(ActionExecutingContext filterContext) { bool end = true; //处理手动退出后不自动登录 string actlogout = WebHelper.GetCookie(CookieKeysCollection.Mall_ACTIVELOGOUT); //分析当前平台类型,并创建对应的登录接口 IMobileOAuth imobileOauth = null; switch (PlatformType) { case Core.PlatformType.WeiXin: imobileOauth = new WeixinOAuth(); break; } string normalLoginUrl = string.Format("/m-{0}/Login/Entrance?returnUrl={1}", PlatformType.ToString(), WebUtility.UrlEncode(filterContext.HttpContext.Request.GetDisplayUrl().ToString())); if (imobileOauth != null && GetRequestType(filterContext.HttpContext.Request) == Core.PlatformType.WeiXin)//找到了支持的登录接口 { //可能的待跳转用户授权地址 var settings = new Entities.WXshopInfo(); string redirectUrl; //string strShopid = WebHelper.GetCookie(CookieKeysCollection.Mall_SHOP); //long shopid = string.IsNullOrEmpty(strShopid) ? 0 : UserCookieEncryptHelper.Decrypt(strShopid, "Mobile"); string strShopid = filterContext.HttpContext.Request.Query["shop"].ToString(); var AppidType = MemberOpenIdInfo.AppIdTypeEnum.Normal; if (!string.IsNullOrEmpty(strShopid)) { long shopid = 0; bool isLong = long.TryParse(strShopid, out shopid); if (shopid > 0) { settings = VshopApplication.GetVShopSetting(shopid); } } if (string.IsNullOrEmpty(settings.AppId) || string.IsNullOrEmpty(settings.AppSecret)) { settings = new Entities.WXshopInfo() { AppId = SiteSettings.WeixinAppId, AppSecret = SiteSettings.WeixinAppSecret, Token = SiteSettings.WeixinToken }; AppidType = MemberOpenIdInfo.AppIdTypeEnum.Payment;//是平台Appid,可以作为付款(微信支付) } //获取当前用户信息 var userInfo = imobileOauth.GetUserInfo(filterContext, out redirectUrl, settings); if (string.IsNullOrWhiteSpace(redirectUrl)) //待跳转地址为空,说明已经经过了用户授权页面 { if (userInfo != null && !string.IsNullOrWhiteSpace(userInfo.OpenId)) //用户信息不为空并且OpenId不为空,说明用户已经授权 { if (AppidType == MemberOpenIdInfo.AppIdTypeEnum.Payment) { var curMenberOpenId = Core.Helper.SecureHelper.AESEncrypt(userInfo.OpenId, "Mobile"); WebHelper.SetCookie(CookieKeysCollection.Mall_USER_OpenID, curMenberOpenId); } //检查是否已经有用户绑定过该OpenId //Mall.Core.Log.Debug("InvalidUser LoginProvider=" + userInfo.LoginProvider); //Mall.Core.Log.Debug("InvalidUser OpenId=" + userInfo.OpenId); //Mall.Core.Log.Debug("InvalidUser UnionId=" + userInfo.UnionId); Entities.MemberInfo existUser = null; //existUser = ServiceHelper.Create<IMemberService>().GetMemberByUnionId(userInfo.LoginProvider, userInfo.UnionId); if (existUser == null) { if (actlogout != "1") { //existUser = ServiceHelper.Create<IMemberService>().GetMemberByOpenId(userInfo.LoginProvider, userInfo.OpenId); existUser = MemberApplication.GetMemberByUnionId(userInfo.UnionId); } } if (existUser != null)//已经有用户绑定过,直接标识为该用户 { #region 如它已冻结了则直接跳到登录页 if (existUser.Disabled) { var result = Redirect(normalLoginUrl); end = false; return(end); } #endregion base.SetUserLoginCookie(existUser.Id); Application.MemberApplication.UpdateLastLoginDate(existUser.Id); var isBind = MessageApplication.IsOpenBindSms(existUser.Id); if (!isBind) { var result = Redirect(string.Format("/m-{0}/Member/BindPhone", PlatformType.ToString())); filterContext.Result = result; } } else//未绑定过,则跳转至登录绑定页面 { normalLoginUrl = string.Format("/m-{0}/Login/Entrance?openId={1}&serviceProvider={2}&nickName={3}&realName={4}&headimgurl={5}&returnUrl={6}&AppidType={7}&unionid={8}&sex={9}&city={10}&province={11}&country={12}", PlatformType.ToString(), userInfo.OpenId, "Mall.Plugin.OAuth.WeiXin",//使用同微信登录插件一致的名称, 以此保证微信信任与微信商城登录用户信息统一 WebUtility.UrlEncode(userInfo.NickName), WebUtility.UrlEncode(userInfo.RealName), WebUtility.UrlEncode(userInfo.Headimgurl), WebUtility.UrlEncode(filterContext.HttpContext.Request.Headers["Referer"].ToString()), AppidType, userInfo.UnionId, userInfo.Sex, userInfo.City, userInfo.Province, userInfo.Country ); //跳转至登录绑定页面 var result = Redirect(normalLoginUrl); filterContext.Result = result; } } else//用户未授权,或者无法获取用户授权 { //用户未授权,则跳转至普通登录页面 var result = Redirect(normalLoginUrl); filterContext.Result = result; } } else {//立即跳转到用户授权页面 var result = Redirect(redirectUrl); filterContext.Result = result; } } else {//未找到对应的用户授权实现机制,则跳转至普通登录页面 var result = Redirect(normalLoginUrl); filterContext.Result = result; } return(end); }
public object GetUser(string userName = "", string password = "", string oauthType = "", string oauthOpenId = "", string unionid = "", string headimgurl = "", string oauthNickName = "", int?sex = null, string city = "", string province = "") { dynamic data = new System.Dynamic.ExpandoObject(); //信任登录 if (!string.IsNullOrEmpty(oauthType) && (!string.IsNullOrEmpty(unionid) || !string.IsNullOrEmpty(oauthOpenId)) && string.IsNullOrEmpty(userName) && string.IsNullOrEmpty(password)) { Log.Debug(string.Format("oauthType={0} openId={1} unionid={2} userName={3}", oauthType, oauthOpenId, unionid, userName)); var member = Application.MemberApplication.GetMemberByUnionIdAndProvider(oauthType, unionid); if (member == null) { member = Application.MemberApplication.GetMemberByOpenId(oauthType, oauthOpenId); } if (member != null) { if (member.Disabled) { data = ErrorResult("用户已被冻结", 105); } else { //信任登录并且已绑定 data.success = true; data.UserId = member.Id.ToString(); string memberId = UserCookieEncryptHelper.Encrypt(member.Id, CookieKeysCollection.USERROLE_USER); data.UserKey = memberId; } } else { data = ErrorResult("未绑定商城帐号", 104); } } //普通登录 if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password) && string.IsNullOrEmpty(oauthType) && string.IsNullOrEmpty(unionid) && string.IsNullOrEmpty(oauthOpenId)) { Entities.MemberInfo member = null; try { member = ServiceProvider.Instance <IMemberService> .Create.Login(userName, password); } catch (Exception ex) { data = ErrorResult(ex.Message, 104); return(data); } if (member == null) { data = ErrorResult("用户名或密码错误", 103); } else if (member != null && member.Disabled) { data = ErrorResult("用户已被冻结", 105); } else { data.success = true; data.UserId = member.Id.ToString(); string memberId = UserCookieEncryptHelper.Encrypt(member.Id, CookieKeysCollection.USERROLE_USER); data.UserKey = memberId; } } //绑定 if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(oauthType) && (!string.IsNullOrEmpty(unionid) || !string.IsNullOrEmpty(oauthOpenId))) { var service = ServiceProvider.Instance <IMemberService> .Create; var member = service.Login(userName, password); if (member == null) { data = ErrorResult("用户名或密码错误", 103); } else if (member != null && member.Disabled) { data = ErrorResult("用户已被冻结", 105); } else { string wxsex = null; if (null != sex) { wxsex = sex.Value.ToString(); } province = System.Web.HttpUtility.UrlDecode(province); city = System.Web.HttpUtility.UrlDecode(city); service.BindMember(member.Id, oauthType, oauthOpenId, wxsex, headimgurl, unionid, null, city, province); string memberId = UserCookieEncryptHelper.Encrypt(member.Id, CookieKeysCollection.USERROLE_USER); data.success = true; data.UserId = member.Id; data.UserKey = memberId; } } return(data); }