Example #1
0
 public void MakeOrder(HttpContext context)
 {
     int Type = int.Parse(context.Request["Type"]);
     int GameId = int.Parse(context.Request["GameId"]);
     int ServerId = int.Parse(context.Request["ServerId"]);
     string SelMoney = context.Request["SelMoney"];
     string TxtMoney = context.Request["TxtMoney"];
     string UserName = context.Request["UserName"].Trim();
     string Bank = context.Request["Bank"];
     int PayType = int.Parse(context.Request["PayType"]);
     Orders order = new Orders();
     OrderManager om = new OrderManager();
     GameUserManager gum = new GameUserManager();
     GamesManager gm = new GamesManager();
     GameUser gu = new GameUser();
     try
     {
         gu = gum.GetGameUser((int)context.Session[Keys.SESSION_USER]);
     }
     catch (Exception)
     {
         if (PayType == 7)
         {
             context.Response.Write("/Home/Login");
             return;
         }
     }
     float PayMoney = 0;
     string OrderCode = Type == 1 ? "G" : "P";
     try
     {
         if (!string.IsNullOrEmpty(TxtMoney))
         {
             PayMoney = float.Parse(TxtMoney.Trim());
         }
         else
         {
             PayMoney = float.Parse(SelMoney);
         }
         order = om.GetOrder(OrderCode, GameId.ToString(), ServerId, Type, PayType, UserName, PayMoney, gu.UserName);
         if (PayType == 7)
         {
             if (om.AddOrder(order))
             {
                 string Result = gm.PayManager(order.OrderNo);
                 context.Response.Write("您的订单" + order.OrderNo + "已经处理。处理结果:" + Result + "|Error");
                 return;
             }
             else
             {
                 context.Response.Write("添加订单失败!|Error");
                 return;
             }
         }
         else
         {
             if (om.AddOrder(order))
             {
                 context.Response.Write("/PayCenter/PayOrder?Order=" + DESEncrypt.encryptstring1(order.OrderNo) + "&Bank=" + Bank + "|Success");
             }
             else
             {
                 context.Response.Write("添加订单失败!|Error");
                 return;
             }
         }
     }
     catch (Exception e)
     {
         context.Response.Write(e.Message + "|Error");
         return;
     }
 }
Example #2
0
 /// <summary>
 /// 验证订单
 /// </summary>
 /// <param name="GameId">游戏Id</param>
 /// <param name="ServerId">服务器Id</param>
 /// <param name="Type">充值类型</param>
 /// <param name="PayTypeId">充值方式</param>
 /// <param name="UserName">充值目标账户</param>
 /// <param name="Money">充值金额</param>
 /// <param name="AdminUserName">充值操作用户</param>
 /// <returns></returns>
 public Boolean CheckOrder(string GameId, int ServerId, int Type, int PayTypeId, string UserName, float Money, string AdminUserName)
 {
     GameUserManager gum = new GameUserManager();
     GamesManager gm = new GamesManager();
     if (!string.IsNullOrEmpty(UserName))                                    //验证用户名不能为空
     {
         if (gum.IsGameUser(UserName))                                       //验证用户是否存在
         {
             if (Type == 1 && ServerId > 0)                                   //验证区是否选择区服
             {
                 GameUserInfo gui = gm.GetGameUserInfo(int.Parse(GameId), gum.GetGameUser(UserName).Id, ServerId);
                 if (gui.Message == "Success") //验证用户是否在所选区服中存在角色
                 {
                     if (PayTypeId == 6)                                         //验证手动充值必须满足的一些条件
                     {
                         if (Money >= 1 && Money % 1 == 0)                       //订单金额必须大于等于1且必须为1的整数
                         {
                             return true;
                         }
                         else
                         {
                             throw new Exception("您输入的金额有误!");
                         }
                     }
                     else if (PayTypeId == 7)                                    //验证平台币充值必须满足的一些条件
                     {
                         if (Money >= 10 && Money % 10 == 0)                     //订单金额必须大于等于10且必须为10的整数
                         {
                             if (gum.GetGameUser(AdminUserName).Money >= Money)   //玩家平台币余额必须大于等于充值金额
                             {
                                 return true;
                             }
                             else
                             {
                                 throw new Exception("您的余额不足!");
                             }
                         }
                         else
                         {
                             throw new Exception("您输入的金额有误!");
                         }
                     }
                     else                                                        //验证其他充值方式必须满的一些条件
                     {
                         if (Money >= 5 && Money % 1 == 0)                       //订单金额必须大于等于5且必须为1的整数
                         {
                             return true;
                         }
                         else
                         {
                             throw new Exception("您输入的金额有误!");
                         }
                     }
                 }
                 else
                 {
                     throw new Exception(gui.Message);
                 }
             }
             else if (Type == 2)
             {
                 if (PayTypeId == 6)                                         //验证手动充值必须满足的一些条件
                 {
                     if (Money >= 1 && Money % 1 == 0)                       //订单金额必须大于等于1且必须为1的整数
                     {
                         return true;
                     }
                     else
                     {
                         throw new Exception("您输入的金额有误!");
                     }
                 }
                 else                                                        //验证其他充值方式必须满的一些条件
                 {
                     if (Money >= 5 && Money % 1 == 0)                       //订单金额必须大于等于5且必须为1的整数
                     {
                         return true;
                     }
                     else
                     {
                         throw new Exception("您输入的金额有误!");
                     }
                 }
             }
             else
             {
                 throw new Exception("请选择游戏服务器!");
             }
         }
         else
         {
             throw new Exception("用户不存在!");
         }
     }
     else
     {
         throw new Exception("用户名不能为空!");
     }
 }
Example #3
0
        /// <summary>
        /// 验证订单
        /// </summary>
        /// <param name="GameId">游戏Id</param>
        /// <param name="ServerId">服务器Id</param>
        /// <param name="Type">充值类型</param>
        /// <param name="PayTypeId">充值方式</param>
        /// <param name="UserName">充值目标账户</param>
        /// <param name="Money">充值金额</param>
        /// <param name="AdminUserName">充值操作用户</param>
        /// <returns></returns>
        public Boolean CheckOrder(string GameId, int ServerId, int Type, int PayTypeId, string UserName, float Money, string AdminUserName)
        {
            GameUserManager gum = new GameUserManager();
            GamesManager    gm  = new GamesManager();

            if (!string.IsNullOrEmpty(UserName))                                    //验证用户名不能为空
            {
                if (gum.IsGameUser(UserName))                                       //验证用户是否存在
                {
                    if (Type == 1 && ServerId > 0)                                  //验证区是否选择区服
                    {
                        GameUserInfo gui = gm.GetGameUserInfo(int.Parse(GameId), gum.GetGameUser(UserName).Id, ServerId);
                        if (gui.Message == "Success")             //验证用户是否在所选区服中存在角色
                        {
                            if (PayTypeId == 6)                   //验证手动充值必须满足的一些条件
                            {
                                if (Money >= 1 && Money % 1 == 0) //订单金额必须大于等于1且必须为1的整数
                                {
                                    return(true);
                                }
                                else
                                {
                                    throw new Exception("您输入的金额有误!");
                                }
                            }
                            else if (PayTypeId == 7)                                    //验证平台币充值必须满足的一些条件
                            {
                                if (Money >= 10 && Money % 10 == 0)                     //订单金额必须大于等于10且必须为10的整数
                                {
                                    if (gum.GetGameUser(AdminUserName).Money >= Money)  //玩家平台币余额必须大于等于充值金额
                                    {
                                        return(true);
                                    }
                                    else
                                    {
                                        throw new Exception("您的余额不足!");
                                    }
                                }
                                else
                                {
                                    throw new Exception("您输入的金额有误!");
                                }
                            }
                            else                                                        //验证其他充值方式必须满的一些条件
                            {
                                if (Money >= 5 && Money % 1 == 0)                       //订单金额必须大于等于5且必须为1的整数
                                {
                                    return(true);
                                }
                                else
                                {
                                    throw new Exception("您输入的金额有误!");
                                }
                            }
                        }
                        else
                        {
                            throw new Exception(gui.Message);
                        }
                    }
                    else if (Type == 2)
                    {
                        if (PayTypeId == 6)                                         //验证手动充值必须满足的一些条件
                        {
                            if (Money >= 1 && Money % 1 == 0)                       //订单金额必须大于等于1且必须为1的整数
                            {
                                return(true);
                            }
                            else
                            {
                                throw new Exception("您输入的金额有误!");
                            }
                        }
                        else                                                        //验证其他充值方式必须满的一些条件
                        {
                            if (Money >= 5 && Money % 1 == 0)                       //订单金额必须大于等于5且必须为1的整数
                            {
                                return(true);
                            }
                            else
                            {
                                throw new Exception("您输入的金额有误!");
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("请选择游戏服务器!");
                    }
                }
                else
                {
                    throw new Exception("用户不存在!");
                }
            }
            else
            {
                throw new Exception("用户名不能为空!");
            }
        }