Beispiel #1
0
        public bool AddPointTrans_Sync(EUserPointsTrans newEntity)
        {
            var insertable = base.Db.Insertable(newEntity);

            return(insertable.ExecuteCommand() > 0);
        }
Beispiel #2
0
        /// <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);
        }