/// <summary> /// 发送验证码,认证管理员 /// </summary> /// <param name="pluginId">信息类别</param> /// <param name="destination">联系号码</param> /// <param name="UserName">会员账号</param> /// <param name="SiteName">站点设置</param> /// <returns></returns> public static Himall.CommonModel.SendMemberCodeReturn SendMemberCode(string pluginId, string destination, string UserName, string SiteName) { //判断号码是否绑定 if (MessageApplication.GetMemberContactsInfo(pluginId, destination, Himall.Model.MemberContactsInfo.UserTypes.General) != null) { return(Himall.CommonModel.SendMemberCodeReturn.repeat); } else { var timeout = CacheKeyCollection.MemberPluginReBindTime(UserName, pluginId); //验证码超时时间 if (Core.Cache.Get(timeout) != null) { return(Himall.CommonModel.SendMemberCodeReturn.limit); } var checkCode = new Random().Next(10000, 99999); Log.Debug("Code:" + checkCode); var cacheTimeout = DateTime.Now.AddMinutes(15); Core.Cache.Insert(CacheKeyCollection.MemberPluginCheck(UserName, pluginId + destination), checkCode, cacheTimeout); var user = new MessageUserInfo() { UserName = UserName, SiteName = SiteName, CheckCode = checkCode.ToString() }; MessageApplication.SendMessageCode(destination, pluginId, user); Core.Cache.Insert(CacheKeyCollection.MemberPluginReBindTime(UserName, pluginId), "0", DateTime.Now.AddSeconds(110));//验证码超时时间 return(Himall.CommonModel.SendMemberCodeReturn.success); } }
/// <summary> /// 根据插件类型和ID和目标获取信息 /// </summary> /// <param name="pluginId"></param> /// <param name="contact"></param> /// <param name="type"></param> /// <returns></returns> public static Himall.DTO.MemberContacts GetMemberContactsInfo(string pluginId, string contact, Himall.Model.MemberContactsInfo.UserTypes type) { var model = MessageApplication.GetMemberContactsInfo(pluginId, contact, type); Mapper.CreateMap <Himall.Model.MemberContactsInfo, Himall.DTO.MemberContacts>(); return(Mapper.Map <Himall.Model.MemberContactsInfo, Himall.DTO.MemberContacts>(model)); }
/// <summary> /// 验证码验证,认证管理员 /// </summary> /// <param name="pluginId">信息类别</param> /// <param name="code">验证码</param> /// <param name="destination">联系号码</param> /// <param name="userId">会员ID</param> /// <returns></returns> public static int CheckShopCode(string pluginId, string code, string destination, long userId) { var member = MemberApplication.GetMembers(userId); int result = 0; var cache = CacheKeyCollection.MemberPluginCheck(member.UserName, pluginId + destination); var cacheCode = Core.Cache.Get <string>(cache); if (cacheCode != null && cacheCode == code) { if (MessageApplication.GetMemberContactsInfo(pluginId, destination, Entities.MemberContactInfo.UserTypes.General) != null) { result = -1; } else { if (pluginId.ToLower().Contains("email")) { member.Email = destination; } else if (pluginId.ToLower().Contains("sms")) { member.CellPhone = destination; } MemberApplication.UpdateMember(member); MessageApplication.UpdateMemberContacts(new Entities.MemberContactInfo() { Contact = destination, ServiceProvider = pluginId, UserId = userId, UserType = Entities.MemberContactInfo.UserTypes.General }); Core.Cache.Remove(CacheKeyCollection.MemberPluginCheck(member.UserName, pluginId)); Core.Cache.Remove(CacheKeyCollection.Member(userId));//移除用户缓存 Core.Cache.Remove("Rebind" + userId); result = 1; } } return(result); }
/// <summary> /// 获取会员认证情况 /// </summary> /// <param name="UserId">会员ID</param> /// <returns></returns> public static Himall.DTO.MemberAccountSafety GetMemberAccountSafety(long UserId) { Himall.DTO.MemberAccountSafety model = new Himall.DTO.MemberAccountSafety(); model.UserId = UserId; List <Himall.Model.MemberContactsInfo> lmMemberContactsInfo = MessageApplication.GetMemberContactsInfo(UserId); foreach (Himall.Model.MemberContactsInfo item in lmMemberContactsInfo) { if (item.ServiceProvider.Contains("SMS")) { model.Phone = item.Contact; model.BindPhone = true; } else if (item.ServiceProvider.Contains("Email")) { model.Email = item.Contact; model.BindEmail = true; } } return(model); }
/// <summary> /// 获取店铺认证情况 /// </summary> /// <param name="ShopId">店铺ID</param> /// <returns></returns> public static MemberAccountSafety GetShopAccountSafety(long ShopId) { MemberAccountSafety model = new MemberAccountSafety(); long UserId = Service.GetShopManagers(ShopId); model.UserId = UserId; List <Entities.MemberContactInfo> lmMemberContactsInfo = MessageApplication.GetMemberContactsInfo(UserId); foreach (var item in lmMemberContactsInfo) { if (item.ServiceProvider.Contains("SMS")) { model.Phone = item.Contact; model.BindPhone = true; } else if (item.ServiceProvider.Contains("Email")) { model.Email = item.Contact; model.BindEmail = true; } } return(model); }