Пример #1
0
 MessageCode Save_TranReceiveBindPoint(PayUserEntity payUser, InvestManagerEntity investInfo)
 {
     try
     {
         using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
         {
             transactionManager.BeginTransaction();
             var code = Tran_ReceiveBindPoint(payUser, investInfo, transactionManager.TransactionObject);
             if (code == ShareUtil.SuccessCode)
             {
                 transactionManager.Commit();
             }
             else
             {
                 transactionManager.Rollback();
             }
             return(code);
         }
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("ReceiveBindPoint", ex);
         return(MessageCode.Exception);
     }
 }
Пример #2
0
        /// <summary>
        /// 带事务的Update
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="trans">The trans.</param>
        /// <returns></returns>
        /// <remarks>2016/3/4 16:25:58</remarks>
        public bool Update(InvestManagerEntity entity, DbTransaction trans = null)
        {
            var       database       = new SqlDatabase(this.ConnectionString);
            DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_InvestManager_Update");

            database.AddInParameter(commandWrapper, "@ManagerId", DbType.Guid, entity.ManagerId);
            database.AddInParameter(commandWrapper, "@Deposit", DbType.Int32, entity.Deposit);
            database.AddInParameter(commandWrapper, "@StepStatus", DbType.AnsiString, entity.StepStatus);
            database.AddInParameter(commandWrapper, "@TheMonthly", DbType.Boolean, entity.TheMonthly);
            database.AddInParameter(commandWrapper, "@MonthlyTime", DbType.DateTime, entity.MonthlyTime);
            database.AddInParameter(commandWrapper, "@ExpirationTime", DbType.DateTime, entity.ExpirationTime);
            database.AddInParameter(commandWrapper, "@Once", DbType.Boolean, entity.Once);
            database.AddInParameter(commandWrapper, "@ReceivedCount", DbType.Int32, entity.ReceivedCount);
            database.AddInParameter(commandWrapper, "@RowTime", DbType.DateTime, entity.RowTime);
            database.AddInParameter(commandWrapper, "@DepositCount", DbType.Int32, entity.DepositCount);


            int results = 0;

            if (trans != null)
            {
                results = database.ExecuteNonQuery(commandWrapper, trans);
            }
            else
            {
                results = database.ExecuteNonQuery(commandWrapper);
            }

            entity.ManagerId = (System.Guid)database.GetParameterValue(commandWrapper, "@ManagerId");

            return(Convert.ToBoolean(results));
        }
Пример #3
0
        MessageCode Tran_ReceiveBindPoint(PayUserEntity payUser, InvestManagerEntity investInfo,
                                          DbTransaction transaction)
        {
            if (!InvestManagerMgr.Update(investInfo, transaction))
            {
                return(MessageCode.NbUpdateFail);
            }

            if (!PayUserMgr.Update(payUser, transaction))
            {
                return(MessageCode.NbUpdateFail);
            }
            return(MessageCode.Success);
        }
Пример #4
0
        MessageCode Tran_InvestDeposit(PayUserEntity payUser, InvestManagerEntity investInfo, int point, DbTransaction transaction)
        {
            if (!InvestManagerMgr.Update(investInfo, transaction))
            {
                return(MessageCode.NbUpdateFail);
            }
            int returnCode = -2;

            PayUserMgr.ConsumePoint(payUser.Account, investInfo.ManagerId, (int)EnumConsumeSourceType.InvestDeposit,
                                    Guid.NewGuid().ToString(), point, DateTime.Now, payUser.RowVersion, ref returnCode, transaction);
            if (returnCode != (int)MessageCode.PaySuccess)
            {
                return(MessageCode.NbUpdateFail);
            }
            return(MessageCode.Success);
        }
Пример #5
0
        InvestManagerEntity InnerBuildEntity(Guid managerId)
        {
            InvestManagerEntity entity = new InvestManagerEntity();

            entity.ManagerId      = managerId;
            entity.Deposit        = 0;
            entity.StepStatus     = "0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0";
            entity.TheMonthly     = false;
            entity.MonthlyTime    = DateTime.Today;
            entity.ExpirationTime = DateTime.Today;
            entity.Once           = false;
            entity.ReceivedCount  = 0;
            entity.RowTime        = DateTime.Now;
            entity.DepositCount   = 0;
            InvestManagerMgr.Insert(entity);
            return(entity);
        }
Пример #6
0
        /// <summary>
        /// 将IDataReader的当前记录读取到InvestManagerEntity 对象
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public InvestManagerEntity LoadSingleRow(IDataReader reader)
        {
            var obj = new InvestManagerEntity();

            obj.ManagerId      = (System.Guid)reader["ManagerId"];
            obj.Deposit        = (System.Int32)reader["Deposit"];
            obj.StepStatus     = (System.String)reader["StepStatus"];
            obj.TheMonthly     = (System.Boolean)reader["TheMonthly"];
            obj.MonthlyTime    = (System.DateTime)reader["MonthlyTime"];
            obj.ExpirationTime = (System.DateTime)reader["ExpirationTime"];
            obj.Once           = (System.Boolean)reader["Once"];
            obj.ReceivedCount  = (System.Int32)reader["ReceivedCount"];
            obj.RowTime        = (System.DateTime)reader["RowTime"];
            obj.DepositCount   = (System.Int32)reader["DepositCount"];

            return(obj);
        }
Пример #7
0
        InvestInfoResponse BuildInvestInfoResponse(InvestManagerEntity investInfo, List <int> restitution, string newStepStatus, PayUserEntity payUser, int depositPoint)
        {
            var response = ResponseHelper.CreateSuccess <InvestInfoResponse>();

            response.Data = new InvestInfoEntity();

            response.Data.Deposit       = investInfo.Deposit;
            response.Data.Restitution   = restitution;
            response.Data.ReceiveStatus = BuildReceiveStatus(newStepStatus);
            response.Data.Once          = investInfo.Once;

            if (DateTime.Today > investInfo.ExpirationTime)
            {
                response.Data.TotalCount   = 0;
                response.Data.ReceiveCount = 0;
            }
            else
            {
                response.Data.TotalCount   = (investInfo.ExpirationTime - investInfo.MonthlyTime).Days;
                response.Data.ReceiveCount = investInfo.ReceivedCount;
            }

            if (investInfo.TheMonthly)
            {
                response.Data.DayCount = (DateTime.Today - investInfo.MonthlyTime).Days + 1;
            }
            else
            {
                response.Data.DayCount = 0;
            }
            if (payUser == null)
            {
                response.Data.BindPoint = 0;
            }
            else
            {
                response.Data.BindPoint = payUser.BindPoint;
                //ChatHelper.SendUpdateManagerInfoPop(investInfo.ManagerId, payUser.TotalPoint - depositPoint, true);
            }

            return(response);
        }
Пример #8
0
        /// <summary>
        /// GetById
        /// </summary>
        /// <param name="managerId">managerId</param>
        /// <returns>InvestManagerEntity</returns>
        /// <remarks>2016/3/4 16:25:58</remarks>
        public InvestManagerEntity GetById(System.Guid managerId)
        {
            var database = new SqlDatabase(this.ConnectionString);

            DbCommand commandWrapper = database.GetStoredProcCommand("P_InvestManager_GetById");

            database.AddInParameter(commandWrapper, "@ManagerId", DbType.Guid, managerId);


            InvestManagerEntity obj = null;

            using (IDataReader reader = database.ExecuteReader(commandWrapper))
            {
                if (reader.Read())
                {
                    obj = LoadSingleRow(reader);
                }
            }
            return(obj);
        }
Пример #9
0
        public static bool Update(InvestManagerEntity investManagerEntity, DbTransaction trans = null, string zoneId = "")
        {
            var provider = new InvestManagerProvider(zoneId);

            return(provider.Update(investManagerEntity, trans));
        }