public void UpdateMemberContacts(MemberContactsInfo info) { var exist = Context.MemberContactsInfo.FirstOrDefault(a => a.ServiceProvider == info.ServiceProvider && a.UserId == info.UserId && a.UserType == info.UserType); if (exist != null) { exist.Contact = info.Contact; } else { Context.MemberContactsInfo.Add(info); } var user = Context.UserMemberInfo.Where(a => a.Id == info.UserId).FirstOrDefault(); if (user != null) { if (info.ServiceProvider == "Himall.Plugin.Message.SMS") { user.CellPhone = info.Contact; } else { user.Email = info.Contact; } } Context.SaveChanges(); Core.Cache.Remove(CacheKeyCollection.Member(info.UserId));//移除用户缓存 }
public UserMemberInfo GetMemberByContactInfo(string contact) { UserMemberInfo userMemberInfo = null; MemberContactsInfo memberContactsInfo = context.MemberContactsInfo.FirstOrDefault((MemberContactsInfo item) => (item.Contact == contact) && item.UserType == 0); userMemberInfo = (memberContactsInfo == null ? ( from a in context.UserMemberInfo where (a.UserName == contact) && context.MemberContactsInfo.Any((MemberContactsInfo item) => item.UserId == a.Id) select a).FirstOrDefault() : context.UserMemberInfo.FindById <UserMemberInfo>(memberContactsInfo.UserId)); return(userMemberInfo); }
public string GetDestination(long userId, string pluginId, MemberContactsInfo.UserTypes type) { MemberContactsInfo memberContactsInfo = ( from a in context.MemberContactsInfo where a.UserId == userId && (a.ServiceProvider == pluginId) && (int)a.UserType == (int)type select a).FirstOrDefault(); if (memberContactsInfo == null) { return(""); } return(memberContactsInfo.Contact); }
public void UpdateMemberContacts(MemberContactsInfo info) { MemberContactsInfo contact = context.MemberContactsInfo.FirstOrDefault((MemberContactsInfo a) => (a.ServiceProvider == info.ServiceProvider) && a.UserId == info.UserId && (int)a.UserType == (int)info.UserType); if (contact == null) { context.MemberContactsInfo.Add(info); } else { contact.Contact = info.Contact; } context.SaveChanges(); }
//更新信息=用户表 public static void UpdateMemberContacts(MemberContactsInfo info) { _iMessageService.UpdateMemberContacts(info); }
public UserMemberInfo Register(string username, string password, string email = "", long introducer = 0L) { UserMemberInfo nullable; if (string.IsNullOrWhiteSpace(username)) { throw new ArgumentNullException("用户名不能为空"); } if (CheckMemberExist(username)) { throw new HimallException(string.Concat("用户名 ", username, " 已经被其它会员注册")); } if (string.IsNullOrWhiteSpace(password)) { throw new ArgumentNullException("密码不能为空"); } if (!string.IsNullOrEmpty(email) && CheckEmailExist(email)) { throw new HimallException("邮箱已经被其它会员注册"); } password = password.Trim(); Guid guid = Guid.NewGuid(); string str = guid.ToString("N").Substring(12); password = GetPasswrodWithTwiceEncode(password, str); using (TransactionScope transactionScope = new TransactionScope()) { UserMemberInfo userMemberInfo = new UserMemberInfo() { UserName = username, PasswordSalt = str, CreateDate = DateTime.Now, LastLoginDate = DateTime.Now, Nick = username, RealName = username, Email = email }; nullable = userMemberInfo; if (introducer != 0) { nullable.InviteUserId = new long?(introducer); } nullable.Password = password; nullable = context.UserMemberInfo.Add(nullable); context.SaveChanges(); if (!string.IsNullOrEmpty(email)) { IMessageService create = Instance <IMessageService> .Create; MemberContactsInfo memberContactsInfo = new MemberContactsInfo() { Contact = email, ServiceProvider = "Himall.Plugin.Message.Email", UserId = nullable.Id, UserType = MemberContactsInfo.UserTypes.General }; create.UpdateMemberContacts(memberContactsInfo); MemberIntegralRecord memberIntegralRecord = new MemberIntegralRecord() { UserName = username, MemberId = nullable.Id, RecordDate = new DateTime?(DateTime.Now), TypeId = MemberIntegral.IntegralType.Reg, ReMark = "Bind Email" }; IConversionMemberIntegralBase conversionMemberIntegralBase = Instance <IMemberIntegralConversionFactoryService> .Create.Create(MemberIntegral.IntegralType.Reg, 0); Instance <IMemberIntegralService> .Create.AddMemberIntegral(memberIntegralRecord, conversionMemberIntegralBase); IMemberInviteService memberInviteService = Instance <IMemberInviteService> .Create; if (introducer != 0) { UserMemberInfo member = GetMember(introducer); if (member != null) { memberInviteService.AddInviteIntegel(nullable, member); } } } transactionScope.Complete(); } return(nullable); }
public void UpdateShop(ShopInfo shop) { ShopInfo shopName = context.ShopInfo.FindById <ShopInfo>(shop.Id); shopName.ShopName = shop.ShopName ?? shopName.ShopName; shopName.GradeId = (shop.GradeId == 0 ? shopName.GradeId : shop.GradeId); ShopInfo shopInfo = shopName; DateTime?endDate = shop.EndDate; shopInfo.EndDate = (endDate.HasValue ? new DateTime?(endDate.GetValueOrDefault()) : shopName.EndDate); shopName.ShopStatus = shop.ShopStatus == 0 ? shopName.ShopStatus : shop.ShopStatus; ShopInfo shopInfo1 = shopName; ShopInfo.ShopStage?stage = shop.Stage; shopInfo1.Stage = (stage.HasValue ? new ShopInfo.ShopStage?(stage.GetValueOrDefault()) : shopName.Stage); shopName.BankAccountName = shop.BankAccountName ?? shopName.BankAccountName; shopName.BankAccountNumber = shop.BankAccountNumber ?? shopName.BankAccountNumber; shopName.BankCode = shop.BankCode ?? shopName.BankCode; shopName.BankName = shop.BankName ?? shopName.BankName; shopName.BankRegionId = (shop.BankRegionId == 0 ? shopName.BankRegionId : shop.BankRegionId); shopName.CompanyRegionId = (shop.CompanyRegionId == 0 ? shopName.CompanyRegionId : shop.CompanyRegionId); shopName.CompanyRegisteredCapital = (shop.CompanyRegisteredCapital == new decimal(0) ? shopName.CompanyRegisteredCapital : shop.CompanyRegisteredCapital); ShopInfo shopInfo2 = shopName; DateTime?businessLicenceEnd = shop.BusinessLicenceEnd; shopInfo2.BusinessLicenceEnd = (businessLicenceEnd.HasValue ? new DateTime?(businessLicenceEnd.GetValueOrDefault()) : shopName.BusinessLicenceEnd); ShopInfo shopInfo3 = shopName; DateTime?businessLicenceStart = shop.BusinessLicenceStart; shopInfo3.BusinessLicenceStart = (businessLicenceStart.HasValue ? new DateTime?(businessLicenceStart.GetValueOrDefault()) : shopName.BusinessLicenceStart); shopName.legalPerson = shop.legalPerson ?? shopName.legalPerson; if (shop.CompanyFoundingDate.HasValue) { shopName.CompanyFoundingDate = new DateTime?((shop.CompanyFoundingDate.HasValue ? shop.CompanyFoundingDate.Value : shopName.CompanyFoundingDate.Value)); } shopName.Logo = shop.Logo ?? shopName.Logo; shopName.SubDomains = shop.SubDomains ?? shopName.SubDomains; shopName.Theme = shop.Theme ?? shopName.Theme; shopName.BusinessLicenceRegionId = (shop.BusinessLicenceRegionId == 0 ? shopName.BusinessLicenceRegionId : shop.BusinessLicenceRegionId); shopName.CompanyEmployeeCount = shop.CompanyEmployeeCount == 0 ? shopName.CompanyEmployeeCount : shop.CompanyEmployeeCount; shopName.BusinessLicenceNumber = shop.BusinessLicenceNumber ?? shopName.BusinessLicenceNumber; shopName.BusinessSphere = shop.BusinessSphere ?? shopName.BusinessSphere; shopName.CompanyAddress = shop.CompanyAddress ?? shopName.CompanyAddress; shopName.CompanyName = shop.CompanyName ?? shopName.CompanyName; shopName.CompanyPhone = shop.CompanyPhone ?? shopName.CompanyPhone; shopName.CompanyRegionAddress = shop.CompanyRegionAddress ?? shopName.CompanyRegionAddress; shopName.ContactsEmail = shop.ContactsEmail ?? shopName.ContactsEmail; shopName.ContactsName = shop.ContactsName ?? shopName.ContactsName; shopName.ContactsPhone = shop.ContactsPhone ?? shopName.ContactsPhone; shopName.OrganizationCode = shop.OrganizationCode ?? shopName.OrganizationCode; shopName.TaxpayerId = shop.TaxpayerId ?? shopName.TaxpayerId; shopName.TaxRegistrationCertificate = shop.TaxRegistrationCertificate ?? shopName.TaxRegistrationCertificate; shopName.PayRemark = shop.PayRemark ?? shopName.PayRemark; shopName.SenderAddress = shop.SenderAddress ?? shopName.SenderAddress; shopName.SenderName = shop.SenderName ?? shopName.SenderName; shopName.SenderPhone = shop.SenderPhone ?? shopName.SenderPhone; if (!string.IsNullOrEmpty(shop.BusinessLicenseCert)) { shopName.BusinessLicenseCert = string.Concat("/Storage/Shop/", shop.Id, "/Cert/BusinessLicenseCert"); } if (!string.IsNullOrEmpty(shop.ProductCert)) { shopName.ProductCert = string.Concat("/Storage/Shop/", shop.Id, "/Cert/ProductCert"); } if (!string.IsNullOrEmpty(shop.OtherCert)) { shopName.OtherCert = string.Concat("/Storage/Shop/", shop.Id, "/Cert/OtherCert"); } if (!string.IsNullOrEmpty(shop.TaxRegistrationCertificatePhoto)) { shopName.TaxRegistrationCertificatePhoto = string.Concat("/Storage/Shop/", shop.Id, "/Cert/TaxRegistrationCertificatePhoto1.png"); } if (!string.IsNullOrEmpty(shop.BusinessLicenceNumberPhoto)) { shopName.BusinessLicenceNumberPhoto = string.Concat("/Storage/Shop/", shop.Id, "/Cert/BusinessLicenceNumberPhoto1.png"); } if (!string.IsNullOrEmpty(shop.OrganizationCodePhoto)) { shopName.OrganizationCodePhoto = string.Concat("/Storage/Shop/", shop.Id, "/Cert/OrganizationCodePhoto1.png"); } if (!string.IsNullOrEmpty(shop.GeneralTaxpayerPhot)) { shopName.GeneralTaxpayerPhot = string.Concat("/Storage/Shop/", shop.Id, "/Cert/GeneralTaxpayerPhoto1.png"); } if (!string.IsNullOrEmpty(shop.BankPhoto)) { shopName.BankPhoto = string.Concat("/Storage/Shop/", shop.Id, "/Cert/BankPhoto1.png"); } if (!string.IsNullOrEmpty(shop.PayPhoto)) { shopName.PayPhoto = string.Concat("/Storage/Shop/", shop.Id, "/Cert/PayPhoto1.png"); } context.SaveChanges(); string businessLicenseCert = shop.BusinessLicenseCert; string productCert = shop.ProductCert; string otherCert = shop.OtherCert; string businessLicenceNumberPhoto = shop.BusinessLicenceNumberPhoto; string taxRegistrationCertificatePhoto = shop.TaxRegistrationCertificatePhoto; string organizationCodePhoto = shop.OrganizationCodePhoto; string generalTaxpayerPhot = shop.GeneralTaxpayerPhot; string bankPhoto = shop.BankPhoto; string payPhoto = shop.PayPhoto; if (!string.IsNullOrEmpty(businessLicenceNumberPhoto)) { MoveImages(shop.Id, businessLicenceNumberPhoto, "BusinessLicenceNumberPhoto", 1); } if (!string.IsNullOrEmpty(taxRegistrationCertificatePhoto)) { MoveImages(shop.Id, taxRegistrationCertificatePhoto, "TaxRegistrationCertificatePhoto", 1); } if (!string.IsNullOrEmpty(organizationCodePhoto)) { MoveImages(shop.Id, organizationCodePhoto, "OrganizationCodePhoto", 1); } if (!string.IsNullOrEmpty(generalTaxpayerPhot)) { MoveImages(shop.Id, generalTaxpayerPhot, "GeneralTaxpayerPhoto", 1); } if (!string.IsNullOrEmpty(bankPhoto)) { MoveImages(shop.Id, bankPhoto, "BankPhoto", 1); } if (!string.IsNullOrEmpty(payPhoto)) { MoveImages(shop.Id, payPhoto, "PayPhoto", 1); } if (!string.IsNullOrEmpty(businessLicenseCert)) { string[] strArrays = businessLicenseCert.Split(new char[] { ',' }); int num = 0; string[] strArrays1 = strArrays; for (int i = 0; i < strArrays1.Length; i++) { string str = strArrays1[i]; num++; MoveImages(shop.Id, str, "BusinessLicenseCert", num); } } if (!string.IsNullOrEmpty(productCert)) { string[] strArrays2 = productCert.Split(new char[] { ',' }); int num1 = 0; string[] strArrays3 = strArrays2; for (int j = 0; j < strArrays3.Length; j++) { string str1 = strArrays3[j]; num1++; MoveImages(shop.Id, str1, "ProductCert", num1); } } if (!string.IsNullOrEmpty(otherCert)) { string[] strArrays4 = otherCert.Split(new char[] { ',' }); int num2 = 0; string[] strArrays5 = strArrays4; for (int k = 0; k < strArrays5.Length; k++) { string str2 = strArrays5[k]; num2++; MoveImages(shop.Id, str2, "OtherCert", num2); } } IMessageService create = Instance <IMessageService> .Create; Plugin <IEmailPlugin> plugin = PluginsManagement.GetPlugins <IEmailPlugin>().FirstOrDefault <Plugin <IEmailPlugin> >(); if (!string.IsNullOrWhiteSpace(shopName.ContactsEmail)) { MemberContactsInfo memberContactsInfo = new MemberContactsInfo() { Contact = shopName.ContactsEmail, ServiceProvider = plugin.PluginInfo.PluginId, UserId = shopName.Id, UserType = MemberContactsInfo.UserTypes.ShopManager }; create.UpdateMemberContacts(memberContactsInfo); } Plugin <ISMSPlugin> plugin1 = PluginsManagement.GetPlugins <ISMSPlugin>().FirstOrDefault <Plugin <ISMSPlugin> >(); if (plugin1 != null && !string.IsNullOrWhiteSpace(shopName.ContactsPhone)) { MemberContactsInfo memberContactsInfo1 = new MemberContactsInfo() { Contact = shopName.ContactsPhone, ServiceProvider = plugin1.PluginInfo.PluginId, UserId = shopName.Id, UserType = MemberContactsInfo.UserTypes.ShopManager }; create.UpdateMemberContacts(memberContactsInfo1); } }
public ActionResult CheckCode(string pluginId, string code, string destination) { string str = CacheKeyCollection.MemberPluginCheck(base.CurrentUser.UserName, pluginId); object obj = Cache.Get(str); UserMemberInfo currentUser = base.CurrentUser; string str1 = ""; if (obj == null || !(obj.ToString() == code)) { Result result = new Result() { success = false, msg = "验证码不正确或者已经超时" }; return(Json(result)); } IMessageService messageService = ServiceHelper.Create <IMessageService>(); if (messageService.GetMemberContactsInfo(pluginId, destination, MemberContactsInfo.UserTypes.General) != null) { Result result1 = new Result() { success = false, msg = string.Concat(destination, "已经绑定过了!") }; return(Json(result1)); } if (pluginId.ToLower().Contains("email")) { currentUser.Email = destination; str1 = "邮箱"; } else if (pluginId.ToLower().Contains("sms")) { currentUser.CellPhone = destination; str1 = "手机"; } ServiceHelper.Create <IMemberService>().UpdateMember(currentUser); MemberContactsInfo memberContactsInfo = new MemberContactsInfo() { Contact = destination, ServiceProvider = pluginId, UserId = base.CurrentUser.Id, UserType = MemberContactsInfo.UserTypes.General }; messageService.UpdateMemberContacts(memberContactsInfo); Cache.Remove(CacheKeyCollection.MemberPluginCheck(base.CurrentUser.UserName, pluginId)); Cache.Remove(CacheKeyCollection.Member(base.CurrentUser.Id)); Cache.Remove(string.Concat("Rebind", base.CurrentUser.Id)); UserMemberInfo member = null; if (currentUser.InviteUserId.HasValue) { member = ServiceHelper.Create <IMemberService>().GetMember(currentUser.InviteUserId.Value); } Task.Factory.StartNew(() => { MemberIntegralRecord memberIntegralRecord = new MemberIntegralRecord() { UserName = currentUser.UserName, MemberId = currentUser.Id, RecordDate = new DateTime?(DateTime.Now), TypeId = MemberIntegral.IntegralType.Reg, ReMark = string.Concat("绑定", str1) }; IConversionMemberIntegralBase conversionMemberIntegralBase = ServiceHelper.Create <IMemberIntegralConversionFactoryService>().Create(MemberIntegral.IntegralType.Reg, 0); ServiceHelper.Create <IMemberIntegralService>().AddMemberIntegral(memberIntegralRecord, conversionMemberIntegralBase); if (member != null) { ServiceHelper.Create <IMemberInviteService>().AddInviteIntegel(currentUser, member); } }); Result result2 = new Result() { success = true, msg = "验证正确" }; return(Json(result2)); }