public bool submitUerChargeTrans(VueSubmitUserCharge submitData)
        {
            DbResult<bool> transResult = null;

            if (string.IsNullOrEmpty(submitData.userId))
                throw new CCException("【提交充值】非法进入");
            if (submitData.amount < 1)
                throw new CCException("【提交充值】金额不能小于1");
            if (submitData.points < 10)
                throw new CCException("【提交充值】积分不能小于10");
           // if(submitData.pointEffectDate)

            transResult = _userFinanceRepository.Db.Ado.UseTran(() =>
            {
                //充值交易记录
                _userFinanceRepository.Add_Sync(new EUserChargeTrans
                {
                    userId = submitData.userId,
                    createdDateTime = DateTime.Now,
                    money = submitData.amount,
                    point = submitData.points,
                    rate = submitData.rate
                }) ;

                //积分变动
                _userFinanceRepository.AddPointTrans_Sync(new EUserPointsTrans
                {
                    userId = submitData.userId,
                    createdDateTime = DateTime.Now,
                    point = submitData.points,
                    changeType = Model.BaseEnum.PointChangeType.charge

                });

                //用户财务概况表
                _userFinanceOverViewRepository.updateChargePoint(new updateFinOverview
                {
                    userId = submitData.userId,
                    direction = Model.BaseEnum.OperationDirection.plus,
                    point = submitData.points,
                    pointEffectDate = submitData.pointEffectDate
                });
            });
            if (!transResult.IsSuccess)
                throw new Exception(transResult.ErrorMessage);
            return true;
            
        }
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);
        }