private void CreateSystemNoteMessage(MsgSubmitSystem submitSystem) { DbResult <bool> transResult = null; if (submitSystem.systemNoteTarget == SystemNoteTarget.Single) { EMsgInfo_System msg = new EMsgInfo_System { CreatedDateTime = DateTime.Now, ContentId = submitSystem.contentId, ReceiveUserId = submitSystem.receiveUserId, }; transResult = _msgReplyRepository.Db.Ado.UseTran(() => { //新消息 _msgSystemRepository.AddNoIdentity_Sync(msg); //总数 _msgInfoOverviewRepository.UpdateNotificateToUnRead(NotificationType.system, msg.ReceiveUserId); }); } else { List <UserSimple> userList = _userRepository.queryNotificationGroup(submitSystem.receiveGroupId); List <EMsgInfo_System> msgList = new List <EMsgInfo_System>(); foreach (var u in userList) { EMsgInfo_System msg = new EMsgInfo_System { CreatedDateTime = DateTime.Now, ContentId = submitSystem.contentId, ReceiveUserId = u.UserId, }; msgList.Add(msg); } transResult = _msgReplyRepository.Db.Ado.UseTran(() => { //新消息 _msgSystemRepository.AddRange(msgList); //总数 _msgInfoOverviewRepository.UpdateGroupToUnRead(submitSystem.receiveGroupId); }); } if (transResult != null && !transResult.IsSuccess) { throw new Exception(transResult.ErrorMessage); } }
/// <summary> /// /// </summary> /// <param name="regUser"></param> /// <returns>-1 已存在,-2手机已使用</returns> public VueUserLogin Register(RegUser regUser) { int c = _userDb.GetCount(a => a.UserAccount == regUser.Account).Result; int phone = _userDb.GetCount(a => a.Phone == regUser.Phone).Result; if (c > 0) { throw new CCException(CCWebMsg.User_Reg_Exist_Account); } if (phone > 0) { throw new CCException(CCWebMsg.User_Reg_Exist_Phone); } //用户基本信息 EUserInfo ui = new EUserInfo { Id = CodeManager.UserCode(), //Guid.NewGuid().ToString("N"), UserAccount = regUser.Account, UserPwd = regUser.Pwd, Phone = regUser.Phone, NickName = regUser.Account, Group_Notification = Model.BaseEnum.Group_Notification.normal, }; //用户财务概览 EUserFinanceOverview financeOverview = new EUserFinanceOverview { userId = ui.Id, pointEffectDate = DateTime.Now.AddDays(90), money = 0, chargePoint = 0, fixedPoint = 20, }; //注册赠送积分 EUserPointsTrans trans = new EUserPointsTrans { userId = ui.Id, createdDateTime = DateTime.Now, changeType = Model.BaseEnum.PointChangeType.newRegister, point = 20, }; //消息通知(欢迎新用户) EMsgInfo_System msg = new EMsgInfo_System { ContentId = 10000, NotificationStatus = NotificationStatus.sent, ReceiveUserId = ui.Id, }; DbResult <bool> transResult = null; transResult = _userDb.Db.Ado.UseTran(() => { _userDb.AddNoIdentity_Sync(ui); _userFinanceOverViewRepository.AddNoIdentity_Sync(financeOverview); _userFinanceRepository.AddPointTrans_Sync(trans); //消息通知(欢迎新用户) _msgSystemRepository.AddNoIdentity_Sync(msg); //用户消息概览 _msgInfoOverviewRepository.InitForNewUser_Sync(ui.Id); }); if (!transResult.IsSuccess) { throw new Exception("注册失败"); } VueUserLogin result = new VueUserLogin(); result.UerInfo = ui.ToVueUser(); result.MsgOverview = new VueMsgInfoOverview(); result.MsgOverview.userId = ui.Id; return(result); }