public bool H5Register(H5RegisterIM im) { if (im.Cellphone.StartsWith("170") || im.Cellphone.StartsWith("171")) { throw new CommonException(ReasonCode.PhoneNumber_Invalid, MessageResources.InvalidCellphone); } var verifier = new RegisterCellphoneVerifier(); SecurityVerify.Verify(verifier, SystemPlatform.FiiiPay, $"{im.CountryId}:{im.Cellphone}", im.SMSCode, true); var accountDAC = new UserAccountDAC(); if (!IsNullOrEmpty(im.InviterCode) && !accountDAC.ExistInviterCode(im.InviterCode)) { throw new CommonException(ReasonCode.INVITORCODE_NOT_EXISTS, MessageResources.InvalidInvitation); } if (!AccountUseable(im.CountryId, im.Cellphone)) { throw new CommonException(ReasonCode.ACCOUNT_EXISTS, Format(MessageResources.AccountAlreadyExist, im.Cellphone)); } bool result = Register(im.CountryId, im.Cellphone, im.Password, im.InviterCode); if (result) { SecurityVerify.InvalidateCode(verifier, SystemPlatform.FiiiPay, $"{im.CountryId}:{im.Cellphone}"); } return(result); }
private string GenerateInvitationCode(string code = null) { if (IsNullOrEmpty(code)) { code = RandomAlphaNumericGenerator.GenerateCode(5); } var accountDAC = new UserAccountDAC(); if (accountDAC.ExistInviterCode(code)) { var newCode = RandomAlphaNumericGenerator.GenerateCode(5); code = GenerateInvitationCode(newCode); return(code); } return(code); }
/// <summary> /// 修改邀请码 /// </summary> /// <param name="merchantId"></param> /// <param name="email"></param> /// <returns></returns> public void UpdateInviterCode(Guid merchantId, string inviterCode) { UserAccountDAC uaDac = new UserAccountDAC(); if (!string.IsNullOrEmpty(inviterCode) && !uaDac.ExistInviterCode(inviterCode)) { throw new CommonException(ReasonCode.FiiiPosReasonCode.INVITERCODE_NOT_EXISTS, "邀请码不存在"); } var user = uaDac.GetUserAccountByInviteCode(inviterCode); InviteRecordDAC irDac = new InviteRecordDAC(); InviteRecord model = new InviteRecord(); model.AccountId = merchantId; model.InviterCode = inviterCode; model.Type = InviteType.Fiiipos; model.Timestamp = DateTime.UtcNow; model.InviterAccountId = user.Id; irDac.Insert(model);; }
public string GenerateNickname(string code = null) { string prevStr = "user_"; if (IsNullOrEmpty(code)) { code = RandomAlphaNumericGenerator.GenerateCode(10); } string nickname = prevStr + code; var accountDAC = new UserAccountDAC(); if (accountDAC.ExistInviterCode(nickname)) { var newCode = RandomAlphaNumericGenerator.GenerateCode(10); nickname = GenerateNickname(newCode); return(nickname); } return(nickname); }