Exemple #1
0
        public bool SaveFinalGoldCoinRechargeRecord(GoldCoinRechargeRecord record, CustomerMySqlTransaction myTrans)
        {
            MySqlCommand mycmd = null;

            try
            {
                mycmd = myTrans.CreateCommand();

                string cmdTextA = "insert into goldcoinrechargerecord " +
                                  "(`OrderNumber`, `UserID`, `SpendRMB`, `GainGoldCoin`, `CreateTime`, `PayTime`) values " +
                                  " (@OrderNumber, @UserID, @SpendRMB, @GainGoldCoin, @CreateTime, @PayTime); ";

                mycmd.CommandText = cmdTextA;
                mycmd.Parameters.AddWithValue("@OrderNumber", record.OrderNumber);
                mycmd.Parameters.AddWithValue("@UserID", record.UserID);
                mycmd.Parameters.AddWithValue("@SpendRMB", record.SpendRMB);
                mycmd.Parameters.AddWithValue("@GainGoldCoin", record.GainGoldCoin);
                mycmd.Parameters.AddWithValue("@CreateTime", record.CreateTime);
                mycmd.Parameters.AddWithValue("@PayTime", record.PayTime);

                mycmd.ExecuteNonQuery();
                return(true);
            }
            finally
            {
                if (mycmd != null)
                {
                    mycmd.Dispose();
                }
            }
        }
Exemple #2
0
 private GoldCoinRechargeRecord FindRecordByOrderNumber(string orderNumber)
 {
     lock (this._lock)
     {
         GoldCoinRechargeRecord buyRecord = null;
         this._listTempRecord.TryGetValue(orderNumber, out buyRecord);
         return(buyRecord);
     }
 }
Exemple #3
0
        public TradeOperResult RechargeGoldCoin(string userName, int rmbValue, int gainGoldCoin, int payType)
        {
            TradeOperResult result = new TradeOperResult();

            result.PayType = payType;
            DateTime timenow = DateTime.Now;

            var    player                 = PlayerController.Instance.GetPlayerInfoByUserName(userName);
            string orderNumber            = OrderController.Instance.CreateOrderNumber(userName, timenow, AlipayTradeInType.BuyGoldCoin);
            GoldCoinRechargeRecord record = new GoldCoinRechargeRecord()
            {
                OrderNumber  = orderNumber,
                CreateTime   = timenow,
                UserID       = player.SimpleInfo.UserID,
                UserName     = userName,
                SpendRMB     = rmbValue,
                GainGoldCoin = gainGoldCoin
            };

            if (payType == (int)PayType.RMB)
            {
                result = RechargeGoldCoinByRMB(record);
            }
            else if (payType == (int)PayType.Diamand)
            {
                result = RechargeGoldCoinByDiamond(record);
            }
            else if (payType == (int)PayType.Alipay)
            {
                lock (this._lock)
                {
                    this._listTempRecord.Add(record.OrderNumber, record);
                }

                DBProvider.GoldCoinRecordDBProvider.SaveTempGoldCoinRechargeTradeRecord(record);
                result.ResultCode = OperResult.RESULTCODE_TRUE;
                result.AlipayLink = OrderController.Instance.CreateAlipayLink(userName, record.OrderNumber, "迅灵金币", record.SpendRMB, "金币可用于购买矿工");
            }
            else if (payType == (int)PayType.Credits)
            {
                result = RechargeGoldCoinByShoppingCredits(record);
            }

            return(result);
        }
Exemple #4
0
        private TradeOperResult RechargeGoldCoinByRMB(GoldCoinRechargeRecord record)
        {
            TradeOperResult          result  = new TradeOperResult();
            CustomerMySqlTransaction myTrans = null;

            try
            {
                myTrans = MyDBHelper.Instance.CreateTrans();

                int value = PlayerController.Instance.RechargeGoldCoinByRMB(record.UserName, (int)record.SpendRMB, (int)record.GainGoldCoin, myTrans);
                result.ResultCode = value;
                if (value == OperResult.RESULTCODE_TRUE)
                {
                    record.PayTime = DateTime.Now;
                    DBProvider.GoldCoinRecordDBProvider.SaveFinalGoldCoinRechargeRecord(record, myTrans);
                }

                myTrans.Commit();
                PlayerActionController.Instance.AddLog(record.UserName, MetaData.ActionLog.ActionType.GoldCoinRecharge, record.GainGoldCoin,
                                                       "充值了 " + record.GainGoldCoin.ToString() + " 的金币");
                return(result);
            }
            catch (Exception exc)
            {
                myTrans.Rollback();
                LogHelper.Instance.AddErrorLog("玩家[" + record.UserName + "] 用灵币购买金币异常", exc);
                result.ResultCode = OperResult.RESULTCODE_EXCEPTION;
                return(result);
            }
            finally
            {
                if (myTrans != null)
                {
                    myTrans.Dispose();
                }
            }
        }
Exemple #5
0
        public bool SaveTempGoldCoinRechargeTradeRecord(GoldCoinRechargeRecord record)
        {
            MySqlConnection myconn = MyDBHelper.Instance.CreateConnection();
            MySqlCommand    mycmd  = null;

            try
            {
                myconn.Open();
                mycmd = myconn.CreateCommand();

                string cmdTextA = "insert into tempgoldcoinrechargerecord " +
                                  "(`OrderNumber`, `UserID`, `SpendRMB`, `GainGoldCoin`,`CreateTime`) values " +
                                  " (@OrderNumber, @UserID, @SpendRMB, @GainGoldCoin, @CreateTime); ";

                mycmd.CommandText = cmdTextA;
                mycmd.Parameters.AddWithValue("@OrderNumber", record.OrderNumber);
                mycmd.Parameters.AddWithValue("@UserID", record.UserID);
                mycmd.Parameters.AddWithValue("@SpendRMB", record.SpendRMB);
                mycmd.Parameters.AddWithValue("@GainGoldCoin", record.GainGoldCoin);
                mycmd.Parameters.AddWithValue("@CreateTime", record.CreateTime);

                mycmd.ExecuteNonQuery();
                return(true);
            }
            finally
            {
                if (mycmd != null)
                {
                    mycmd.Dispose();
                }
                if (myconn != null)
                {
                    myconn.Close();
                    myconn.Dispose();
                }
            }
        }
 public GoldCoinRechargeRecordUIModel(GoldCoinRechargeRecord parent)
 {
     this.ParentObject = parent;
 }
Exemple #7
0
        public int AlipayCallback(AlipayRechargeRecord alipayRecord)
        {
            GoldCoinRechargeRecord rechargeRecord = FindRecordByOrderNumber(alipayRecord.out_trade_no);

            if (rechargeRecord == null)
            {
                rechargeRecord = DBProvider.GoldCoinRecordDBProvider.GetGoldCoinRechargeRecord(alipayRecord.user_name, alipayRecord.out_trade_no);
                if (rechargeRecord != null)
                {
                    return(OperResult.RESULTCODE_ORDER_BUY_SUCCEED);
                }

                LogHelper.Instance.AddInfoLog("玩家[" + alipayRecord.user_name + "] 支付宝购买金币回调,找不到订单。支付宝信息:" + alipayRecord.ToString());
                return(OperResult.RESULTCODE_ORDER_NOT_EXIST);
            }
            CustomerMySqlTransaction myTrans = null;

            try
            {
                int value = OperResult.RESULTCODE_FALSE;
                myTrans = MyDBHelper.Instance.CreateTrans();

                alipayRecord.user_name = rechargeRecord.UserName;
                if (alipayRecord.out_trade_no == rechargeRecord.OrderNumber &&
                    alipayRecord.value_rmb >= rechargeRecord.SpendRMB)
                {
                    rechargeRecord.PayTime = DateTime.Now;
                    value = PlayerController.Instance.RechargeGoldCoinByAlipay(rechargeRecord.UserName, alipayRecord.total_fee, (int)rechargeRecord.SpendRMB, (int)(rechargeRecord.SpendRMB * GlobalConfig.GameConfig.RMB_GoldCoin), myTrans);
                    if (value == OperResult.RESULTCODE_TRUE)
                    {
                        DBProvider.GoldCoinRecordDBProvider.SaveFinalGoldCoinRechargeRecord(rechargeRecord, myTrans);
                        DBProvider.GoldCoinRecordDBProvider.DeleteTempGoldCoinRechargeTradeRecord(rechargeRecord.OrderNumber, myTrans);
                        this.RemoveRecord(alipayRecord.out_trade_no);

                        string tokenBuyer = ClientManager.GetToken(rechargeRecord.UserName);
                        if (GoldCoinOrderPaySucceedNotify != null)
                        {
                            GoldCoinOrderPaySucceedNotify(tokenBuyer, rechargeRecord.OrderNumber);
                        }

                        LogHelper.Instance.AddInfoLog("玩家[" + alipayRecord.user_name + "] 成功充值" + rechargeRecord.GainGoldCoin + "金币。ano: " + alipayRecord.alipay_trade_no);
                    }
                    else
                    {
                        LogHelper.Instance.AddInfoLog("玩家[" + alipayRecord.user_name + "] 金币充值失败,原因为:" + OperResult.GetMsg(value) + "。ano: " + alipayRecord.alipay_trade_no);
                    }
                }

                DBProvider.AlipayRecordDBProvider.SaveAlipayRechargeRecord(alipayRecord, myTrans);

                myTrans.Commit();
                return(value);
            }
            catch (Exception exc)
            {
                myTrans.Rollback();
                PlayerController.Instance.RefreshFortune(alipayRecord.user_name);

                LogHelper.Instance.AddErrorLog("玩家[" + alipayRecord.user_name + "] 支付宝金币充值,回调异常。AlipayInfo : " + alipayRecord.ToString(), exc);
                return(OperResult.RESULTCODE_EXCEPTION);
            }
            finally
            {
                if (myTrans != null)
                {
                    myTrans.Dispose();
                }
            }
        }