/// <summary> /// 帐户查询 /// transType=116 /// </summary> /// <param name="accountNo">代理商账号</param> /// <param name="transType">交易类型编号,如:116</param> /// <param name="accounts"></param> /// <returns></returns> public string AccountQuery(AccountNumber accountNo, TransactionType transType, List<AccountQuery> accounts) { if (transType.TypeCode.Trim() != "116") throw new Exception("交易类型和帐户查询的交易类型不匹配。"); if (accounts.Count >= 1 && accounts.Count <= 20) { try { DateTime now = DateTime.Now; string body = "<body><accountQuery>"; foreach (AccountQuery account in accounts) body = body + "<account userName=\"" + account.UserName + "\" />"; body = body + "</accountQuery></body>"; string messageId = accountNo.UserName + now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; string timestamp = now.ToString("yyyyMMdd") + now.ToString("HHmmss"); string requestMessage = "transType=" + transType.TypeCode + "&transMessage=" + (((((((("<?xml version=\"1.0\" encoding=\"GBK\"?>" + "<message version=\"1.0\" id=\"" + messageId + "\">") + "<header>") + "<messengerID>" + accountNo.UserName + "</messengerID>") + "<timestamp>" + timestamp + "</timestamp>") + "<transactionType>" + transType.TypeCode + "</transactionType>") + "<digest>" + PostManager.MD5(messageId + timestamp + accountNo.UserPassword + body, "gb2312") + "</digest>") + "</header>") + body + "</message>"); Console.WriteLine("账户查询请求消息为:\n" + requestMessage); string responseMessage = PostManager.Post(GatewayUrl, requestMessage, 120); return responseMessage; } catch (Exception ex) { throw ex; } } else throw new Exception("帐户查询的个数超过了单次能查询的数目(必须为1~20)。"); }
/// <summary> /// 销量查询 /// transType="107" /// 代理商在收到恒朋电话投注系统发送的“完成期结”奖期通知或者 /// 代理商查询到恒朋电话投注系统奖期状态为“完成期结”,才能发起销量查询。 /// </summary> /// <param name="accountNo">代理商账号</param> /// <param name="transType">交易类型</param> /// <param name="issue">要查询返奖信息的奖期对象</param> /// <returns></returns> public string BalanceQuery(AccountNumber accountNo, TransactionType transType, Issue issue) { if (transType.TypeCode.Trim() != "107") { throw new Exception("票查询请求对应的交易类型错误。"); } try { DateTime now = DateTime.Now; string body = "<body><balanceQuery><issue gameName=\"" + issue.PlayMethodInfo.GameName + "\" number=\"" + issue.Number + "\"/></balanceQuery></body>"; string messageId = accountNo.UserName + now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; string timestamp = now.ToString("yyyyMMdd") + now.ToString("HHmmss"); string requestMessage="transType=" + transType.TypeCode + "&transMessage=" + (((((((("<?xml version=\"1.0\" encoding=\"GBK\"?>" + "<message version=\"1.0\" id=\"" + messageId + "\">") + "<header>") + "<messengerID>" + accountNo.UserName + "</messengerID>") + "<timestamp>" + timestamp + "</timestamp>") + "<transactionType>"+transType.TypeCode+"</transactionType>") + "<digest>" + PostManager.MD5(messageId + timestamp + accountNo.UserPassword + body, "gb2312") + "</digest>") + "</header>") + body + "</message>"); Console.WriteLine("销量查询传递的消息为:"); Console.WriteLine(requestMessage); string message = PostManager.Post(GatewayUrl, requestMessage, 120); return message; } catch (Exception ex) { throw ex; } }
/// <summary> /// 提款 /// transType=111 /// </summary> /// <param name="accountNo">代理商账号</param> /// <param name="transType">交易类型编号,如:111</param> /// <param name="drawing"></param> /// <returns></returns> public string DrawingRequest(AccountNumber accountNo, TransactionType transType, Drawing drawing) { if (transType.TypeCode.Trim() != "111") { throw new Exception("提款请求对应的交易类型错误。"); } if (drawing != null && drawing.User != null) { try { DateTime now = DateTime.Now; string body = "<body><drawingRequest><drawing "; body += "id=\"" + drawing.Id + "\" "; body += "userName=\"" + drawing.User.UserName + "\" "; body += "realName=\"" + drawing.User.RealName + "\" "; body += "cardType=\"" + (int)drawing.User.CardTypeInfo + "\" "; body += "idCard=\"" + drawing.User.CardNumber + "\" "; body += "bankCard=\"" + drawing.BankCard + "\" "; body += "bankName=\"" + drawing.BankName + "\" "; body += "province=\"" + drawing.Province + "\" "; body += "city=\"" + drawing.City + "\" "; body += "branch=\"" + drawing.Branch + "\" "; body += "money=\"" + drawing.Money + "\" "; body += "/></drawingRequest></body>"; string messageId = accountNo.UserName + now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; string timestamp = now.ToString("yyyyMMdd") + now.ToString("HHmmss"); string requestMessage = "transType=" + transType.TypeCode + "&transMessage=" + (((((((("<?xml version=\"1.0\" encoding=\"GBK\"?>" + "<message version=\"1.0\" id=\"" + messageId + "\">") + "<header>") + "<messengerID>" + accountNo.UserName + "</messengerID>") + "<timestamp>" + timestamp + "</timestamp>") + "<transactionType>" + transType.TypeCode + "</transactionType>") + "<digest>" + PostManager.MD5(messageId + timestamp + accountNo.UserPassword + body, "gb2312") + "</digest>") + "</header>") + body + "</message>"); Console.WriteLine("提款请求消息:\n" + requestMessage); string responseMessage = PostManager.Post(GatewayUrl, requestMessage, 120); return responseMessage; } catch (Exception ex) { throw ex; } } else throw new Exception("提款信息为空或者提款信息部完整。"); }
public string GetCheckTicketUrl(AccountNumber accountNo, TransactionType transType, Ticket ticket) { try { DateTime now = DateTime.Now; //代理商Id string agentId = accountNo.UserName; //票流水号。ID生成规则为(agentID+8位时间戳YYYYMMDD+8位递增流水号) string ticketId = accountNo.UserName + now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; //消息加密字符串。使用MD5加密,原文为代理商编号(agentID)+代理商密码+代理商票号(ticketId) string digest = PostManager.MD5(agentId + accountNo.UserPassword + ticket.TicketId, "gb2312"); string url = GateWayManager.HPTicketVerification_GateWay + "?agentId=\"" + agentId + "\" ticketId=\"" + ticketId + "\" digest=\"" + digest + "\""; return url; } catch (Exception ex) { throw ex; } }
/// <summary> /// 电话投注卡充值 /// transType="117" /// </summary> /// <param name="accountNo">代理商账号</param> /// <param name="transType">交易类型</param> /// <param name="userProfile">要充值的用户账户</param> /// <param name="cardFill">充值数据对象</param> /// <returns></returns> public string AnteCardFill(AccountNumber accountNo, TransactionType transType,UserProfile userProfile,Fill cardFill) { if (transType.TypeCode.Trim() != "117") throw new Exception("交易类型和电话投注卡充值的交易类型不匹配。"); if (userProfile!=null && cardFill!=null && userProfile.UserName==cardFill.UserName) { try { DateTime now = DateTime.Now; string body = "<body><anteCardFill>"; body = body + "<fill agentID=\"" + accountNo.UserName + "\" "; string id = accountNo.UserName + now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; body = "id=\"" + id + "\" "; body = "userName=\"" + userProfile.UserName + "\" "; body = "realName=\"" + userProfile.RealName + "\" "; body = "idCard=\"" + userProfile.CardNumber + "\" "; body = "cardType=\"" + (int)userProfile.CardTypeInfo + "\" "; body = "money=\"" + cardFill.CardFillMoney + "\" "; body = "cardNo=\"" + cardFill.CardNo + "\" "; body = "password=\"" + PostManager.MD5(cardFill.Password,"gb2312") + "\" />"; body = body + "</anteCardFill></body>"; string messageId = accountNo.UserName + now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; string timestamp = now.ToString("yyyyMMdd") + now.ToString("HHmmss"); string requestMessage = "transType=" + transType.TypeCode + "&transMessage=" + (((((((("<?xml version=\"1.0\" encoding=\"GBK\"?>" + "<message version=\"1.0\" id=\"" + messageId + "\">") + "<header>") + "<messengerID>" + accountNo.UserName + "</messengerID>") + "<timestamp>" + timestamp + "</timestamp>") + "<transactionType>" + transType.TypeCode + "</transactionType>") + "<digest>" + PostManager.MD5(messageId + timestamp + accountNo.UserPassword + body, "gb2312") + "</digest>") + "</header>") + body + "</message>"); string responseMessage = PostManager.Post(GatewayUrl, requestMessage, 120); return responseMessage; } catch (Exception ex) { throw ex; } } else throw new Exception("电话投注卡充值对象或者用户账号信息不能为空。"); }
/// <summary> /// 提款查询 /// transType=113 /// </summary> /// <param name="accountNo">代理商账号</param> /// <param name="transType">交易类型编号,如:113</param> /// <param name="drawings"></param> /// <returns></returns> public string DrawingQuery(AccountNumber accountNo, TransactionType transType, List<Drawing> drawings) { if (transType.TypeCode.Trim() != "113") { throw new Exception("提款查询请求对应的交易类型错误。"); } if (drawings.Count >= 1 && drawings.Count <= 20) { try { int timeoutSeconds = 120; string body = "<body><drawingQuery>"; foreach (Drawing drawing in drawings) { body += "<drawing id=\"" + drawing.Id + "\"/>"; } body += "</drawingQuery></body>"; string messageId = accountNo.UserName + DateTime.Now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; string timestamp = DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmmss"); string requestMessage = "<?xml version=\"1.0\" encoding=\"GBK\"?>"; requestMessage = (((((((requestMessage + "<message version=\"1.0\" id=\"" + messageId + "\">") + "<header>") + "<messengerID>" + accountNo.UserName + "</messengerID>") + "<timestamp>" + timestamp + "</timestamp>") + "<transactionType>" + transType.TypeCode + "</transactionType>") + "<digest>" + PostManager.MD5(messageId + timestamp + accountNo.UserPassword + body, "gb2312") + "</digest>") + "</header>") + body + "</message>"; Console.WriteLine("提款查询请求的消息:\n" + "transType=" + transType.TypeCode + "&transMessage=" + requestMessage); string responseMessage = PostManager.Post(GatewayUrl, "transType=" + transType.TypeCode + "&transMessage=" + requestMessage, timeoutSeconds); return responseMessage; } catch (Exception ex) { throw ex; } } else throw new Exception("提款查询的个数超过了单次能查询的数目(必须为1~20)。"); }
/// <summary> /// 向恒朋提交充值请求 /// </summary> /// <param name="accountNo">代理商账号</param> /// <param name="alipayProviderType">支付提供商类型</param> /// <param name="userProfile">要充值的用户</param> /// <param name="money">充值金额</param> /// <param name="pageReturnUrl">恒朋系统会向代理商系统提供的充值请求的pageReturnUrl地址发送支付结果信息</param> public void PostAddBalance(AccountNumber accountNo, AlipayProviderType alipayProviderType, UserProfile userProfile, string money, string pageReturnUrl) { DateTime now = DateTime.Now; string messageId = accountNo.UserName + now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; //MD5,摘要的内容为代理商编号(agentID)+代理商密码(agentPasswd)+代理商充值流水号(id)+登录名(userName)+充值金额(money) string digest = PostManager.MD5(accountNo.UserName + accountNo.UserPassword + messageId + userProfile.UserName + money, "gb2312"); string paras = "agentID=" + accountNo.UserName + "&id=" + messageId + "&providerID=" + alipayProviderType.Number + "&userName="******"&realName=" + userProfile.RealName + "&idCard=" + userProfile.CardNumber + "&cardType=" + (int)userProfile.CardTypeInfo + "&money=" + money + "&digest=" + digest + "&pageReturnUrl=" + pageReturnUrl; Console.WriteLine("充值请求消息:" + this.GatewayUrl + "?" + paras); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.GatewayUrl); request.Timeout = 0x3e8 * 120; request.Method = "POST"; request.AllowAutoRedirect = true; byte[] bytes = Encoding.GetEncoding("GBK").GetBytes(paras); Stream requestStream = request.GetRequestStream(); requestStream.Write(bytes, 0, bytes.Length); requestStream.Close(); }
protected AccountNumber GetAccountNumber() { AccountNumber accountN = new AccountNumber(); accountN.UserName = GetAgenceAccountUserName(); accountN.UserPassword = GetAgenceAccountPassword(); return accountN; }
static void Main(string[] args) { Console.WriteLine("恒朋上海接口测试开始。。。。\n"); AccountNumber accountN = new AccountNumber(); Console.WriteLine("请输入代理商账号:"); accountN.UserName = "******";//Console.ReadLine(); Console.WriteLine("请输入代理商密码:"); accountN.UserPassword = "******";//Console.ReadLine(); Console.WriteLine("你输入的代理商账号为:" + accountN.UserName + " 密码为:" + accountN.UserPassword + "\n"); IIssueQueryGateway gateway = GatewayFactroy.CreateIssueQueryGatewayFactory(LotteryType.ShangHaiWelfareLottery); Console.WriteLine("投注/查询网关地址:" + gateway.GatewayUrl + "\n"); #region 奖期查询 TransactionTypeManager transTypeM = new TransactionTypeManager(LotteryType.ShangHaiWelfareLottery); TransactionType transType = transTypeM.GetTransactionTypeByTypeCode(LotteryType.ShangHaiWelfareLottery, "102"); ////奖期查询测试 //Console.WriteLine("奖期查询开始。。。。"); Issue issue=new Issue(); PlayMethodManager pleyMethodM = new PlayMethodManager(LotteryType.ShangHaiWelfareLottery); //Console.WriteLine("请输入玩法名称(如:双色球、15选5、3D、七乐彩、6+1、天天彩4、时时乐):"); //issue.PlayMethodInfo=pleyMethodM.GetMethodType(LotteryType.ShangHaiWelfareLottery,Console.ReadLine()); //Console.WriteLine("请输入期号:"); //issue.Number=Console.ReadLine(); //Console.WriteLine("你要进行的奖期查询玩法为:" + issue.PlayMethodInfo.PlayName + " 玩法编号为:" +issue.PlayMethodInfo.GameName + " 奖期为:" + issue.Number); //try //{ // string result = gateway.IssueQuery(accountN, transType, issue); // Console.WriteLine("奖期查询结果:\n" + result); //} //catch (Exception ex) //{ // Console.WriteLine("奖期查询结果:\n 错误:" + ex.Message); //} //Console.WriteLine("奖期查询结束。。。。\n"); #endregion #region 投注 //投注测试 Console.WriteLine("投注开始(本测试会携带相同的两张彩票(票号不同))。。。。"); transType = transTypeM.GetTransactionTypeByTypeCode(LotteryType.ShangHaiWelfareLottery, "103"); Console.WriteLine("构建彩票信息开始。。。。"); List<Ticket> tickets = new List<Ticket>(); Ticket ticketOne = new Ticket(); ticketOne.TicketId = accountN.UserName + DateTime.Now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; ticketOne.IssueInfo = new Issue(); Console.WriteLine("请输入玩法名称(如:双色球、15选5、3D、七乐彩、6+1、天天彩4、时时乐):"); string gameName = "ssl";// Console.ReadLine(); ticketOne.PlayTypeInfo = pleyMethodM.GetMethodType(LotteryType.ShangHaiWelfareLottery, gameName).PlayTypes[0]; ticketOne.IssueInfo.PlayMethodInfo = pleyMethodM.GetMethodType(LotteryType.ShangHaiWelfareLottery, gameName); Console.WriteLine("请输入期号:"); ticketOne.IssueInfo.Number = Console.ReadLine(); Console.WriteLine("倍投数:"); ticketOne.Amount = "1";// Console.ReadLine(); Console.WriteLine("购买金额:"); ticketOne.Money = "2";//Console.ReadLine(); Console.WriteLine("要投注的彩票号码(测试时,每张彩票一注):"); ticketOne.AnteCodes = Console.ReadLine(); UserProfile user = new UserProfile(); Console.WriteLine("彩票用户名:"); user.UserName = "******";// Console.ReadLine(); Console.WriteLine("用户证件类型(1、身份证;2、军官证;3、护照):"); string cardType = "1";// Console.ReadLine(); if (cardType == "1" || cardType == "2" || cardType == "3") { user.CardTypeInfo = (CardType)int.Parse(cardType); Console.WriteLine("证件号码:"); user.CardNumber = "510212198105057410"; //Console.ReadLine(); Console.WriteLine("用户邮箱地址:"); user.Mail = "*****@*****.**";// Console.ReadLine(); Console.WriteLine("用户手机号(无纸化彩票中大奖的凭证之一):"); user.Mobile = "15902307117"; // Console.ReadLine(); Console.WriteLine("用户真实姓名:"); user.RealName = "钟家宇";// Console.ReadLine(); Console.WriteLine("你输入的彩票用户信息为: 证件类型:" + (int)user.CardTypeInfo + " 证件号码:" + user.CardNumber + " 邮箱:" + user.Mail + " 手机号:" + user.Mobile + " 真实姓名:" + user.RealName); ticketOne.UserProfile = user; tickets.Add(ticketOne); ticketOne.TicketId = accountN.UserName + DateTime.Now.ToString("yyyyMMdd") + PostManager.TenSerialNumber; tickets.Add(ticketOne); transType = transTypeM.GetTransactionTypeByTypeCode(LotteryType.ShangHaiWelfareLottery, "103"); try { string result = gateway.LotteryRequest(accountN, transType, tickets); Console.WriteLine("投注结果:"); Console.WriteLine(result); } catch (Exception ex) { Console.WriteLine("投注结果:\n 错误:" + ex.Message); } } else { Console.WriteLine("构建彩票用户错误:用户证件类型不正确"); } Console.WriteLine("投注结束。。。。\n"); #endregion #region 票查询 Console.WriteLine("票查询开始(如果上面的投注成功,直接查询投票的彩票,否则请输入彩票号)。。。。"); Console.WriteLine("上面的投注是否成功?(1、成功;2、失败):"); try { Ticket ticketP = null; if (Console.ReadLine() == "2") { Console.WriteLine("请输入要查询的票号:"); ticketP = new Ticket(); ticketP.TicketId = Console.ReadLine(); } else ticketP = tickets[0]; transType = transTypeM.GetTransactionTypeByTypeCode(LotteryType.ShangHaiWelfareLottery, "105"); List<Ticket> ticketsP = new List<Ticket>(); ticketsP.Add(ticketP); string result = gateway.TicketQuery(accountN, transType, ticketsP); Console.WriteLine("票查询结果:"); Console.WriteLine(result); } catch (Exception ex) { Console.WriteLine("票查询结果:\n 错误:" + ex.Message); } Console.WriteLine("票查询结束。。。。\n"); #endregion #region 销量查询 Console.WriteLine("销量查询开始。。。。"); Console.WriteLine("请输入玩法名称(如:双色球、15选5、3D、七乐彩、6+1、天天彩4、时时乐):"); issue.PlayMethodInfo = pleyMethodM.GetMethodType(LotteryType.ShangHaiWelfareLottery, Console.ReadLine()); Console.WriteLine("请输入期号:"); issue.Number = Console.ReadLine(); transType = transTypeM.GetTransactionTypeByTypeCode(LotteryType.ShangHaiWelfareLottery, "107"); try { string result = gateway.BalanceQuery(accountN, transType, issue); Console.WriteLine("销量查询结果:\n" + result); } catch (Exception ex) { Console.WriteLine("销量查询结果:\n 错误:" + ex.Message); } Console.WriteLine("销量查询结束。。。。\n"); #endregion #region 返奖查询 Console.WriteLine("返奖查询开始。。。。"); Console.WriteLine("请输入玩法名称(如:双色球、15选5、3D、七乐彩、6+1、天天彩4、时时乐):"); issue.PlayMethodInfo = pleyMethodM.GetMethodType(LotteryType.ShangHaiWelfareLottery, Console.ReadLine()); Console.WriteLine("请输入期号:"); issue.Number = Console.ReadLine(); transType = transTypeM.GetTransactionTypeByTypeCode(LotteryType.ShangHaiWelfareLottery, "106"); try { string result = gateway.BonusQuery(accountN, transType, issue); Console.WriteLine("返奖查询结果:\n" + result); } catch (Exception ex) { Console.WriteLine("返奖查询结果:\n 错误:" + ex.Message); } Console.WriteLine("返奖查询结束。。。。\n"); #endregion #region 账户查询 Console.WriteLine("账户查询开始。。。。"); try { transType = transTypeM.GetTransactionTypeByTypeCode(LotteryType.ShangHaiWelfareLottery, "116"); List<AccountQuery> users = new List<AccountQuery>(); AccountQuery account = new AccountQuery(); account.UserName = "******"; users.Add(account); account = new AccountQuery(); account.UserName = "******"; users.Add(account); string result = gateway.AccountQuery(accountN, transType, users); Console.WriteLine("账户查询结果: \n" + result); } catch (Exception ex) { Console.WriteLine("账户查询结果: \n错误:" + ex.Message); } Console.WriteLine("账户查询结束。。。。\n"); #endregion IAddBalanceGateway gateway2 = GatewayFactroy.CreateAddBalanceGatewayFactory(LotteryType.ShangHaiWelfareLottery); Console.WriteLine("\n充值网关地址:" + gateway2.GatewayUrl + "\n"); #region 充值 Console.WriteLine("充值开始。。。。"); Console.WriteLine("请输入支付提供商类型(1、银联;2、支付宝;3、腾讯财付通;4、汇付天下;5、快钱;6、网银在线;7、云网支付):"); AlipayProviderTypeManager alipayM = new AlipayProviderTypeManager(); int alipayIndex = Convert.ToInt32(Console.ReadLine()) - 1; AlipayProviderType alipayType = alipayM.providerTypes[alipayIndex]; user = new UserProfile(); Console.WriteLine("彩票用户名:"); user.UserName = Console.ReadLine(); Console.WriteLine("用户证件类型(1、身份证;2、军官证;3、护照):"); cardType = Console.ReadLine(); if (cardType == "1" || cardType == "2" || cardType == "3") { user.CardTypeInfo = (CardType)int.Parse(cardType); Console.WriteLine("证件号码:"); user.CardNumber = Console.ReadLine(); Console.WriteLine("用户真是姓名:"); user.RealName = Console.ReadLine(); Console.WriteLine("你输入的彩票用户信息为: 证件类型:" + (int)user.CardTypeInfo + " 证件号码:" + user.CardNumber + " 邮箱:" + user.Mail + " 真实姓名:" + user.RealName); Console.WriteLine("请输入充值金额:"); string money = Console.ReadLine(); Console.WriteLine("请输入接受充值结果的URL地址:"); string returnUrl = Console.ReadLine(); try { gateway2.PostAddBalance(accountN, alipayType, user, money, returnUrl); Console.WriteLine("充值结果:成功"); } catch (Exception ex) { Console.WriteLine("充值结果:\n 错误:" + ex.Message); } } else { Console.WriteLine("构建彩票用户错误:用户证件类型不正确"); } Console.WriteLine("充值结束。。。。\n"); #endregion #region 充值查询 Console.WriteLine("充值查询开始(本测试只查询一个充值)。。。。"); Console.WriteLine("请输入号充值Id(请COPY上面\"充值请求信息\"中的id):"); string id = Console.ReadLine(); try { Fill fill = new Fill(); fill.Id = id; List<Fill> fills = new List<Fill>(); fills.Add(fill); transType = transTypeM.GetTransactionTypeByTypeCode(LotteryType.ShangHaiWelfareLottery, "110"); string result = gateway2.FillQuery(accountN, transType, fills); Console.WriteLine("充值查询结果:\n" + result); } catch (Exception ex) { Console.WriteLine("充值查询结果:\n 错误" + ex.Message); } Console.WriteLine("充值查询结束。。。。\n"); #endregion IDrawingGateway gateway3 = GatewayFactroy.CreateDrawingGatewayFactory(LotteryType.ShangHaiWelfareLottery); Console.WriteLine("\n提款网关地址:" + gateway3.GatewayUrl + "\n"); #region 提款 Console.WriteLine("提款开始。。。。"); Drawing drawing = new Drawing(); try { drawing = new Drawing(); drawing.Id = accountN.UserName + DateTime.Now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; Console.WriteLine("彩票用户名:"); user.UserName = Console.ReadLine(); Console.WriteLine("用户证件类型(1、身份证;2、军官证;3、护照):"); cardType = Console.ReadLine(); if (cardType == "1" || cardType == "2" || cardType == "3") { user.CardTypeInfo = (CardType)int.Parse(cardType); Console.WriteLine("证件号码:"); user.CardNumber = Console.ReadLine(); Console.WriteLine("用户真是姓名:"); user.RealName = Console.ReadLine(); Console.WriteLine("你输入的彩票用户信息为: 证件类型:" + (int)user.CardTypeInfo + " 证件号码:" + user.CardNumber + " 邮箱:" + user.Mail + " 真实姓名:" + user.RealName); } drawing.User = user; Console.WriteLine("银行账号:"); drawing.BankCard = Console.ReadLine(); Console.WriteLine("开户行名称:"); drawing.BankName = Console.ReadLine(); Console.WriteLine("开户行所在省或直辖市名称:"); drawing.Province = Console.ReadLine(); Console.WriteLine("开户行所在城市:"); drawing.City = Console.ReadLine(); Console.WriteLine("分行或支行、分理处名称:"); drawing.Branch = Console.ReadLine(); Console.WriteLine("提款金额:"); drawing.Money = Convert.ToInt32(Console.ReadLine()); transType = transTypeM.GetTransactionTypeByTypeCode(LotteryType.ShangHaiWelfareLottery, "111"); string result = gateway3.DrawingRequest(accountN, transType, drawing); Console.WriteLine("提款结果:\n" + result); } catch (Exception ex) { Console.WriteLine("提款结果: \n错误:" + ex.Message); } Console.WriteLine("提款结束。。。。\n"); #endregion #region 提款查询 Console.WriteLine("提款查询开始。。。。"); try { List<Drawing> drawings = new List<Drawing>(); drawings.Add(drawing); transType = transTypeM.GetTransactionTypeByTypeCode(LotteryType.ShangHaiWelfareLottery, "113"); string result = gateway3.DrawingQuery(accountN, transType, drawings); Console.WriteLine("提款查询结果:\n" + result); } catch (Exception ex) { Console.WriteLine("提款查询结果: \n错误:" + ex.Message); } Console.WriteLine("提款查询结束。。。。\n"); #endregion }
/// <summary> /// 联合购买 /// 代理商向恒朋系统发其一个联合购买请求只能包含一个联合购买方案。 /// </summary> /// <param name="accountNo">代理商账户</param> /// <param name="transType">交易类型</param> /// <param name="anteInfo">联合购买方案信息</param> /// <param name="issue">奖期信息</param> /// <param name="anteTickets">联合购买方案投注票信息集合</param> /// <param name="anteBuies">联合购买方案认购主体信息集合</param> /// <param name="anteCommisions">联合购买方案佣金规则信息集合</param> /// <returns></returns> public string UniteAnteRequest(AccountNumber accountNo, TransactionType transType, UniteAnteInfo anteInfo, Issue issue, List<UniteAnteTicket> anteTickets, List<UniteAnteBuy> anteBuies, List<UniteAnteCommision> anteCommisions) { //if (transType.TypeCode.Trim() != "114") // throw new Exception("交易类型和赠送彩金的交易类型不匹配。"); try { DateTime now = DateTime.Now; string body = "<body><uniteAnteRequest>"; //联合购买方案信息 body += "<uniteAnteInfo counterAnteId=\"" + anteInfo.CounterAnteId + "\" "; body += "anteName=\"" + anteInfo.AnteName + "\" "; body += "totalAnteMoney=\"" + anteInfo.TotalAnteMoney + "\" "; body += "totalDeal=\"" + anteInfo.TotalDeal + "\" "; body += "perDeal=\"" + anteInfo.PerDeal + "\" "; body += "userName=\"" + anteInfo.UserName + "\" "; body += "userName=\"" + anteInfo.UserName + "\" >"; body += "<issue gameName=\"" + issue.PlayMethodInfo.PlayName + "\" number=" + issue.Number + "\" /></uniteAnteInfo>"; //联合购买方案投注票明细信息 foreach(UniteAnteTicket anteTicket in anteTickets) { body += "<uniteAnteTicket ticketId=\"" + anteTicket.TicketId + "\" amount=\"" + anteTicket.Amount + "\" money=\"" + anteTicket.Money + "\" playType=\"" + anteTicket.PlayTypeInfo.ID + "\" >"; foreach (string anteCode in anteTicket.AnteCodes.Split(new char[] { '\n' }))//投注号 { if (!(anteCode.Trim() == "")) { //<anteCode>01,02,03,04,05,06#01</anteCode> body = body + "<anteCode>" + anteCode + "</anteCode>"; } } body += "</uniteAnteTicket>"; } //联合购买方案认购主体的明细信息 foreach (UniteAnteBuy anteBuy in anteBuies) { //<uniteAnteBuy userName="******" cardType="1" mail="*****@*****.**" //cardNumber="430923198009071234" bonusPhone="(0551)76526753" mobile="13098191231" realName="李侠" buyDeal="10" buyMoney="10"/> body += "<uniteAnteBuy userName=\"" + anteBuy.UserName + "\" cardType=\"" + (int)anteBuy.CardType + "\" mail=\"" + anteBuy.Mail + "\" cardNumber=\"" + anteBuy.CardNumber + "\" bonusPhone=\"" + anteBuy.BonusPhone + "\" mobile=\"" + anteBuy.Mobile + "\" realName=\"" + anteBuy.RealName + "\" buyDeal=\"" + anteBuy.BuyDeal + "\" buyMoney=\"" +anteBuy.BuyMoney + "\" />"; } //联合购买方案佣金规则信息 foreach (UniteAnteCommision anteCommision in anteCommisions) { //<uniteAnteCommision minMoney="100" maxMoney="1000" rate="4"/> body += "<uniteAnteCommision minMoney=\"" + anteCommision.MinMoney +"\" maxMoney=\"" + anteCommision.MaxMoney + "\" rate=\"" + anteCommision.Rate + "\"/>"; } body = body + "</uniteAnteRequest></body>"; string messageId = accountNo.UserName + now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; string timestamp = now.ToString("yyyyMMdd") + now.ToString("HHmmss"); string requestMessage = "transType=" + transType.TypeCode + "&transMessage=" + (((((((("<?xml version=\"1.0\" encoding=\"GBK\"?>" + "<message version=\"1.0\" id=\"" + messageId + "\">") + "<header>") + "<messengerID>" + accountNo.UserName + "</messengerID>") + "<timestamp>" + timestamp + "</timestamp>") + "<transactionType>" + transType.TypeCode + "</transactionType>") + "<digest>" + PostManager.MD5(messageId + timestamp + accountNo.UserPassword + body, "gb2312") + "</digest>") + "</header>") + body + "</message>"); string responseMessage = PostManager.Post(GatewayUrl, requestMessage, 120); return responseMessage; } catch (Exception ex) { throw ex; } }
/// <summary> /// 联合购买查询 /// </summary> /// <param name="accountNo">代理商账户</param> /// <param name="transType">交易类型</param> /// <param name="anteInfo">联合购买方案信息</param> /// <returns></returns> public string UniteAnteQuery(AccountNumber accountNo, TransactionType transType, UniteAnteInfo anteInfo) { //if (transType.TypeCode.Trim() != "114") // throw new Exception("交易类型和赠送彩金的交易类型不匹配。"); try { DateTime now = DateTime.Now; string body = "<body><uniteAnteQuery counterAnteId=\"" + anteInfo.CounterAnteId + "\" /></body>"; string messageId = accountNo.UserName + now.ToString("yyyyMMdd") + now.ToString("HHmmss"); string timestamp = now.ToString("yyyyMMdd") + now.ToString("HHmmss"); string message = PostManager.Post(GatewayUrl, "transType=" + transType.TypeCode + "&transMessage=" + (((((((("<?xml version=\"1.0\" encoding=\"GBK\"?>" + "<message version=\"1.0\" id=\"" + messageId + "\">") + "<header>") + "<messengerID>" + accountNo.UserName + "</messengerID>") + "<timestamp>" + timestamp + "</timestamp>") + "<transactionType>106</transactionType>") + "<digest>" + PostManager.MD5(messageId + timestamp + accountNo.UserPassword + body, "gb2312") + "</digest>") + "</header>") + body + "</message>"), 120); string responseMessage = PostManager.Post(GatewayUrl, message, 120); return responseMessage; } catch (Exception ex) { throw ex; } }
/// <summary> /// 票查询,最多5票。如:<ticket>...</ticket> /// transType=105 /// </summary> /// <param name="AccountNo">代理商账号</param> /// <param name="transType">交易类型编号,如:105</param> /// <param name="tickets">要进行票查询的彩票集合。要查询的票的票号,如:6000012007051012345678</param> /// <returns></returns> public string TicketQuery(AccountNumber accountNo, TransactionType transType, List<Ticket> tickets) { if (transType.TypeCode.Trim() != "105") { throw new Exception("票查询请求对应的交易类型错误。"); } if (tickets.Count >= 1 && tickets.Count <= 5) { try { int timeoutSeconds = 120; string body = "<body><ticketQuery>"; foreach (Ticket ticket in tickets) { body = body + "<ticket id=\"" + ticket.TicketId + "\"/>"; } body = body + "</ticketQuery></body>"; string messageId = accountNo.UserName + DateTime.Now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; string timestamp = DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmmss"); string requestMessage = "<?xml version=\"1.0\" encoding=\"GBK\"?>"; requestMessage = (((((((requestMessage + "<message version=\"1.0\" id=\"" + messageId + "\">") + "<header>") + "<messengerID>" + accountNo.UserName + "</messengerID>") + "<timestamp>" + timestamp + "</timestamp>") + "<transactionType>" + transType.TypeCode + "</transactionType>") + "<digest>" + PostManager.MD5(messageId + timestamp + accountNo.UserPassword + body, "gb2312") + "</digest>") + "</header>") + body + "</message>"; Console.WriteLine("票查询传递的消息为:"); Console.WriteLine("transType=" + transType.TypeCode + "&transMessage=" + requestMessage); string responseMessage = PostManager.Post(GatewayUrl, "transType=" + transType.TypeCode + "&transMessage=" + requestMessage, timeoutSeconds); return responseMessage; } catch (Exception ex) { throw ex; } } else throw new Exception("每个票查询请求最多5票。"); }
/// <summary> /// 风险控制查询 /// tansType="134" /// </summary> /// <param name="accountNo">代理商账户</param> /// <param name="transType">交易类型</param> /// <param name="issue"></param> /// <param name="anteCode">投注号码.如果指定投注号码,表示查询特定号码的可投注注数,反之,表示查询所有可投注注数小于某个阀值的号码.</param> /// <returns></returns> public string RiskControlQuery(AccountNumber accountNo, TransactionType transType,Issue issue,string anteCode) { if (transType.TypeCode.Trim() != "134") throw new Exception("交易类型和赠送彩金的交易类型不匹配。"); try { DateTime now = DateTime.Now; string body = "<body><riskControlQuery gameName=" + issue.PlayMethodInfo.PlayName + "\" number=\"" + issue.Number + "\" anteCode=\"" + anteCode + "\" /></body>"; string messageId = accountNo.UserName + now.ToString("yyyyMMdd") + now.ToString("HHmmss"); string timestamp = now.ToString("yyyyMMdd") + now.ToString("HHmmss"); string message = PostManager.Post(GatewayUrl, "transType=" + transType.TypeCode + "&transMessage=" + (((((((("<?xml version=\"1.0\" encoding=\"GBK\"?>" + "<message version=\"1.0\" id=\"" + messageId + "\">") + "<header>") + "<messengerID>" + accountNo.UserName + "</messengerID>") + "<timestamp>" + timestamp + "</timestamp>") + "<transactionType>106</transactionType>") + "<digest>" + PostManager.MD5(messageId + timestamp + accountNo.UserPassword + body, "gb2312") + "</digest>") + "</header>") + body + "</message>"), 120); string responseMessage = PostManager.Post(GatewayUrl, message, 120); return responseMessage; } catch (Exception ex) { throw ex; } }
//恒朋投注系统向本地系统发送的“奖期通知” // 1)用奖期查询,来代替。改变本地系统奖期状态,可能需要轮讯 //恒朋投注系统向本地系统发送的“返奖通知” //暂时不考虑 /// <summary> /// 发送响应信息到恒朋电话投注系统 /// </summary> /// <param name="accountNo">代理商账号</param> /// <param name="transType">交易类型 </param> /// <param name="messageID">消息ID</param> /// <param name="resStatus">返回恒朋系统的响应状态</param> public void ResponseNotice(AccountNumber accountNo, TransactionType transType, string messageID, ResponseStatus resStatus) { DateTime now = DateTime.Now; string body = "<body><response code=\"" + resStatus.StatusCode + "\" message=\"" + resStatus.Description + "\"/></body>"; string timestamp = now.ToString("yyyyMMdd") + now.ToString("HHmmss"); string message = "<?xml version=\"1.0\" encoding=\"GBK\"?>"; message = (((((((message + "<message version=\"1.0\" id=\"" + messageID + "\">") + "<header>") + "<messengerID>" + accountNo.UserName + "</messengerID>") + "<timestamp>" + timestamp + "</timestamp>") + "<transactionType>" + transType.TypeCode + "</transactionType>") + "<digest>" + PostManager.MD5(messageID + timestamp + accountNo.UserPassword + body, "gb2312") + "</digest>") + "</header>") + body + "</message>"; PostManager.Post(GatewayUrl, "transType=" + transType.TypeCode + "&transMessage=" + message, 90); }
/// <summary> /// 赠送彩金 /// 单次最多500笔 /// transType=114 /// </summary> /// <param name="accountNo">代理商账号</param> /// <param name="transType">交易类型编号,如:114</param> /// <param name="presents">要赠送彩金的赠送集合</param> /// <returns></returns> public string PresentMoney(AccountNumber accountNo, TransactionType transType, List<Present> presents) { if (transType.TypeCode.Trim() != "114") throw new Exception("交易类型和赠送彩金的交易类型不匹配。"); if (presents.Count >= 1 && presents.Count <= 500) { try { DateTime now = DateTime.Now; string body = "<body><presentMoney>"; foreach (Present present in presents) { string id = accountNo.UserName + now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; body += "<present id=\"" + id + "\" "; body += "userName=\"" + present.UserName + "\" "; body += "realName=\"" + present.RealName + "\" "; body += "cardType=\"" + (int)present.CardTypeInfo + "\" "; body += "idCard=\"" + present.IdCard + "\" "; body += "money=\"" + present.Money + "\" "; body += " />"; } body = body + "</presentMoney></body>"; string messageId = accountNo.UserName + now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; string timestamp = now.ToString("yyyyMMdd") + now.ToString("HHmmss"); string requestMessage = "transType=" + transType.TypeCode + "&transMessage=" + (((((((("<?xml version=\"1.0\" encoding=\"GBK\"?>" + "<message version=\"1.0\" id=\"" + messageId + "\">") + "<header>") + "<messengerID>" + accountNo.UserName + "</messengerID>") + "<timestamp>" + timestamp + "</timestamp>") + "<transactionType>" + transType.TypeCode + "</transactionType>") + "<digest>" + PostManager.MD5(messageId + timestamp + accountNo.UserPassword + body, "gb2312") + "</digest>") + "</header>") + body + "</message>"); string responseMessage = PostManager.Post(GatewayUrl, requestMessage, 120); return responseMessage; } catch (Exception ex) { throw ex; } } else throw new Exception("赠送彩金的用户个数个数超过了单次能查询的数目(必须为1~20)。"); }
/// <summary> /// 投注 /// 在每个请求最多500票的限制内,尽可能携带更多的票,禁止一个投注请求仅携带一票 /// transType=103 /// </summary> /// <param name="accountNo">代理商账号</param> /// <param name="transType">交易类型,如:103</param> /// <param name="tickets">要进行投注的彩票集合</param> /// <returns></returns> public string LotteryRequest(AccountNumber accountNo, TransactionType transType, List<Ticket> tickets) { if (transType.TypeCode.Trim() != "103") { throw new Exception("投注请求对应的交易类型错误。"); } if (tickets.Count > 1 && tickets.Count <= 500) { try { string body = "<body><lotteryRequest>"; foreach (Ticket ticket in tickets) { Issue issue = ticket.IssueInfo; UserProfile userProfile = ticket.UserProfile; string anteCodes = ticket.AnteCodes; string ticketid = ticket.TicketId; string ticketN = body + "<ticket id=\"" + ticketid + "\""; string playType = ticketN + " playType=\"" + ticket.PlayTypeInfo.ID + "\" money=\"" + ticket.Money.Replace(",", "") + "\" amount=\"" + ticket.Amount + "\">"; string issueN = playType + "<issue gameName=\"" + issue.PlayMethodInfo.GameName + "\" number=\"" + issue.Number + "\"/>"; body = issueN + "<userProfile userName=\"" + userProfile.UserName + "\" cardType=\"" + ((int)userProfile.CardTypeInfo) + "\" mail=\"" + userProfile.Mail + "\" cardNumber=\"" + userProfile.CardNumber + "\" mobile=\"" + userProfile.Mobile + "\" realName=\"" + userProfile.RealName + "\"/>"; foreach (string anteCode in anteCodes.Split(new char[] { '\n' })) { if (!(anteCode.Trim() == "")) { body = body + "<anteCode>" + anteCode + "</anteCode>"; } } body = body + "</ticket>"; } body = body + "</lotteryRequest></body>"; string messageId = accountNo.UserName + DateTime.Now.ToString("yyyyMMdd") + PostManager.EightSerialNumber; string timestamp = DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmmss"); string message = "<?xml version=\"1.0\" encoding=\"GBK\"?>"; message = (((((((message + "<message version=\"1.0\" id=\"" + messageId + "\">") + "<header>") + "<messengerID>" + accountNo.UserName + "</messengerID>") + "<timestamp>" + timestamp + "</timestamp>") + "<transactionType>" + transType.TypeCode + "</transactionType>") + "<digest>" + PostManager.MD5(messageId + timestamp + accountNo.UserPassword + body, "gb2312") + "</digest>") + "</header>") + body + "</message>"; Console.WriteLine("投注传递的消息为:"); Console.WriteLine("transType=" + transType.TypeCode + "&transMessage=" + message); string receiveString = ""; receiveString = PostManager.Post(GatewayUrl, "transType=" + transType.TypeCode + "&transMessage=" + message, 120); return receiveString; } catch (Exception ex) { throw ex; } } else throw new Exception("每个投注请求最多500票的限制内,尽可能携带更多的票,禁止一个投注请求仅携带一票。"); }