public void AddAuthenticationEmail(string authFrom, string userId, string email, string createBy) { using (var biz = new GameBiz.Business.GameBizBusinessManagement()) { biz.BeginTran(); using (var manager = new BettingPointManager()) { var entity = manager.GetUserEmail(userId); if (entity != null) { throw new ArgumentException(string.Format("此用户已于【{0:yyyy-MM-dd HH:mm:ss}】进行过邮箱认证", entity.CreateTime)); } entity = new UserEmail { UserId = userId, User = manager.LoadUser(userId), AuthFrom = authFrom, Email = email, IsSettedEmail = true, CreateBy = createBy, UpdateBy = createBy, }; manager.AddUserEmail(entity); var gv = new TaskListManager(); //增加成长值 var orderId = Guid.NewGuid().ToString("N"); BusinessHelper.Payin_UserGrowth("绑定邮箱", orderId, userId, 50, "完成邮箱绑定可获得50点成长值"); gv.AddUserTaskRecord(new UserTaskRecord { CreateTime = DateTime.Now, CurrentTime = DateTime.Now.ToString("yyyyMMdd"), OrderId = orderId, TaskCategory = TaskCategory.EmailBinding, TaskName = "绑定邮箱", UserId = userId, }); gv.AddTaskList(new TaskList { UserId = userId, OrderId = orderId, Content = "完成邮箱绑定可获得50点成长值", ValueGrowth = 50, IsGive = true, VipLevel = 0, CurrentTime = DateTime.Now.ToString("yyyyMMdd"), TaskCategory = TaskCategory.EmailBinding, TaskName = "绑定邮箱", CreateTime = DateTime.Now, }); } biz.CommitTran(); } }
public void RequestAuthenticationEmail(string userId, string email, int delaySeconds, string delayDescription, int maxRequestTime, string createBy) { #region //using (var biz = new GameBiz.Business.GameBizBusinessManagement()) //{ // biz.BeginTran(); // using (var manager = new BettingPointManager()) // { // var other = manager.GetOtherUserEmail(email, userId); // if (other != null && other.IsSettedEmail) // { // throw new ArgumentException(string.Format("此邮箱【{0}】已被其他用户认证。", email)); // } // var entity = manager.GetUserEmail(userId); // if (entity != null) // { // if (entity.IsSettedEmail) // { // throw new ArgumentException(string.Format("已于【{0:yyyy-MM-dd HH:mm:ss}】进行过邮箱认证。", entity.UpdateTime)); // } // if (entity.RequestTimes >= maxRequestTime) // { // throw new ArgumentException(string.Format("已请求最大限制次数【{0}】次还未成功认证,请联系客服。", maxRequestTime)); // } // if (email != entity.Email) // { // var span = entity.UpdateTime.AddSeconds(delaySeconds) - DateTime.Now; // if (span.TotalSeconds > 0) // { // throw new ArgumentException(string.Format("换邮箱再次认证必须在【{0}】后进行。", delayDescription)); // } // } // entity.UpdateBy = createBy; // entity.RequestTimes++; // entity.Email = email; // manager.UpdateUserEmail(entity); // } // else // { // entity = new UserEmail // { // UserId = userId, // User = manager.LoadUser(userId), // AuthFrom = "LOCAL", // Email = email, // IsSettedEmail = false, // CreateBy = createBy, // UpdateBy = createBy, // }; // manager.AddUserEmail(entity); // } // } // biz.CommitTran(); //} #endregion using (var manager = new BettingPointManager()) { var entity = manager.GetEmailInfoByEmail(email); if (entity != null && entity.IsSettedEmail) { throw new ArgumentException(string.Format("此邮箱【{0}】已被其他用户认证。", email)); } //var entity = manager.GetUserEmail(userId); if (entity != null) { if (entity.IsSettedEmail) { throw new ArgumentException(string.Format("已于【{0:yyyy-MM-dd HH:mm:ss}】进行过邮箱认证。", entity.UpdateTime)); } if (entity.RequestTimes >= maxRequestTime) { throw new ArgumentException(string.Format("已请求最大限制次数【{0}】次还未成功认证,请联系客服。", maxRequestTime)); } if (email != entity.Email) { var span = entity.UpdateTime.AddSeconds(delaySeconds) - DateTime.Now; if (span.TotalSeconds > 0) { throw new ArgumentException(string.Format("换邮箱再次认证必须在【{0}】后进行。", delayDescription)); } } entity.UpdateBy = createBy; entity.RequestTimes++; entity.Email = email; manager.UpdateUserEmail(entity); } else { entity = new UserEmail { UserId = userId, User = manager.LoadUser(userId), AuthFrom = "LOCAL", Email = email, IsSettedEmail = false, CreateBy = createBy, UpdateBy = createBy, }; manager.AddUserEmail(entity); } } }