/// <summary> /// 天行剑充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回支付结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5(OrderNo + gu.UserName + PayGold + order.PayMoney + tstamp + gc.PayTicket, 32); string PayUrl = "http://" + gs.ServerNo + "." + gc.PayCom + "?orderid=" + OrderNo + "&username="******"&gold=" + PayGold + "&money=" + order.PayMoney + "&time=" + tstamp + "&flag=" + Sign + "&channel="; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) //对充值结果进行解析 { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值成功!错误原因:更新订单状态失败!"; } case "2": return "充值失败!无法提交重复订单!"; case "-1": return "充值失败!参数不全!"; case "-2": return "充值失败!验证失败!"; case "-3": return "充值失败!用户不存在!"; case "-4": return "充值失败!请求超时!"; case "-5": return "充值失败!充值比例异常!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!用户不存在!"; } }
/// <summary> /// 添加一笔订单 /// </summary> /// <param name="o">订单</param> /// <returns>返回是否添加成功</returns> public Boolean AddOrder(Orders o) { try { string sql = "insert into orders(orderno,type,paytypeid,state,username,pmoney,paymoney,paytime,ip,gameid,serverid,gamename,servername,AdminUserName)" + "values(@OrderNo,@Type,@PayTypeId,@State,@UserName,@PMoney,@PayMoney,@PayTime,@Ip,@GameId,@ServerId,@GameName,@ServerName,@AdminUserName)"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@OrderNo", o.OrderNo), new SqlParameter("@Type",o.Type), new SqlParameter("@PayTypeId",o.PayTypeId), new SqlParameter("@State", o.State), new SqlParameter("@UserName",o.UserName), new SqlParameter("@PMoney",o.PMoney), new SqlParameter("@PayMoney", o.PayMoney), new SqlParameter("@PayTime",o.PayTime), new SqlParameter("@Ip",o.Ip), new SqlParameter("@GameId", o.GameId), new SqlParameter("@ServerId",o.ServerId), new SqlParameter("@GameName",o.GameName), new SqlParameter("@ServerName",o.ServerName), new SqlParameter("@AdminUserName", o.AdminUserName) }; return db.ExecuteNonQuery(sql, sp); } catch (SqlException ex) { throw new Exception("数据库异常!原因:" + ex.Message); } catch (Exception ex) { throw new Exception("未知异常!原因:" + ex.Message); } }
/// <summary> /// 封天传充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5("[" + gc.PayTicket + gu.UserName + "1" + order.PayMoney + tstamp + "]", 32); string PayUrl = "http://" + gs.ServerNo + "." + gc.PayCom + "?userName="******"&goodsId=1&num=" + order.PayMoney + "&time=" + tstamp + "&sign=" + Sign + "&orderId=" + OrderNo + "&source=tt&serverId=" + gs.ServerNo; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { try { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "0": return "充值失败!错误原因:充值失败!"; case "2": return "充值失败!错误原因:无法提交重复订单!"; default: return "充值失败!未知错误!"; } } catch (Exception) { return "充值失败!错误原因:充值失败!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!错误原因:用户不存在"; } }
/// <summary> /// 一剑轩辕充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5(gu.UserName + "|" + tstamp + "|" + PayGold + "|" + gs.QuFu + "|" + gc.PayTicket, 32); string PayUrl = "http://" + gs.ServerNo + "." + gc.PayCom + "?accname=" + gu.UserName + "&paytime=" + tstamp + "&gold=" + PayGold + "&billno=" + OrderNo + "&serverid=" + gs.QuFu + "&sign=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 Dictionary<string, string> PRE = Json.JsonToArray(PayResult); switch (PRE["ret"]) //对充值结果进行解析 { case "0": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "1": return "充值失败!错误原因:角色不存在!"; case "2": return "充值失败!错误原因:无法提交重复订单!"; case "3": return "充值失败!错误原因:验证失败!"; case "4": return "充值失败!错误原因:参数错误!"; case "5": return "充值失败!错误原因:非法Ip!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return "充值失败!角色不存在!"; } } else { return "充值失败!用户不存在!"; } }
/// <summary> /// 怒斩充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5(order.PayMoney + gu.Id.ToString() + OrderNo + tstamp + gc.PayTicket, 32); string PayUrl = "http://" + gs.ServerNo + "." + gc.PayCom + "exchange.php?amount=" + order.PayMoney + "&u=" + gu.Id + "&order_no=" + OrderNo + "&time=" + tstamp + "&sign=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) //对充值结果进行解析 { case "success": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "err_time": return "充值失败!错误原因:订单请求超时!"; case "err_sign": return "充值失败!错误原因:验证参数错误!"; case "err_repeat": return "充值失败!错误原因:无法提交重复订单!"; case "fail": return "充值失败!错误原因:其它错误!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return "充值失败!角色不存在!"; } } else { return "充值失败!用户不存在!"; } }
/// <summary> /// 盗魂传充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5(gc.AgentId + "|" + gu.UserName + "|" + gs.ServerNo + "|" + tstamp + "|" + OrderNo + "|" + PayGold + "|" + gc.PayTicket, 32); //获取验证参数 string PayUrl = "http://" + gc.PayCom + "?ptid=" + gc.AgentId + "&account=" + gu.UserName + "&areaid=" + gs.ServerNo + "&tt=" + tstamp + "&orderno=" + OrderNo + "&point=" + PayGold + "&sign=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 PayResult = PayResult.Substring(0, PayResult.IndexOf('}')); //处理返回结果 PayResult = PayResult.Replace(PayResult.Substring(0, PayResult.LastIndexOf('{') + 1), ""); string[] b = PayResult.Split(','); switch (b[0].Substring(13)) //对充值结果进行解析 { case "0": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "1": return "充值失败!错误原因:商家错误或者不存在!"; case "2": return "订单重复,之前已经处理成功!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return "充值失败!角色不存在!"; } } else { return "充值失败!用户不存在!"; } }
/// <summary> /// 热血海贼王充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns></returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要登录的服务器 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 Sign = DESEncrypt.Md5(gu.Id.ToString() + order.PayMoney + OrderNo + gs.ServerNo + gc.PayTicket, 32); //获取验证参数 string PayUrl = "http://" + gs.ServerNo + "." + gc.PayCom + "?qid=" + gu.Id + "&order_amount=" + order.PayMoney + "&order_id=" + OrderNo + "&server_id=" + gs.ServerNo + "&sign=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值返回结果 switch (PayResult) //对充值结果进行解析 { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "2": return "充值失败!无法提交重复订单!"; case "0": return "充值失败!未知原因!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!用户不存在!"; } }
/// <summary> /// 抽奖系统自动发放奖励 /// </summary> /// <param name="UserName">用户名</param> /// <param name="Money">金额</param> /// <returns>返回发放结果</returns> public string AddUserMoney(string UserName, float Money) { try { Orders order = new Orders(); order = om.GetOrder("J", "0", 0, 2, 6, UserName, Money, "抽奖系统"); order.State = 1; if (om.AddOrder(order)) { return gm.PayManager(order.OrderNo); } else { return "添加订单失败!"; } } catch (Exception e) { return e.Message; } }
/// <summary> /// 通过分页获取推广付费详情 /// </summary> /// <param name="PageSize">页大小</param> /// <param name="PageNum">页码</param> /// <param name="UserId">用户Id</param> /// <returns>返回订单集合</returns> public List<Orders> GetAllSpreadPay(int PageSize, int PageNum, int UserId, string GameId, string StartTime, string EndTime) { List<Orders> list = new List<Orders>(); try { SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@UserId",UserId), new SqlParameter("@PageSize",PageSize), new SqlParameter("@PageNum",PageNum), new SqlParameter("@StartTime",StartTime), new SqlParameter("@EndTime",EndTime), new SqlParameter("@GameId",GameId) }; using (SqlDataReader reder = db.GetReaderByProc("Proc_Page_SpreadPay", sp)) { while (reder.Read()) { Orders order = new Orders((int)reder["id"], reder["orderno"].ToString(), (int)reder["type"], (int)reder["paytypeid"], (int)reder["state"], reder["username"].ToString(), float.Parse(reder["pmoney"].ToString()), float.Parse(reder["paymoney"].ToString()), (DateTime)reder["paytime"], reder["ip"].ToString(), (int)reder["gameid"], (int)reder["serverid"], reder["gamename"].ToString(), reder["servername"].ToString(), reder["phone"].ToString(), float.Parse(reder["rebatenum"].ToString()), (int)reder["rebateid"], (int)reder["convertid"], reder["AdminUserName"].ToString()); list.Add(order); } }; } catch (SqlException ex) { throw new Exception("数据库异常!原因:" + ex.Message); } catch (Exception ex) { throw new Exception("未知异常!原因:" + ex.Message); } return list; }
/// <summary> /// 添加一笔订单 /// </summary> /// <param name="o">订单</param> /// <returns>返回是否添加成功</returns> public Boolean AddOrder(Orders o) { return os.AddOrder(o); }
/// <summary> /// 大侠传充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 string url = string.Format("op_id={0}&sid={1}&game_id={2}&account={3}&order_id={4}&game_money={5}&u_money={6}&time={7}", gc.AgentId, gs.ServerNo, 8, gu.UserName, OrderNo, PayGold, order.PayMoney, tstamp); //获取验证字符串 Base64Protector bp = new Base64Protector(); Auth = bp.Base64Code(url); //获取验证码 Sign = DESEncrypt.Md5(Auth + gc.PayTicket, 32); //获取验证参数 string PayUrl = "http://" + gc.PayCom + "?auth=" + Auth + "&verify=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 PayResult = PayResult.Substring(0, PayResult.IndexOf('}')); //处理充值结果 PayResult = PayResult.Replace(PayResult.Substring(0, PayResult.LastIndexOf('{') + 1), ""); switch (PayResult.Substring(9)) //对充值结果进行解析 { case "0": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "1": return "充值失败!错误原因:商家错误或者不存在!"; case "2": return "充值失败!错误原因:服务器不存在!"; case "3": return "充值失败!错误原因:游戏不存在!"; case "4": return "充值失败!错误原因:无效时间戳!"; case "5": return "充值失败!错误原因:检验码错误!"; case "6": return "充值失败!错误原因:缺少参数!"; case "7": return "充值失败!错误原因:订单号不存在!"; case "8": return "充值失败!错误原因:角色不存在!"; case "9": return "充值失败!错误原因:排行榜类型不存在!"; case "10": return "充值失败!错误原因:方法名字错误!"; case "11": return "充值失败!错误原因:非法IP!"; case "12": return "充值失败!错误原因:充值金额不对!"; case "13": return "充值失败!错误原因:游戏币金额不对!"; case "14": return "充值失败!错误原因:游戏币和游戏币币比列不对!"; case "100": return "充值失败!未知原因"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return "充值失败!角色不存在!"; } } else { return "充值失败!用户不存在!"; } }
public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5(("amount=" + order.PayMoney + "&gid=221&money=" + order.PayMoney + "&oid=" + OrderNo + "&pid=" + gc.AgentId + "&point=" + PayGold + "&sid=" + gs.QuFu + "&uid=" + gu.UserName + "&utime=" + tstamp).ToUpper() + gc.PayTicket, 32); string PayUrl = "http://" + gc.PayCom + "?pid=" + gc.AgentId + "&gid=221&sid=" + gs.QuFu + "&uid=" + gu.UserName + "&point=" + PayGold + "&amount=" + order.PayMoney + "&money=" + order.PayMoney + "&oid=" + OrderNo + "&utime=" + tstamp + "&sign=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { try { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值成功!发生错误:更新订单状态失败!"; } case "11": return "充值失败!错误原因:金额错误!"; case "2006209": return "充值失败!错误原因:参数错误!"; case "13": return "充值失败!错误原因:请求方式错误!"; case "17": return "充值失败!错误原因:验证失败!"; case "10": return "充值失败!错误原因:充值服务器不存在!"; case "14": return "充值失败!错误原因:请求超时!"; case "18": return "充值失败!错误原因:非法请求的IP!"; case "19": return "充值失败!错误原因:充值游戏不存在!"; case "20": return "充值失败!错误原因:充值比例错误!"; case "-10": return "充值失败!错误原因:无效的服务器!"; case "-11": return "充值失败!错误原因:无效的玩家帐号!"; case "12": case "-12": return "充值失败!错误原因:无法提交重复订单!"; case "-14": return "充值失败!错误原因:无效的时间!"; case "-15": return "充值失败!错误原因:充值金额错误!"; case "-17": return "充值失败!错误原因:无效的时间!"; case "-18": return "充值失败!错误原因:验证失败!"; default: return "充值失败!未知错误!"; } } catch (Exception) { return "充值失败!错误原因:充值失败!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!错误原因:用户不存在"; } }
/// <summary> /// 生成一个订单 /// </summary> /// <param name="OrderCode">订单标识码</param> /// <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">充值金额(RMB/元)</param> /// <param name="AdminUserName">操作员</param> /// <returns></returns> public Orders GetOrder(string OrderCode, string GameId, int ServerId, int Type, int PayTypeId, string UserName, float Money, string AdminUserName) { Thread.Sleep(8); Orders o = new Orders(); if (CheckOrder(GameId, ServerId, Type, PayTypeId, UserName, Money, AdminUserName)) { GameServerServers gss = new GameServerServers(); GamesServers gs = new GamesServers(); o.Type = Type; o.PayTypeId = PayTypeId; o.State = 0; o.UserName = UserName; o.PayTime = DateTime.Now; o.Ip = BBRequest.GetIP(); if (!string.IsNullOrEmpty(AdminUserName)) { o.AdminUserName = AdminUserName; } else { o.AdminUserName = "******"; } if (PayTypeId == 7) { o.PMoney = o.PayMoney = Money / 10; } else { o.PMoney = o.PayMoney = Money; } if (Type == 1) { if (GameId.ToString().Length == 1) { GameId = "00" + GameId; } else if (GameId.ToString().Length == 2) { GameId = "0" + GameId; } o.OrderNo = OrderCode + DateTime.Now.ToString("yyyyMMddHHmmss") + DateTime.Now.Millisecond + GameId + gss.GetGameServer(ServerId).QuFu; o.GameId = int.Parse(GameId); o.ServerId = ServerId; o.GameName = gs.GetGame(o.GameId).Name; o.ServerName = gss.GetGameServer(ServerId).Name; } else { o.OrderNo = OrderCode + DateTime.Now.ToString("yyyyMMddHHmmss") + DateTime.Now.Millisecond + 0 + 0; o.GameId = 0; o.ServerId = 0; o.GameName = "适用所有游戏"; o.ServerName = "适用所有区服"; } } return o; }
/// <summary> /// 太古遮天充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5(OrderNo + gu.UserName + PayGold + tstamp + gc.PayTicket + gc.AgentId + gs.QuFu + order.PayMoney, 32); string PayUrl = "http://" + gc.PayCom + "/api/v1/mc/pay.php?order=" + OrderNo + "&username="******"&money=" + order.PayMoney + "&gold=" + PayGold + "&time=" + tstamp + "&flag=" + Sign + "&server=" + gs.QuFu + "&agentName=" + gc.AgentId + "&moneyType=1"; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { try { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "2": return "充值失败!错误原因:该订单已提交,请勿重复提交!"; case "-1": return "充值失败!错误原因:参数错误!"; case "-2": return "充值失败!错误原因:验证失败!"; case "-3": return "充值失败!错误原因:账号不存在!"; case "-4": return "充值失败!错误原因:请求超时!"; case "-5": return "充值失败!错误原因:非法访问IP!"; case "-6": return "充值失败!错误原因:其他未知错误!"; default: return "充值失败!未知错误!"; } } catch (Exception) { return "充值失败!错误原因:充值失败!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!错误原因:用户不存在"; } }
/// <summary> /// 奇迹来了充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5("orderid=" + OrderNo + "&money=" + order.PayMoney + "&paypoint=" + PayGold + "&platid=" + gc.AgentId + "&platuid=" + gu.Id + "&sid=" + gs.ServerNo + "&tm=" + tstamp + gc.PayTicket, 32); //获取验证参数 string PayUrl = "http://" + gs.ServerNo + "." + gc.PayCom + "?orderid=" + OrderNo + "&money=" + order.PayMoney + "&paypoint=" + PayGold + "&platid=" + gc.AgentId + "&platuid=" + gu.Id + "&sid=" + gs.ServerNo + "&tm=" + tstamp + "&sig=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) //对充值结果进行解析 { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值成功!发生错误:更新订单状态失败!"; } case "-1": return "充值失败!错误原因:参数错误!"; case "-2": return "充值失败!错误原因:请求超时!"; case "-3": return "充值失败!错误原因:服务器或平台不存在!"; case "-4": return "充值失败!错误原因:验证失败!"; case "-5": return "充值失败!错误原因:用户不存在!"; case "-6": return "充值失败!错误原因:非法的访问IP!"; case "-7": return "充值失败!错误原因:无法提交重复订单!"; case "-8": return "充值失败!错误原因:订单重发时前后不一致!"; case "0": return "充值失败!错误原因:充值失败!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return "充值失败!角色不存在!"; } } else { return "充值失败!用户不存在!"; } }
/// <summary> /// 楚汉传奇充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5("from=" + gc.AgentId + "game=chuhan" + "server=" + gs.ServerNo + "user_id=" + gu.UserName + "amount=" + order.PayMoney * 100 + "order_number=" + OrderNo + "t=" + tstamp + "transfer_secret_signature=" + gc.PayTicket, 32); string PayUrl = "http://" + gc.PayCom + "?from=" + gc.AgentId + "&game=chuhan&server=" + gs.ServerNo + "&user_id=" + gu.UserName + "&amount=" + order.PayMoney * 100 + "&order_number=" + OrderNo + "&t=" + tstamp + "&signature=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { try { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 PayResult = PayResult.Substring(0, PayResult.IndexOf('}')); //处理充值结果 PayResult = PayResult.Replace(PayResult.Substring(0, PayResult.LastIndexOf('{') + 1), ""); string[] b = PayResult.Split(','); if (b[2] == "\"status\":1") { if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } } else { switch (b[0]) { case "\"status\":1": case "\"status\":-6": return "充值失败!错误原因:充值失败!"; case "\"status\":-93": return "充值失败!错误原因:签名错误!"; default: return "充值失败!未知错误!"; } } } catch (Exception) { return "充值失败!错误原因:充值失败!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!错误原因:用户不存在"; } }
/// <summary> /// 大清英雄传充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5(gu.UserName + tstamp + OrderNo + PayGold + order.PayMoney + gs.QuFu + gc.PayTicket, 32); //获取验证参数 string PayUrl = "http://" + gc.PayCom + "?sid=" + gc.AgentId + "&gid=1&servid=" + gs.ServerNo + "&username="******"&rmb=" + order.PayMoney + "&orderid=" + OrderNo + "&paytime=" + tstamp + "&md5=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) //对充值结果进行解析 { case "0": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "-1": return "充值失败!错误原因:用户不存在!"; case "-2": return "充值失败!错误原因:无法提交重复订单!"; case "-3": return "充值失败!错误原因:服务器不存在!"; case "-4": return "充值失败!错误原因:服务器繁忙!"; case "-5": return "充值失败!错误原因:没有权限!"; case "-6": return "充值失败!错误原因:超过最大额度!"; case "-7": return "充值失败!错误原因:验证失败!"; case "-8": return "充值失败!错误原因:其它错误!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return "充值失败!角色不存在!"; } } else { return "充值失败!用户不存在!"; } }
/// <summary> /// 武尊充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回订单结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5("7" + gc.AgentId + gs.QuFu + gu.Id + gu.UserName + OrderNo + order.PayMoney + tstamp + gc.PayTicket, 32); //获取验证参数 string PayUrl = "http://" + gc.PayCom + "?orderid=" + OrderNo + "&partnerid=" + gc.AgentId + "&gameid=7&sid=" + gs.QuFu + "&userid=" + gu.Id + "&username="******"&actorid=&actorname=&money=" + order.PayMoney + "&time=" + tstamp + "&sign=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) //对充值结果进行解析 { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "2": return "充值失败!错误原因:缺少参数!"; case "3": return "充值失败!错误原因:验证失败!"; case "4": return "充值失败!错误原因:非法的访问IP!"; case "5": return "充值失败!错误原因:合作方不存在!"; case "6": return "充值失败!错误原因:充值的游戏不存在!"; case "7": return "充值失败!错误原因:游戏未登记!"; case "8": return "充值失败!错误原因:游戏服务器未登记!"; case "9": return "充值失败!错误原因:合作商未开启!"; case "10": return "充值失败!错误原因:游戏未开启!"; case "11": return "充值失败!错误原因:游戏服务器未开启!"; case "12": return "充值失败!错误原因:充值金额不对!"; case "13": return "充值失败!错误原因:游戏币金额不对!"; case "14": return "充值失败!错误原因:游戏未创建!"; case "15": return "充值失败!错误原因:请求超时!"; case "-1": return "充值失败!错误原因:玩家角色不存在!"; case "-2": return "充值失败!错误原因:无法提交重复的订单号!"; case "-3": return "充值失败!错误原因:游戏签名失败!"; case "-4": return "充值失败!错误原因:游戏非法的访问IP!"; case "-5": return "充值失败!错误原因:游戏缺少参数!"; case "-6": return "充值失败!错误原因:充值失败!"; case "-7": return "充值失败!错误原因:充值异常!"; case "-8": return "充值失败!错误原因:游戏请求超时!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!用户不存在!"; } }
/// <summary> /// 冒险契约充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5(gu.UserName + gc.AgentId + OrderNo + order.PayMoney + gc.PayTicket + tstamp + gs.ServerNo + "mxqy", 32); string PayUrl = "http://" + gc.PayCom + "?game=mxqy&agent=" + gc.AgentId + "&user="******"&order=" + OrderNo + "&money=" + order.PayMoney + "&server=" + gs.ServerNo + "&time=" + tstamp + "&sign=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "0": return "充值失败!错误原因:参数不全!"; case "2": return "充值失败!错误原因:不存在的合作方!"; case "3": return "充值失败!错误原因:金额错误!"; case "4": return "充值失败!错误原因:服务器不存在!"; case "5": return "充值失败!错误原因:验证失败!"; case "6": return "充值失败!错误原因:游戏不存在!"; case "7": return "充值失败!错误原因:角色不存在!"; case "-7": return "充值失败!错误原因:无法提交重复订单!"; case "-1": return "充值失败!错误原因:非法访问的IP!"; case "-4": return "充值失败!错误原因:未知错误!"; case "-102": return "充值失败!错误原因:游戏无响应!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!错误原因:用户不存在"; } }
public void zfbeOrder(HttpContext context) { Orders order = new Orders(); string OrderNo = context.Request["OrderNo"]; OrderManager om = new OrderManager(); order = om.GetOrder(OrderNo); if (order.PayTypeId == 8) { //支付类型 string payment_type = "1"; //必填,不能修改 //服务器异步通知页面路径 string notify_url = ConfigurationManager.AppSettings["zfbmsg"].ToString(); //需http://格式的完整路径,不能加?id=123这类自定义参数 //页面跳转同步通知页面路径 string return_url = ConfigurationManager.AppSettings["zfbreurl"].ToString(); //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ //卖家支付宝帐户 string seller_email = ConfigurationManager.AppSettings["zfbuser"].ToString(); //必填 //商户订单号 string out_trade_no = order.OrderNo; //商户网站订单系统中唯一订单号,必填 //订单名称 string subject = order.Type == 1 ? "5577yx平台游戏币" : "5577yx平台币" + "充值"; //必填 //付款金额 string total_fee = order.PayMoney.ToString(); //必填 //订单描述 string body = order.GameName + order.ServerName; //商品展示地址 string show_url = ""; //需以http://开头的完整路径,例如:http://www.xxx.com/myorder.html //防钓鱼时间戳 string anti_phishing_key = Common.Submit.Query_timestamp(); //若要使用请调用类文件submit中的query_timestamp函数 //客户端的IP地址 string exter_invoke_ip = ""; //非局域网的外网IP地址,如:221.0.0.1 //把请求参数打包成数组 SortedDictionary<string, string> sParaTemp = new SortedDictionary<string, string>(); sParaTemp.Add("partner", Config.Partner); sParaTemp.Add("_input_charset", Config.Input_charset.ToLower()); sParaTemp.Add("service", "create_direct_pay_by_user"); sParaTemp.Add("payment_type", payment_type); sParaTemp.Add("notify_url", notify_url); sParaTemp.Add("return_url", return_url); sParaTemp.Add("seller_email", seller_email); sParaTemp.Add("out_trade_no", out_trade_no); sParaTemp.Add("subject", subject); sParaTemp.Add("total_fee", total_fee); sParaTemp.Add("body", body); sParaTemp.Add("show_url", show_url); sParaTemp.Add("anti_phishing_key", anti_phishing_key); sParaTemp.Add("exter_invoke_ip", exter_invoke_ip); //建立请求 string sHtmlText = Submit.BuildRequest(sParaTemp, "post", "确认"); context.Response.Write(sHtmlText); } else { context.Response.Write("NoZfb"); } }
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; } }
public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5(OrderNo + gu.UserName + PayGold + tstamp + gc.PayTicket, 32); //获取验证参数 string PayUrl = "http://" + gs.ServerNo + "." + gc.PayCom + "?p=" + OrderNo + "|" + gu.UserName + "|" + PayGold + "|" + tstamp + "|" + Sign + "|" + order.PayMoney + "|" + gs.ServerNo; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 XmlDocument MyXml = new XmlDocument(); MyXml.LoadXml(PayResult); XmlNode ShowList = MyXml.DocumentElement; switch (ShowList.InnerText) //对充值结果进行解析 { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值成功!发生错误:更新订单状态失败!"; } case "2": return "充值失败!错误原因:无法提交重复订单!"; case "-1": return "充值失败!错误原因:参数不正确!"; case "-2": return "充值失败!错误原因:验证失败!"; case "-3": return "充值失败!错误原因:用户不存在!"; case "-4": return "充值失败!错误原因:请求超时!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return "充值失败!角色不存在!"; } } else { return "充值失败!用户不存在!"; } }
/// <summary> /// 根据订单号获取订单 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回订单信息</returns> public Orders GetOrder(string OrderNo) { Orders order = null; ; try { string sql = "select * from orders where orderno=@OrderNo"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@OrderNo",OrderNo) }; using (SqlDataReader reder = db.GetReader(sql, sp)) { while (reder.Read()) { order = new Orders((int)reder["id"], reder["orderno"].ToString(), (int)reder["type"], (int)reder["paytypeid"], (int)reder["state"], reder["username"].ToString(), float.Parse(reder["pmoney"].ToString()), float.Parse(reder["paymoney"].ToString()), (DateTime)reder["paytime"], reder["ip"].ToString(), (int)reder["gameid"], (int)reder["serverid"], reder["gamename"].ToString(), reder["servername"].ToString(), reder["phone"].ToString(), float.Parse(reder["rebatenum"].ToString()), (int)reder["rebateid"], (int)reder["convertid"], reder["AdminUserName"].ToString()); } } } catch (SqlException ex) { throw new Exception("数据库异常!原因:" + ex.Message); } catch (Exception ex) { throw new Exception("未知异常!原因:" + ex.Message); } return order; }
/// <summary> /// 神将三国充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要登录的服务器 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 Sign = DESEncrypt.Md5(gc.AgentId + gu.UserName + OrderNo + gs.ServerNo + "sjsg" + order.PayMoney + tstamp + gc.PayTicket, 32); //获取验证参数 string PayUrl = "http://" + gc.PayCom + "?game=sjsg&agent=" + gc.AgentId + "&user="******"&order=" + OrderNo + "&money=" + order.PayMoney + "&server=" + gs.ServerNo + "&time=" + tstamp + "&sign=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值返回结果 switch (PayResult) //对充值结果进行解析 { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "0": return "充值失败!参数不正确!"; case "2": return "充值失败!合作方不存在!"; case "3": return "充值失败!金额有误!"; case "4": return "充值失败!不存在的服务器!"; case "5": return "充值失败!验证失败!"; case "6": return "充值失败!充值游戏不存在!"; case "7": return "充值失败!玩家角色不存在!"; case "-7": return "充值失败!无法提交相同订单!"; case "-1": return "充值失败!非法的访问IP!"; case "-4": return "充值失败!验证失败!"; case "-102": return "充值失败!充值异常,游戏方无响应!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return "充值失败!角色不存在!"; } } else { return "充值失败!用户不存在!"; } }
/// <summary> /// 绝代双骄充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要登录的服务器 tstamp = DateTime.Now.ToString("yyyyMMddHHmmss"); //获取时间戳 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 Sign = DESEncrypt.Md5("uid=" + gu.Id + "&uname=" + gu.UserName + "&serverid=" + gs.ServerNo + "&point=" + PayGold + "&amount=" + order.PayMoney + "&oid=" + OrderNo + "&time=" + tstamp + "&type=" + gc.AgentId + "&key=" + gc.PayTicket, 32); //获取验证参数 string PayUrl = "http://" + gc.PayCom + "?uid=" + gu.Id + "&uname=" + gu.UserName + "&serverid=" + gs.ServerNo + "&point=" + PayGold + "&amount=" + order.PayMoney + "&oid=" + OrderNo + "&time=" + tstamp + "&type=" + gc.AgentId + "&sign=" + Sign + "&format=xml"; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值返回结果 Dictionary<string, string> list = XmlHelper.ReadXml2(PayResult); //解析返回结果 switch (list["status"]) //对充值结果进行解析 { case "400": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值成功!错误原因:更新订单状态失败!"; } case "401": return "充值失败!错误原因:缺少用户!"; case "402": return "充值失败!错误原因:缺少用户名!"; case "403": return "充值失败!错误原因:缺少服务器!"; case "404": return "充值失败!错误原因:缺少充值点数!"; case "405": return "充值失败!错误原因:缺少充值金额!"; case "406": return "充值失败!错误原因:缺少订单!"; case "407": return "充值失败!错误原因:缺少充值时间!"; case "408": return "充值失败!错误原因:缺少运营商!"; case "409": return "充值失败!错误原因:验证!"; case "410": return "充值失败!错误原因:非法访问IP!"; case "411": return "充值失败!未知错误!验证失败!"; case "412": return "充值失败!错误原因:用户角色不存在!"; case "413": return "充值失败!错误原因:获取角色信息失败!"; case "414": return "充值失败!错误原因:内部错误!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!用户不存在!"; } }
/// <summary> /// 古剑奇侠充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5(gc.PayTicket + OrderNo + gu.UserName + order.PayMoney + PayGold + tstamp, 32); string PayUrl = "http://" + gs.ServerNo + "." + gc.PayCom + "?paynum=" + OrderNo + "&username="******"&paymoney=" + order.PayMoney + "&payticket=" + PayGold + "&time=" + tstamp + "&flag=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值成功!错误:更新订单状态失败!"; } case "2": return "充值失败!错误原因:非法访问Ip!"; case "3": return "充值失败!错误原因:参数错误!"; case "4": return "充值失败!错误原因:请求超时!"; case "5": return "充值失败!错误原因:验证错误!"; case "6": return "充值失败!错误原因:角色不存在!"; case "7": return "充值失败!错误原因:无法提交重复订单!"; case "8": return "充值失败!错误原因:数据录入失败!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!错误原因:用户不存在"; } }
/// <summary> /// 街机三国充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 string sign = DESEncrypt.Md5(gu.Id + gc.AgentId + tstamp + gs.ServerNo + PayGold + order.PayMoney * 100 + OrderNo + gc.PayTicket, 32); string PayUrl = "http://" + gc.PayCom + "?user="******"&pay_amount=" + PayGold + "&amount=" + order.PayMoney * 100 + "&time=" + tstamp + "&order_id=" + OrderNo + "&server_id=" + gs.ServerNo + "&platform=" + gc.AgentId + "&sign=" + sign + ""; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) //对充值结果进行解析 { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "2": return "充值失败!错误原因:充值的服务器不存在!"; case "3": return "充值失败!错误原因:充值金额有误!"; case "4": return "充值失败!错误原因:验证参数错误!"; case "5": return "充值失败!错误原因:无非提交重复订单!"; case "6": return "充值失败!错误原因:不存在的用户!"; case "7": return "充值失败!错误原因:充值服务器出错!"; case "8": return "充值失败!错误原因:请求订单超时!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!用户不存在!"; } }
/// <summary> /// 九龙朝充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5("sid=" + gs.ServerNo + "&uid=" + gu.UserName + "&oid=" + OrderNo + "&money=" + order.PayMoney + "&gold=" + PayGold + "&time=" + tstamp + gc.PayTicket, 32); //获取验证参数 string PayUrl = "http://" + gc.PayCom + "?sid=" + gs.ServerNo + "&uid=" + gu.UserName + "&oid=" + OrderNo + "&money=" + order.PayMoney + "&gold=" + PayGold + "&time=" + tstamp + "&sign=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) //对充值结果进行解析 { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "-10": return "充值失败!错误原因:服务器编号错误或者不存在!"; case "-11": return "充值失败!错误原因:无效的玩家账号!"; case "-12": return "充值失败!错误原因:无法提交重复订单!"; case "-14": return "充值失败!错误原因:无效时间戳!"; case "-15": return "充值失败!错误原因:充值金额错误!"; case "-16": return "充值失败!错误原因:虚拟币数量错误!"; case "-17": return "充值失败!错误原因:校验码错误!"; case "-18": return "充值失败!错误原因:其他错误!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!用户不存在!"; } }
/// <summary> /// 仙侠傲世充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5(OrderNo + gu.UserName + PayGold + order.PayMoney + tstamp + DESEncrypt.Md5(gc.PayTicket, 32), 32); string PayUrl = "http://" + gs.ServerNo + "." + gc.LoginCom + "/api/recharge.php?ordernum=" + OrderNo + "&account=" + gu.UserName + "&money=" + order.PayMoney + "&gold=" + PayGold + "&time=" + tstamp + "&flag=" + Sign + "&server_id=" + gs.ServerNo; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值成功!错误:更新订单状态失败!"; } case "-1": return "充值失败!错误原因:参数不完整!"; case "-2": return "充值失败!错误原因:验证错误!"; case "-3": return "充值失败!错误原因:非法访问Ip!"; case "-4": return "充值失败!错误原因:请求超时!"; case "-5": return "充值失败!错误原因:账号或角色不存在!"; case "-6": return "充值失败!错误原因:无法提交重复订单!"; case "-7": return "充值失败!错误原因:服务器账号不存在!"; case "-10": return "充值失败!错误原因:充值失败!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!错误原因:用户不存在"; } }
/// <summary> /// 斗破乾坤充值接口 /// </summary> /// <param name="OrderNo">订单号</param> /// <returns>返回充值结果</returns> public string Pay(string OrderNo) { order = os.GetOrder(OrderNo); //获取用户的充值订单 gu = gus.GetGameUser(order.UserName); //获取充值用户 gs = gss.GetGameServer(order.ServerId); //获取用户要充值的服务器 string PayGold = (order.PayMoney * game.GameMoneyScale).ToString(); //计算支付的游戏币 if (gus.IsGameUser(gu.UserName)) //判断用户是否属于平台 { tstamp = Utils.GetTimeSpan(); //获取时间戳 Sign = DESEncrypt.Md5("account=" + gu.UserName + "&agent=" + gc.AgentId + "&amount=" + PayGold + "&order=" + OrderNo + "&price=" + order.PayMoney + "&serverid=" + gs.ServerNo + "&time=" + tstamp + "&" + gc.PayTicket, 32); string PayUrl = "http://" + gs.ServerNo + "." + gc.PayCom + "?account=" + gu.UserName + "&agent=" + gc.AgentId + "&amount=" + PayGold + "&order=" + OrderNo + "&price=" + order.PayMoney + "&serverid=" + gs.ServerNo + "&time=" + tstamp + "&token=" + Sign; GameUserInfo gui = Sel(gu.Id, gs.Id); //获取玩家查询信息 if (gui.Message == "Success") //判断玩家是否存在 { if (order.State == 1) //判断订单状态是否为支付状态 { string PayResult = Utils.GetWebPageContent(PayUrl); //获取充值结果 switch (PayResult) //对充值结果进行解析 { case "1": if (os.UpdateOrder(order.OrderNo)) //更新订单状态为已完成 { gus.UpdateGameMoney(gu.UserName, order.PayMoney); //跟新玩家游戏消费情况 return "充值成功!"; } else { return "充值失败!错误原因:更新订单状态失败!"; } case "-102": return "充值失败!验证参数错误!"; case "-201": return "充值失败!角色不存在!"; case "-207": return "充值失败!账号不存在!"; case "-300": return "充值失败!金额有误!"; case "-301": return "充值失败!无效订单!"; case "-302": return "充值失败!无非提交重复订单!"; case "-303": return "充值失败!充值接口已关闭!"; case "-304": return "充值失败!IP限制!"; default: return "充值失败!未知错误!"; } } else { return "充值失败!错误原因:无法提交未支付订单!"; } } else { return gui.Message; } } else { return "充值失败!用户不存在!"; } }