Exemplo n.º 1
0
        //public bool AddMiners(int userID, int minersCount, CustomerMySqlTransaction myTrans)
        //{
        //    StoneFactoryOneGroupSlave slave = new StoneFactoryOneGroupSlave()
        //    {
        //        UserID = userID,
        //        ChargeTime = new MyDateTime(),
        //        JoinInSlaveCount = minersCount,
        //        isLive = true,
        //        LifeDays = 2,
        //        LiveSlaveCount = minersCount
        //    };

        //    return false;
        //}

        //public bool AddFoods(int userID, int foodsCount, CustomerMySqlTransaction myTrans)
        //{
        //    //直接修改字段值
        //    return false;
        //}

        public bool AddProfitRMBChangedRecord(StoneFactoryProfitRMBChangedRecord record, CustomerMySqlTransaction myTrans)
        {
            MySqlCommand mycmd = null;

            try
            {
                mycmd = myTrans.CreateCommand();
                string sqlText = "insert into stonefactoryprofitrmbchangedrecord " +
                                 "(`UserID`,`OperRMB`,`ValidStoneCount`,`ProfitType`,`OperTime`) " +
                                 " values (@UserID,@OperRMB,@ValidStoneCount,@ProfitType,@OperTime) ";
                mycmd.CommandText = sqlText;
                mycmd.Parameters.AddWithValue("@UserID", record.UserID);
                mycmd.Parameters.AddWithValue("@OperRMB", record.OperRMB);
                mycmd.Parameters.AddWithValue("@ValidStoneCount", record.ValidStoneCount);
                mycmd.Parameters.AddWithValue("@ProfitType", (int)record.ProfitType);
                mycmd.Parameters.AddWithValue("@OperTime", record.OperTime.ToDateTime());
                mycmd.ExecuteNonQuery();
            }
            finally
            {
                if (mycmd != null)
                {
                    mycmd.Dispose();
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public int WithdrawOutputRMB(int userID, string userName, decimal withdrawRMBCount)
        {
            PlayerRunnable playerrunner = PlayerController.Instance.GetRunnable(userName);

            if (playerrunner == null)
            {
                return(OperResult.RESULTCODE_USER_NOT_EXIST);
            }
            var playerFactoryAccountInfo = this.GetPlayerStoneFactoryAccountInfo(userID);

            if (playerFactoryAccountInfo == null)
            {
                return(OperResult.RESULTCODE_STONEFACTORYISCLOSED);
            }
            if (playerFactoryAccountInfo.WithdrawableProfitRMB < withdrawRMBCount)
            {
                return(OperResult.RESULTCODE_LACK_OF_BALANCE);
            }

            int result = MyDBHelper.Instance.TransactionDataBaseOper(myTrans =>
            {
                //添加提现记录
                StoneFactoryProfitRMBChangedRecord record = new StoneFactoryProfitRMBChangedRecord()
                {
                    UserID     = userID,
                    OperRMB    = -withdrawRMBCount,
                    OperTime   = new MyDateTime(DateTime.Now),
                    ProfitType = FactoryProfitOperType.WithdrawRMB
                };

                bool isOK = DBProvider.PlayerStoneFactoryDBProvider.AddProfitRMBChangedRecord(record, myTrans);
                if (isOK)
                {
                    return(playerrunner.WithdrawRMBFromFactory(withdrawRMBCount, myTrans));
                }

                return(OperResult.RESULTCODE_FALSE);
            },
                                                                     exc =>
            {
                PlayerController.Instance.RollbackUserFromDB(userName);
            });

            if (result == OperResult.RESULTCODE_TRUE)
            {
                LogHelper.Instance.AddInfoLog("矿石工厂,玩家ID[" + userID + "] 提取" + withdrawRMBCount + "灵币");
            }

            return(result);
        }
Exemplo n.º 3
0
 public StoneFactoryProfitRMBChangedRecordUIModel(StoneFactoryProfitRMBChangedRecord parent)
 {
     this.ParentObject = parent;
 }