Esempio n. 1
0
        public bool SaveUserRemoteServerBuyRecord(UserRemoteServerBuyRecord record, CustomerMySqlTransaction myTrans)
        {
            MySqlCommand mycmd = null;

            try
            {
                mycmd = myTrans.CreateCommand();
                string sqlText = "insert into userremoteserverbuyrecord " +
                                 "(`UserID`, `ServerType`,`PayMoneyYuan`,`OrderNumber`,`GetShoppingCredits`,`BuyRemoteServerTime`) " +
                                 " values (@UserID, @ServerType, @PayMoneyYuan,@OrderNumber,@GetShoppingCredits,@BuyRemoteServerTime)";
                mycmd.CommandText = sqlText;

                mycmd.Parameters.AddWithValue("@UserID", record.UserID);
                mycmd.Parameters.AddWithValue("@ServerType", (int)record.ServerType);
                mycmd.Parameters.AddWithValue("@PayMoneyYuan", record.PayMoneyYuan);
                mycmd.Parameters.AddWithValue("@OrderNumber", record.OrderNumber);
                mycmd.Parameters.AddWithValue("@GetShoppingCredits", record.GetShoppingCredits);
                mycmd.Parameters.AddWithValue("@BuyRemoteServerTime", record.BuyRemoteServerTime);
                mycmd.ExecuteNonQuery();
                return(true);
            }
            finally
            {
                if (mycmd != null)
                {
                    mycmd.Dispose();
                }
            }
        }
 public UserRemoteServerBuyRecordUIModel(UserRemoteServerBuyRecord parent)
 {
     this.ParentObject = parent;
 }
        public int AlipayCallback(AlipayRechargeRecord alipay, RemoteServerType serverType)
        {
            int result = OperResult.RESULTCODE_FALSE;

            MyDBHelper.Instance.TransactionDataBaseOper(myTrans =>
            {
                DBProvider.AlipayRecordDBProvider.SaveAlipayRechargeRecord(alipay, myTrans);

                LogHelper.Instance.AddInfoLog("玩家 [" + alipay.user_name + "] 支付宝充值购买远程协助服务," + serverType.ToString() + ", Alipay:" + alipay.ToString());
                result = OperResult.RESULTCODE_TRUE;
                return(result);
            },
                                                        exc =>
            {
                if (exc != null)
                {
                    LogHelper.Instance.AddErrorLog("远程协助1服务付款回调异常,AlipayInfo: " + alipay.ToString() + "; serverType: " + serverType.ToString(), exc);
                }
                result = OperResult.RESULTCODE_EXCEPTION;
            });
            if (result != OperResult.RESULTCODE_TRUE)
            {
                return(result);
            }

            var serverItem = this.GetUserRemoteServerItem(serverType);

            if (serverItem == null)
            {
                LogHelper.Instance.AddInfoLog("玩家 [" + alipay.user_name + "] 支付宝充值购买远程协助服务失败1,原因为:" + OperResult.GetMsg(OperResult.RESULTCODE_BUYREMOTESERVER_FAILED_SERVERTYPEERROR));
                return(OperResult.RESULTCODE_BUYREMOTESERVER_FAILED_SERVERTYPEERROR);
            }
            if (alipay.total_fee != serverItem.PayMoneyYuan)
            {
                LogHelper.Instance.AddInfoLog("玩家 [" + alipay.user_name + "] 支付宝充值购买远程协助服务失败2,原因为:" + OperResult.GetMsg(OperResult.RESULTCODE_BUYREMOTESERVER_FAILED_PAYEDMONEYERROR));
                return(OperResult.RESULTCODE_BUYREMOTESERVER_FAILED_PAYEDMONEYERROR);
            }

            var playerRunner = PlayerController.Instance.GetRunnable(alipay.user_name);

            if (playerRunner == null)
            {
                LogHelper.Instance.AddInfoLog("玩家 [" + alipay.user_name + "] 支付宝充值购买远程协助服务失败3,原因为:" + OperResult.GetMsg(OperResult.RESULTCODE_USER_NOT_EXIST));
                return(OperResult.RESULTCODE_USER_NOT_EXIST);
            }

            int getShoppingCredits = (int)alipay.total_fee * GlobalConfig.GameConfig.RemoteServerRechargeReturnShoppingCreditsTimes;

            MyDBHelper.Instance.TransactionDataBaseOper(myTrans =>
            {
                result = playerRunner.BuyRemoteServer(alipay, serverType, myTrans);
                if (result != OperResult.RESULTCODE_TRUE)
                {
                    LogHelper.Instance.AddInfoLog("玩家 [" + alipay.user_name + "] 支付宝充值购买远程协助服务失败4,原因为:" + OperResult.GetMsg(result));
                    return(result);
                }

                //玩家购买远程服务充值三层返利,
                if (!string.IsNullOrEmpty(playerRunner.BasePlayer.SimpleInfo.ReferrerUserName))
                {
                    //上一级
                    var parent1PlayerRunner = PlayerController.Instance.GetRunnable(playerRunner.BasePlayer.SimpleInfo.ReferrerUserName);
                    if (parent1PlayerRunner != null)
                    {
                        parent1PlayerRunner.BuyShoppingCreditAwardParent(getShoppingCredits * GlobalConfig.GameConfig.BuyRemoteServiceAwardRMBConfig[0], myTrans);

                        //上二级
                        if (!string.IsNullOrEmpty(parent1PlayerRunner.BasePlayer.SimpleInfo.ReferrerUserName))
                        {
                            var parent2PlayerRunner = PlayerController.Instance.GetRunnable(parent1PlayerRunner.BasePlayer.SimpleInfo.ReferrerUserName);
                            if (parent2PlayerRunner != null)
                            {
                                parent2PlayerRunner.BuyShoppingCreditAwardParent(getShoppingCredits * GlobalConfig.GameConfig.BuyRemoteServiceAwardRMBConfig[1], myTrans);

                                //上三级
                                if (!string.IsNullOrEmpty(parent2PlayerRunner.BasePlayer.SimpleInfo.ReferrerUserName))
                                {
                                    var parent3PlayerRunner = PlayerController.Instance.GetRunnable(parent2PlayerRunner.BasePlayer.SimpleInfo.ReferrerUserName);
                                    if (parent3PlayerRunner != null)
                                    {
                                        parent3PlayerRunner.BuyShoppingCreditAwardParent(getShoppingCredits * GlobalConfig.GameConfig.BuyRemoteServiceAwardRMBConfig[2], myTrans);
                                    }
                                }
                            }
                        }
                    }
                }

                UserRemoteServerBuyRecord buyRecord = new UserRemoteServerBuyRecord()
                {
                    UserID              = playerRunner.BasePlayer.SimpleInfo.UserID,
                    UserName            = playerRunner.BasePlayer.SimpleInfo.UserLoginName,
                    OrderNumber         = alipay.out_trade_no,
                    BuyRemoteServerTime = new MyDateTime(DateTime.Now),
                    ServerType          = serverType,
                    PayMoneyYuan        = (int)alipay.total_fee,
                    GetShoppingCredits  = getShoppingCredits
                };
                DBProvider.UserRemoteServerDBProvider.SaveUserRemoteServerBuyRecord(buyRecord, myTrans);

                LogHelper.Instance.AddInfoLog("玩家 [" + alipay.user_name + "] 成功购买远程协助服务," + serverType.ToString() + ", Alipay:" + alipay.ToString());
                result = OperResult.RESULTCODE_TRUE;
                return(result);
            },
                                                        exc =>
            {
                if (exc != null)
                {
                    LogHelper.Instance.AddErrorLog("远程协助服务付款回调异常,AlipayInfo: " + alipay.ToString() + "; serverType: " + serverType.ToString(), exc);
                }
                result = OperResult.RESULTCODE_EXCEPTION;
            });

            return(result);
        }