/// <summary> /// 从数网获取订单 /// </summary> /// <param name="merchantID">商户编号</param> /// <param name="key">商户密码</param> /// <param name="url">接口地址</param> /// <param name="count">订单数量</param> /// <returns></returns> public List <Order> getOrderFromSW(ref int getOrderTime) { getOrderTime = time; List <Order> orderSet = new List <Order>(); try { string sign = Md5Helper.MD5Encrypt(merchantID + key); string postData = string.Format("MerchantID={0}&Count={1}&Sign={2}", merchantID, count, sign); System.Net.CookieContainer cookie = new System.Net.CookieContainer(); string result = PostAndGet.HttpGetString(getOrderurl, postData, ref cookie); WriteLog.Write("方法:getOrderFromSW 获取订单信息:" + result, LogPathFile.Other); if (result.Contains("获取成功")) { assignmentOrder(orderSet, result); } } catch (Exception ex) { WriteLog.Write("方法:getOrderFromSW异常,信息:" + ex.Message + ex.StackTrace, LogPathFile.Exception); } return(orderSet); }
/// <summary> /// 验证码识别 /// </summary> /// <param name="url"></param> /// <param name="cookie"></param> /// <param name="codeType"></param> /// <param name="code"></param> /// <param name="codeId"></param> /// <returns></returns> public static bool GetCodeByByte_UU(string url, ref CookieContainer cookie, int codeType, ref string code, ref int codeId) { try { #region 获取验证码 Image image = ByteHelper.byteArrayToImage(PostAndGet.HttpGetByte(url, "", ref cookie)); #endregion #region 保存图片 //判断保存图片的文件夹是否存在,若不存在则创建 //string filepath = System.Windows.Forms.Application.StartupPath + @"\37"; //if (!Directory.Exists(filepath)) //{ // Directory.CreateDirectory(filepath); //} //Bitmap bmp1 = new Bitmap(image); //MemoryStream bmpStream1 = new MemoryStream(); //bmp1.Save(bmpStream1, System.Drawing.Imaging.ImageFormat.Jpeg); //string BmpPath = filepath + "\\" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".jpg"; //FileStream fs = new FileStream(BmpPath, FileMode.Create); //bmpStream1.WriteTo(fs); //bmpStream1.Close(); //fs.Close(); //bmpStream1.Dispose(); //fs.Dispose(); #endregion #region 把图片转换为字节流 //判断保存图片的文件夹是否存在,若不存在则创建 Bitmap bmp = new Bitmap(image); MemoryStream bmpStream = new MemoryStream(); MemoryStream ms = new MemoryStream(); bmp.Save(ms, ImageFormat.Jpeg); byte[] buffer = new byte[ms.Length]; ms.Position = 0; ms.Read(buffer, 0, buffer.Length); ms.Flush(); #endregion #region 调用优优云打码 StringBuilder strResult = new StringBuilder(50); codeId = Wrapper.uu_recognizeByCodeTypeAndBytes(buffer, buffer.Length, codeType, strResult); code = CheckResult(strResult.ToString(), Convert.ToInt32(strSoftID), codeId, strCheckKey); #endregion return(true); } catch (Exception) { return(false); } }
public Order Query(Order order) { string key = PayAndQueryKamen.key; string CustomerId = PayAndQueryKamen.merchantID; string queryUrl = PayAndQueryKamen.queryUrl; CookieContainer coockie = new CookieContainer(); string strmd5 = "CustomerId=" + CustomerId + "CustomerOrderNo=" + order.OrderInsideID + key; string sign = Md5Helper.EncryptMd5_Kamen(strmd5); StringBuilder str = new StringBuilder(); str.AppendFormat("CustomerId={0}", CustomerId); //云接口商户编号 str.AppendFormat("&CustomerOrderNo={0}", order.OrderInsideID); //客户外部系统订单号 str.AppendFormat("&Sign={0}", sign); //数字签名(MerchantID+OrderID+key) WriteLog.Write("方法:Query,订单号:" + order.OrderInsideID + " Kamen 订单查询参数:" + str.ToString(), LogPathFile.Recharge.ToString()); string result = PostAndGet.HttpPostString(queryUrl, str.ToString(), ref coockie); WriteLog.Write("方法:Charge,订单号:" + order.OrderInsideID + " Kamen 订单查询:" + result, LogPathFile.Recharge.ToString()); //订单状态(未处理、处理中、可疑、成功、失败) string OrderStatus = Regex.Match(result, @"<OrderStatus>(.*?)</OrderStatus>").Groups[1].Value; string Description = Regex.Match(result, @"<Description>(.*?)</Description>").Groups[1].Value; string OrderNo = Regex.Match(result, @"<OrderNo>(.*?)</OrderNo>").Groups[1].Value; switch (OrderStatus) { case "可疑": order.RechargeStatus = (int)OrderRechargeStatus.suspicious; order.RechargeMsg = Description + "-" + OrderNo; return(order); case "成功": order.RechargeStatus = (int)OrderRechargeStatus.successful; order.RechargeMsg = Description + "-" + OrderNo; return(order); case "失败": if (Description.Contains("站点余额不足")) { order.RechargeStatus = (int)OrderRechargeStatus.suspicious; } else { order.RechargeStatus = (int)OrderRechargeStatus.failure; } order.RechargeMsg = Description + "-" + OrderNo; return(order); case "未处理": case "处理中": default: break; } return(order); }
public string getCatalog(string catalogName) { coockie = new CookieContainer(); string strmd5 = merchantID + key; string sign = Md5Helper.GetMD5String_utf8(strmd5); StringBuilder str = new StringBuilder(); str.AppendFormat("MerchantI={0}", merchantID); str.AppendFormat("&Sign={0}", sign); //数字签名(MerchantID+ key) string result = PostAndGet.HttpPostString(getCatalogUrl, str.ToString(), ref coockie); Regex re = new Regex(@"<No>(.*?)</No>\s+<Name>(.*?)</Name> ", RegexOptions.None); MatchCollection mc = re.Matches(result); foreach (Match ma in mc) { if (ma.Groups[2].Value.ToString().Contains("catalogName")) { return(ma.Groups[1].Value); } } return(null); }
public string SubmitOrder(Order order, string str = null) { try { CookieContainer coockie = new CookieContainer(); if (string.IsNullOrEmpty(str)) { str = setPostDate(order); } WriteLog.Write("方法:SubmitOrder,订单号:" + order.OrderInsideID + " ShuShan 提交参数:" + str.ToString(), LogPathFile.Recharge.ToString()); string result = PostAndGet.HttpPostString(submitUrl, str.ToString(), ref coockie); WriteLog.Write("方法:SubmitOrder,订单号:" + order.OrderInsideID + " ShuShan 提交返回:" + result, LogPathFile.Recharge.ToString()); return(result); } catch (Exception ex) { WriteLog.Write("方法:SubmitOrder,订单号:" + order.OrderInsideID + " 异常:" + ex.Message, LogPathFile.Exception.ToString()); return(null); } }
public Order Query(Order order) { string MerchantID = PayAndQueryXunTong.merchantID; string key = PayAndQueryXunTong.key; string QueryUrl = PayAndQueryXunTong.QueryUrl; CookieContainer coockie = new CookieContainer(); string username = MerchantID; // 接入代理用户名 string type = "qb"; // 查询类型(固定:qb) string sporderid = order.OrderInsideID; // SP订单号,商户平台的订单号,最长32位(yyyyMMddHHmmss+8) string buyhaoma = order.TargetAccount; // 要进行查询的号码 string sign = ""; // MD5组合数字签名方式:MD5(username={}&type={}&sporderid={}&buyhaoma={}&key=APIkey加密串均为小写,MD5输出为32位小写 string strmd5 = "username="******"&type=" + type + "&sporderid=" + sporderid + "&buyhaoma=" + buyhaoma + "&key=" + key;; sign = Md5Helper.MD5Encrypt(strmd5); StringBuilder str = new StringBuilder(); str.AppendFormat("username={0}", username); str.AppendFormat("&type={0}", type); str.AppendFormat("&sporderid={0}", sporderid); str.AppendFormat("&buyhaoma={0}", buyhaoma); str.AppendFormat("&sign={0}", sign); WriteLog.Write("方法:Query,订单号:" + order.OrderInsideID + " XunTong 订单查询参数:" + str.ToString(), LogPathFile.Recharge.ToString()); string result = PostAndGet.HttpPostString(QueryUrl, str.ToString(), ref coockie); WriteLog.Write("方法:Query,订单号:" + order.OrderInsideID + " XunTong 订单查询:" + result, LogPathFile.Recharge.ToString()); // 001 充值成功 002 充值失败 003 充值处理中 004,已冲正 005,充正中 006其他情况 if (result.Equals("001") || result.Equals("004")) { order.RechargeStatus = (int)OrderRechargeStatus.successful; order.RechargeMsg = EnumService.GetDescription(OrderRechargeStatus.successful); } else if (result.Equals("002")) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = EnumService.GetDescription(OrderRechargeStatus.failure); } else if (result.Equals("003") || result.Equals("005") || result.Equals("006")) { //充值中 } else { order.RechargeStatus = (int)OrderRechargeStatus.suspicious; order.RechargeMsg = EnumService.GetDescription(OrderRechargeStatus.suspicious); } return(order); }
public Order Query(Order order) { string MerchantID = PayAndQueryMBJ.merchantID; string key = PayAndQueryMBJ.key; string QueryUrl = PayAndQueryMBJ.queryUrl; CookieContainer coockie = new CookieContainer(); string strmd5 = MerchantID + order.OrderInsideID + key; string sign = Md5Helper.MD5Encrypt(strmd5); StringBuilder str = new StringBuilder(); str.AppendFormat("MerchantID={0}", MerchantID); //商家编号 str.AppendFormat("&MerchantOrderID={0}", order.OrderInsideID); //商家订单编号 str.AppendFormat("&Sign={0}", sign); //数字签名 WriteLog.Write("方法:Query,订单号:" + order.OrderInsideID + " MBJ 订单查询参数:" + str.ToString(), LogPathFile.Recharge.ToString()); string result = PostAndGet.HttpPostString(QueryUrl, str.ToString(), ref coockie); WriteLog.Write("方法:Query,订单号:" + order.OrderInsideID + " MBJ 订单查询:" + result, LogPathFile.Recharge.ToString()); string state = Regex.Match(result, @"<state>(.*?)</state>").Groups[1].Value; string mbjOrderId = Regex.Match(result, @"<order-id>(.*?)</order-id>").Groups[1].Value; string mbjStateInfo = Regex.Match(result, @"<state-info>(.*?)</state-info>").Groups[1].Value; if (state.Equals("101")) { order.RechargeStatus = (int)OrderRechargeStatus.successful; order.RechargeMsg = mbjStateInfo + "-" + mbjOrderId; } else if (state.Equals("201") || state.Equals("202") || state.Equals("203") || state.Equals("301") || state.Equals("302") || state.Equals("304") || state.Equals("305") || state.Equals("306") || state.Equals("307") || state.Equals("401") || state.Equals("405") || state.Equals("501")) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = mbjStateInfo + "-" + mbjOrderId; } else if (state.Equals("601")) { int status = getOrderStatus(mbjStateInfo, "601"); order.RechargeStatus = status; order.RechargeMsg = mbjStateInfo + "-" + mbjOrderId; } else if (state.Equals("102")) {//充值中 } else { order.RechargeStatus = (int)OrderRechargeStatus.suspicious; order.RechargeMsg = EnumService.GetDescription(OrderRechargeStatus.suspicious) + "-" + mbjOrderId; } return(order); }
void ChargeOrder(object obj) { Order order = (Order)obj; CookieContainer cookie = new CookieContainer(); string checkAccount = PostAndGet.HttpGetString("https://pay.91y.com/servlet/do.ashx?a=changeuser&acc=" + order.TargetAccount + "&t=0.48772043911252916", "", ref cookie, "https://pay.91y.com/tel/"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",帐号检测提交返回:" + checkAccount, LogPathFile.Recharge); string Accounts = Regex.Match(checkAccount, @"Accounts: '(.*?)'").Groups[1].Value; string Nickname = Regex.Match(checkAccount, @"Nickname: '(.*?)'").Groups[1].Value; string GameID = Regex.Match(checkAccount, @"GameID: '(.*?)'").Groups[1].Value; if (Accounts.Equals("0")) { order.RechargeMsg = "帐号错误"; order.RechargeStatus = (int)OrderRechargeStatus.failure; return; } int count = 0; while (order.RechargeStatus == (int)OrderRechargeStatus.processing) { if (count > 3) { order.RechargeStatus = (int)OrderRechargeStatus.failure; break; } string orderMsg = ReCharge(order, Accounts, cookie); string orderStatus = OrderStatusForXml.GetOrderStatus("91y", orderMsg); switch (orderStatus) { case "成功": order.RechargeStatus = (int)OrderRechargeStatus.successful; break; case "失败": order.RechargeStatus = (int)OrderRechargeStatus.failure; break; case "重复": order.RechargeStatus = (int)OrderRechargeStatus.processing; break; case "可疑": order.RechargeStatus = (int)OrderRechargeStatus.suspicious; break; default: order.RechargeStatus = (int)OrderRechargeStatus.suspicious; break; } count++; } }
bool login(Order order, ref CookieContainer cookie) { try { OrderChargeAccount orderChargeAccount = SQLOrderChargeAccount.GetChargeAccount(OrderChargeAccountType.XunYou, false); cookie = Common.CookieOperation.CookieHelper.ReadCookiesFromDisk(orderChargeAccount.ChargeAccount); string result = PostAndGet.HttpGetString_XY("http://my.xunyou.com/index.php/uCenter/getLoginId", "", ref cookie); if (!result.Contains("-1")) { return(true); } int loginCount = 0; while (loginCount < 5) { result = PostAndGet.HttpGetString_XY("https://my.xunyou.com/u/", "", ref cookie); string code = ""; //验证码 int codeid = 0; WrapperHelp.GetCodeByByte_UU("https://my.xunyou.com/index.php/imageoutput/VertifyCode/ver_code_1/50/24", ref cookie, 1005, ref code, ref codeid); string LoginData = "regfrom=uCenter&agree_rule=1&loginid=" + orderChargeAccount.ChargeAccount + "&password="******"&code=" + code; string LoginUrl = "https://my.xunyou.com/index.php/login/ajaxLoginGj"; result = PostAndGet.HttpPostString_XY(LoginUrl, LoginData, ref cookie, "my.xunyou.com", "https://my.xunyou.com/u/"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + orderChargeAccount.ChargeAccount + "||" + orderChargeAccount.ChargePassword + ",帐号登录返回:" + result, LogPathFile.Recharge); string msg = Regex.Match(result, @"""msg"":""(.*?)""").Groups[1].Value; string encodingMsg = ""; TypeCast.GetString(msg, ref encodingMsg); if (encodingMsg.Contains("登录成功")) { Common.CookieOperation.CookieHelper.WriteCookiesToDisk(orderChargeAccount.ChargeAccount, cookie); return(true); } else { if (encodingMsg.Contains("验证码错误") || result.Contains("验证码错误")) { WrapperHelp.reportError(codeid); } loginCount++; Thread.Sleep(1 * 1000); } } return(false); } catch (Exception) { return(false); } }
/// <summary> /// 发送模板消息 /// </summary> /// <param name="appid">微信AppId</param> /// <param name="secret">微信Secret</param> /// <param name="postjson">要发送的Json数据包</param> /// <returns></returns> public static Result SendTemplate(string appid, string secret, string postjson) { #region postjson格式 // { // "touser":"******", // "template_id":"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY", // "url":"http://weixin.qq.com/download", // "topcolor":"#FF0000", // "data":{ // "first": { // "value":"恭喜你购买成功!", // "color":"#173177" // }, // "keynote1":{ // "value":"巧克力", // "color":"#173177" // }, // "keynote2": { // "value":"39.8元", // "color":"#173177" // }, // "keynote3": { // "value":"2014年9月16日", // "color":"#173177" // }, // "remark":{ // "value":"欢迎再次购买!", // "color":"#173177" // } // } //} #endregion Result rlt = new Result(); try { string token = ""; rlt.Join(Init(appid, secret, out token)); string url = string.Format(" https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}", token); string result = PostAndGet.PostWebRequest(url, postjson, "utf-8"); Msg msg = JsonHelper.Deserialize <Msg>(result); if (msg.errcode != "0") { rlt.Add(err[msg.errcode].ToString()); } } catch (Exception ex) { Log.Log.Error(ex.Message, ex); rlt.Add("错误:" + ex.Message); } return(rlt); }
public static void VerificationFor91y(System.Net.CookieContainer cookie) { string url = "http://123.206.33.187:9000/crack/aLiYun"; string key = "FFFF00000000016860BF"; string scene = "login"; //FFFF00000000016860BF:1511432977354:0.8646665122863599 string t = key + ":" + GetTimeLikeJS() + ":0.8646665122863599"; string userid = "469FB388E2844B90A55E44D99852DE67"; string data = key + "&" + scene + "&" + t + "&" + userid; string result = PostAndGet.HttpGetString(url, data, ref cookie); }
/// <summary> /// /// </summary> /// <param name="appid"></param> /// <param name="secret"></param> /// <param name="code"></param> /// <returns></returns> public static string GetOpenIdByCode(string appid, string secret, string code) { bool wechatopen = true; Boolean.TryParse(ConfigHelper.GetAppSettings("WechatOpened"), out wechatopen); string url = string.Empty; string openid = string.Empty; url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appid + "&secret=" + secret + "&code=" + code + "&grant_type=authorization_code"; openid = PostAndGet.GetResponseString(url); openid = JsonHelper.GetFieldStr(openid, "openid"); return(openid); }
public string QueryOrder(Order order) { CookieContainer coockie = new CookieContainer(); string str = setPostDate_Query(order); WriteLog.Write("方法:QueryOrder,订单号:" + order.OrderInsideID + " Fulu 订单查询参数:" + str.ToString(), LogPathFile.Recharge.ToString()); string result = PostAndGet.HttpPostString_utf8(submitUrl, str.ToString(), ref coockie); WriteLog.Write("方法:QueryOrder,订单号:" + order.OrderInsideID + " Fulu 订单查询:" + result, LogPathFile.Recharge.ToString()); return(result); }
public string SubmitOrder(Order order, string str = null) { CookieContainer coockie = new CookieContainer(); if (string.IsNullOrEmpty(str)) { str = setPostDate(order); } WriteLog.Write("方法:SubmitOrder,订单号:" + order.OrderInsideID + " Xinqidian 提交参数:" + str.ToString(), LogPathFile.Recharge.ToString()); string result = PostAndGet.HttpPostString(submitUrl, str.ToString(), ref coockie); WriteLog.Write("方法:SubmitOrder,订单号:" + order.OrderInsideID + " Xinqidian 提交返回:" + result, LogPathFile.Recharge.ToString()); return(result); }
public string SubmitOrder(Order order, string str = null) { CookieContainer coockie = new CookieContainer(); if (string.IsNullOrEmpty(str)) { str = setPostDate(order, "http://116.62.44.48/NotifyForm99vip.aspx", AreaValueType._99vip); } WriteLog.Write("方法:SubmitOrder,订单号:" + order.OrderInsideID + " 99vip 提交参数:" + str.ToString(), LogPathFile.Recharge.ToString()); string result = PostAndGet.HttpPostString(submitUrl, str.ToString(), ref coockie); WriteLog.Write("方法:SubmitOrder,订单号:" + order.OrderInsideID + " 99vip 提交返回:" + result, LogPathFile.Recharge.ToString()); return(result); }
public string queryOrder(Order order, string merchantOrderID, ref string msg) { int num = 0; string status = "未处理"; while (num < 5) { coockie = new CookieContainer(); string strmd5 = merchantID + merchantOrderID + key; string sign = Md5Helper.GetMD5String_utf8(strmd5); StringBuilder str = new StringBuilder(); str.AppendFormat("MerchantID={0}", merchantID); str.AppendFormat("&OrderID={0}", merchantOrderID); //订单编号(多个订单以','分隔) str.AppendFormat("&Sign={0}", sign); //数字签名(MerchantID+OrderID+key) str.AppendFormat("&MerchantType={0}", "0"); //商家类型(默认为0):0进货商、1供货商 str.AppendFormat("&OrderIDType={0}", "0"); //状态(默认为0):0易约销售系统生成的订单编号、1合作商自定义的下游订单编号 WriteLog.Write("方法:Charge,订单号:" + order.OrderInsideID + " sup 订单查询参数:" + str.ToString(), LogPathFile.Recharge.ToString()); string result = PostAndGet.HttpPostString("http://hphy.eyuesale.com/api/QueryOrder", str.ToString(), ref coockie); WriteLog.Write("方法:Charge,订单号:" + order.OrderInsideID + " sup 订单查询:" + result, LogPathFile.Recharge.ToString()); status = Regex.Match(result, @"<Status>(.*?)</Status>").Groups[1].Value; msg = Regex.Match(result, @"<DetailMsg>(.*?)</DetailMsg>").Groups[1].Value; if (status == "未处理") { System.Threading.Thread.Sleep(2 * 1000); num++; } if (status == "充值成功" || status == "充值失败") { break; } if (num > 5) { status = "可疑"; msg = "查询订单结果失败"; } } return(status); }
/// <summary> /// 获得关注的用户列表 /// </summary> /// <param name="appid"></param> /// <param name="secret"></param> /// <param name="nextopenid"></param> /// <param name="json"></param> /// <returns></returns> public static Result GetUserList(string appid, string secret, string nextopenid, out string json) { json = ""; Result rlt = new Result(); try { string token = ""; rlt.Join(Init(appid, secret, out token)); if (rlt.IsValid) { string url = string.Format("https://api.weixin.qq.com/cgi-bin/user/get?access_token={0}&next_openid={1}", token, nextopenid); json = PostAndGet.GetResponseString(url); } } catch (Exception ex) { rlt.Add("错误:" + ex.Message); } return(rlt); }
/// <summary> /// 获得js接口授权需要的JSApi Ticket,7200s时效 /// </summary> /// <param name="appid">公众生成的AppID</param> /// <param name="secret">公众号生成的AppSecret</param> /// <returns></returns> public static String GetJsapi_ticket(string appid, string secret) { object jsapi = ""; try { object tempToken = MemoryCache.Get("CacheJsapi" + appid); if (tempToken == null || tempToken.ToString() == "") { string token = GetToken(appid, secret); string url = string.Format("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi", token); string result = PostAndGet.GetResponseString(url); try { jsapi = JsonHelper.GetField(result, "ticket"); if (jsapi != null && jsapi.ToString() != "") { MemoryCache.Set("CacheJsapi" + appid, jsapi, 7000); } } catch { Msg msg = JsonHelper.Deserialize <Msg>(result); if (msg.errcode != "0") { jsapi = err[msg.errcode]; } } } else { jsapi = tempToken; } } catch { jsapi = ""; } return(jsapi.ToString()); }
bool login(Order order, ref CookieContainer cookie) { try { int loginCount = 0; while (loginCount < 5) { cookie = new CookieContainer(); string result = PostAndGet.HttpGetString("http://login.sns.hongxiu.com/comlogin.aspx?url=http%3A//www.hongxiu.com/", "", ref cookie); string comLoginUrl = "http://login.sns.hongxiu.com/comlogin.aspx?url=http://pay.hongxiu.com"; OrderChargeAccount orderChargeAccount = SQLOrderChargeAccount.GetChargeAccount(OrderChargeAccountType.HongXiu, false); string comLoginData = "htmlUserName="******"&htmlPassword="******"&iskeeplogin=true&x=43&y=10&postcontent="; result = PostAndGet.HttpPostString_HX(comLoginUrl, comLoginData, ref cookie, "login.sns.hongxiu.com", "http://pay.hongxiu.com/default.shtml"); result = PostAndGet.HttpGetString("http://pay.hongxiu.com/model/GetUserBaseInfo.aspx?roundmun=0.5841341522289687", "", ref cookie); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + orderChargeAccount.ChargeAccount + "||" + orderChargeAccount.ChargePassword + ",帐号登录返回:" + result, LogPathFile.Recharge); if (result.Contains(orderChargeAccount.ChargeAccount)) { return(true); } else { loginCount++; Thread.Sleep(1 * 1000); } } return(false); } catch (Exception) { return(false); } }
public List <Order> getOrderFromSUP(ref int getOrderTime) { getOrderTime = time; List <Order> orderSet = new List <Order>(); try { string sign = Md5Helper.GetMD5String_utf8(merchantID + key); string postData = string.Format("MerchantID={0}&Sign={1}&ProductNo={2}&Count={3}&Status={4}", merchantID, sign, "", count, "0"); System.Net.CookieContainer cookie = new System.Net.CookieContainer(); WriteLog.Write("方法:getOrderFromSUP 获取订单参数:" + postData, LogPathFile.Other); string result = PostAndGet.HttpGetString(getOrderurl, postData, ref cookie); WriteLog.Write("方法:getOrderFromSUP 获取订单信息:" + result, LogPathFile.Other); string State = Regex.Match(result, @"<State>(.*?)</State>").Groups[0].Value; string State_Info = Regex.Match(result, @"<State_Info>(.*?)</State_Info>").Groups[0].Value; if (State.Contains("0") && State_Info.Contains("成功")) { assignmentOrder(orderSet, result); } } catch (Exception ex) { WriteLog.Write("方法:getOrderFromSUP异常,信息:" + ex.Message + ex.StackTrace, LogPathFile.Exception); } return(orderSet); }
/// <summary> /// 发送消息 /// </summary> /// <param name="appid">微信AppId</param> /// <param name="secret">微信Secret</param> /// <param name="openid">接受用户的OpenId</param> /// <param name="text">要发送的文本</param> /// <returns></returns> public static Result SendText(string appid, string secret, string openid, string text) { string json = "{\"touser\":\"" + openid + "\",\"msgtype\":\"text\",\"text\":{\"content\":\"" + text + "\"}}"; Result rlt = new Result(); try { string token = ""; rlt.Join(Init(appid, secret, out token)); string url = string.Format("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}", token); string result = PostAndGet.PostWebRequest(url, json, "utf-8"); Msg msg = JsonHelper.Deserialize <Msg>(result); if (msg.errcode != "0") { rlt.Add(err[msg.errcode].ToString()); } } catch (Exception ex) { rlt.Add("错误:" + ex.Message); } return(rlt); }
public Order Charge(Order order) { try { decimal totalPrice = (decimal)order.BuyAmount; decimal totalPriceFixed = totalPrice; int isContinue = 0; string payment = ""; if (!Getpayment((int)order.ProductParValue, ref payment)) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = "充值面值不合法"; return(order); } if (CheckStrHelper.IsChinese(order.TargetAccount)) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = "充值帐号不能为中文"; return(order); } if (order.TargetAccount.Length < 6 || order.TargetAccount.Length > 20) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = "请输入6~20位字母和数字"; return(order); } CookieContainer cookie = new CookieContainer(); while (totalPrice > 0) { #region 提交充值 if (isContinue > 3) //充值频繁,重试三次 { break; } totalPrice--;; #region 帐号登录 string result = PostAndGet.HttpGetString_XY("http://my.xunyou.com/index.php/uCenter/getLoginId", "", ref cookie); if (result.Contains("-1")) { if (!login(order, ref cookie)) { order.RechargeMsg = "帐号登录失败"; totalPrice++; isContinue++; continue; } } #endregion #region 获取参数 订单确认 string postURl = "https://my.xunyou.com/index.php/payment/confirmPayment2014"; StringBuilder postData = new StringBuilder(); postData.AppendFormat("payment_object={0}", System.Web.HttpUtility.UrlEncode(payment, Encoding.Default)); postData.AppendFormat("&isconversion={0}", "2"); postData.AppendFormat("&product_id={0}", "2"); postData.AppendFormat("&payment_login={0}", order.TargetAccount); postData.AppendFormat("&usernameinput={0}", order.TargetAccount); postData.AppendFormat("&payment_login_confirm={0}", order.TargetAccount); postData.AppendFormat("&payment_card={0}", "ICBC-NET"); postData.AppendFormat("&selected_product_name={0}", "%E8%BF%85%E6%B8%B8VIP"); postData.AppendFormat("&user_mask1={0}", ""); postData.AppendFormat("&user_mask2={0}", ""); postData.AppendFormat("&addition_product_id={0}", ""); postData.AppendFormat("&userid={0}", ""); postData.AppendFormat("&sub_product_class={0}", ""); postData.AppendFormat("&client={0}", " 0"); postData.AppendFormat("&payment_method={0}", "28"); postData.AppendFormat("&eid={0}", "10612"); postData.AppendFormat("&gameid={0}", "0"); postData.AppendFormat("&gid={0}", "0"); postData.AppendFormat("&cdkey={0}", "0"); postData.AppendFormat("&payment_card_account={0}", ""); postData.AppendFormat("&payment_card_password={0}", ""); postData.AppendFormat("&payment_bank={0}", "8001"); postData.AppendFormat("&vertifycode={0}", ""); postData.AppendFormat("&mobile_num={0}", ""); postData.AppendFormat("&packid={0}", "0"); postData.AppendFormat("&mac={0}", ""); postData.AppendFormat("&pageid={0}", "4"); postData.AppendFormat("&pwd={0}", ""); postData.AppendFormat("&spid={0}", ""); postData.AppendFormat("&spid2={0}", ""); result = PostAndGet.HttpPostString(postURl, postData.ToString(), ref cookie, "https://my.xunyou.com/pay/?eid=10612"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",订单第一步提交返回:" + result, LogPathFile.Recharge); if (result.Contains("用户不存在")) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = "用户不存在"; return(order); } if (result.Contains("请更换其他支付方式")) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = "帐号未设置安全工具"; return(order); } if (!result.Contains("确认订单")) { totalPrice++; isContinue++; continue; } #endregion #region Vbi钱包充值 string spid = Regex.Match(result, @"value=""(.*?)"" name=""spid""").Groups[1].Value; string spname = Regex.Match(result, @"value=""(.*?)"" name=""spname""").Groups[1].Value; string spoid = Regex.Match(result, @"value=""(.*?)"" name=""spoid""").Groups[1].Value; string spreq = Regex.Match(result, @"value=""(.*?)"" name=""spreq""").Groups[1].Value; string sprec = Regex.Match(result, @"value=""(.*?)"" name=""sprec""").Groups[1].Value; string userip = Regex.Match(result, @"value=""(.*?)"" name=""userip""").Groups[1].Value; string spcustom = Regex.Match(result, @"value=""(.*?)"" name=""spcustom""").Groups[1].Value; string spversion = Regex.Match(result, @"value=""(.*?)"" name=""spversion""").Groups[1].Value; string money = Regex.Match(result, @"value=""(.*?)"" name=""money""").Groups[1].Value; string urlcode = Regex.Match(result, @"value=""(.*?)"" name=""urlcode""").Groups[1].Value; string spmd5 = Regex.Match(result, @"value=""(.*?)"" name=""spmd5""").Groups[1].Value; string userid = Regex.Match(result, @"value=""(.*?)"" name=""userid""").Groups[1].Value; string payment_object = Regex.Match(result, @"value=""(.*?)"" name=""payment_object""").Groups[1].Value; string payment_orderid = Regex.Match(result, @"value=""(.*?)"" name=""payment_orderid""").Groups[1].Value; string payment_login = Regex.Match(result, @"value=""(.*?)"" name=""payment_login""").Groups[1].Value; string payment_product = Regex.Match(result, @"value=""(.*?)"" name=""payment_product""").Groups[1].Value; string payment_paymoney = Regex.Match(result, @"value=""(.*?)"" name=""payment_paymoney""").Groups[1].Value; StringBuilder vnetonePostdataBuilder = new StringBuilder(); vnetonePostdataBuilder.AppendFormat("spid={0}", spid); vnetonePostdataBuilder.AppendFormat("&spname={0}", System.Web.HttpUtility.UrlEncode(spname, Encoding.Default)); vnetonePostdataBuilder.AppendFormat("&spoid={0}", spoid); vnetonePostdataBuilder.AppendFormat("&spreq={0}", System.Web.HttpUtility.UrlEncode(spreq, Encoding.Default)); vnetonePostdataBuilder.AppendFormat("&sprec={0}", System.Web.HttpUtility.UrlEncode(sprec, Encoding.Default)); vnetonePostdataBuilder.AppendFormat("&userip={0}", userip); vnetonePostdataBuilder.AppendFormat("&spcustom={0}", spcustom); vnetonePostdataBuilder.AppendFormat("&spversion={0}", spversion); vnetonePostdataBuilder.AppendFormat("&money={0}", money); vnetonePostdataBuilder.AppendFormat("&urlcode={0}", urlcode); vnetonePostdataBuilder.AppendFormat("&spmd5={0}", spmd5); vnetonePostdataBuilder.AppendFormat("&userid={0}", userid); vnetonePostdataBuilder.AppendFormat("&payment_object={0}", System.Web.HttpUtility.UrlEncode(payment_object, Encoding.Default)); vnetonePostdataBuilder.AppendFormat("&payment_orderid={0}", payment_orderid); vnetonePostdataBuilder.AppendFormat("&payment_login={0}", payment_login); vnetonePostdataBuilder.AppendFormat("&payment_product={0}", System.Web.HttpUtility.UrlEncode(payment_product, Encoding.Default)); vnetonePostdataBuilder.AppendFormat("&payment_paymoney={0}", System.Web.HttpUtility.UrlEncode(payment_paymoney, Encoding.Default)); OrderChargeAccount orderChargeAccount = SQLOrderChargeAccount.GetChargeAccount(OrderChargeAccountType.Vbi); if (orderChargeAccount == null) { order.RechargeMsg += "未取到v币帐号||"; totalPrice++; isContinue++; continue; } result = VbiChargeHelper.VbiCharge(vnetonePostdataBuilder.ToString(), order, orderChargeAccount, cookie); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",V币钱包充值返回:" + result, LogPathFile.Recharge); #endregion #region 迅游订单查询 result = PostAndGet.HttpGetString_XY("https://my.xunyou.com/index.php/payment/getOrderState/" + spoid, "", ref cookie); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",订单查询结果:" + result, LogPathFile.Recharge); string xyOrderStatus = Regex.Match(result, @"{""state"":(.*?),").Groups[1].Value; string xyfpaysuccess = Regex.Match(result, @"""fpaysuccess"":""(.*?)"",").Groups[1].Value; if (xyOrderStatus == "1") { if (xyfpaysuccess == "1") { order.RechargeMsg += spoid + "充值成功||"; order.SuccessfulAmount += order.ProductParValue; orderChargeAccount.Balance = orderChargeAccount.Balance - order.ProductParValue; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); } else if (xyfpaysuccess == "0") { order.RechargeMsg += spoid + "未支付成功||"; totalPrice++; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); isContinue = isContinue + 6; } else { order.RechargeMsg += spoid + "存疑||"; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); } } else { order.RechargeMsg += spoid + "存疑||"; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); } #endregion #region VB充值结果判断 //if (result.Contains("成功") || result.Contains("您已成功充值") || result.Contains("成功充值")) //{ // order.RechargeMsg += "充值成功||"; // order.SuccessfulAmount += order.ProductParValue; // orderChargeAccount.Balance = orderChargeAccount.Balance - order.ProductParValue; // SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); //} //else if (result.Contains("请五分钟后再登陆商户网站进行帐户查询")) //{ // order.RechargeMsg += "充值成功(请五分钟后再登陆商户网站进行帐户查询)||"; // order.SuccessfulAmount += order.ProductParValue; // orderChargeAccount.Balance = orderChargeAccount.Balance - order.ProductParValue; // SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); //} //else if (result.Contains("操作失败")) //{ // order.RechargeMsg += "操作失败||"; // totalPrice++; // SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); // isContinue++; //} //else if (result.Contains("充值过于频繁")) //{ // order.RechargeMsg += "充值频繁||"; // totalPrice++; // SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); // isContinue++; //} //else if (result.Contains("验证码输入不正确")) //{ // order.RechargeMsg += "验证码输入不正确||"; // totalPrice++; // SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); // isContinue++; //} //else if (result.Contains("账户余额不足")) //{ // order.RechargeMsg += "账户余额不足||"; // totalPrice++; // SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false, false); //} //else if (result.Contains("支付密码不正确")) //{ // order.RechargeMsg += "支付密码不正确||"; // totalPrice++; // SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false, false); //} //else if (result.Contains("用户不存在")) //{ // order.RechargeMsg += "用户不存在||"; // totalPrice++; // SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false, false); //} //else //{ // order.RechargeMsg += "存疑||"; // SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); //} #endregion #endregion } #region 订单状态判断 if (order.SuccessfulAmount >= totalPriceFixed) { order.RechargeStatus = (int)OrderRechargeStatus.successful; } else { order.RechargeStatus = (int)OrderRechargeStatus.suspicious; } #endregion return(order); } catch (Exception ex) { order.RechargeStatus = (int)OrderRechargeStatus.suspicious; WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",充值一场信息:" + ex.Message, LogPathFile.Exception); return(order); } }
public Order Charge(Order order) { try { decimal totalPrice = (decimal)(order.BuyAmount * 2); decimal totalPriceFixed = totalPrice; int isContinue = 0; while (totalPrice > 0) { #region 提交充值 int chargeVbiNum = 0; if (isContinue > 3) //充值频繁,重试三次 { break; } if (!GetChargeNum((int)totalPrice, ref chargeVbiNum)) { break; } totalPrice = totalPrice - chargeVbiNum; string result = ""; CookieContainer cookie = new CookieContainer(); #region 帐号登录 result = PostAndGet.HttpGetString("http://pay.hongxiu.com/model/GetUserBaseInfo.aspx?roundmun=0.8916430823085395", "", ref cookie); if (string.IsNullOrEmpty(result)) { if (!login(order, ref cookie)) { totalPrice += chargeVbiNum; order.RechargeMsg = "帐号登录失败"; continue; } } #endregion #region 获取参数 订单确认 result = PostAndGet.HttpGetString("http://pay.hongxiu.com/model/GetUserBaseInfo.aspx?roundmun=0.8916430823085395", "", ref cookie); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",获取登录信息:" + result, LogPathFile.Recharge); string [] arrLoginAccount = result.Split('|'); if (arrLoginAccount.Length < 2) { break; } string txtUserid = arrLoginAccount[0]; string txtusername = arrLoginAccount[1]; result = PostAndGet.HttpGetString_HX("http://hxzz.hxcdn.net/?d=pay.hongxiu.com&hxid=" + txtUserid + "&f=/default.shtml&q=&aid=0&bid=0", "", ref cookie, "hxzz.hxcdn.net", "http://pay.hongxiu.com/default.shtml"); result = PostAndGet.HttpGetString_HX("http://pay.hongxiu.com/charge/guhua.shtml", "", ref cookie, "pay.hongxiu.com"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",充值页面提交返回:" + result, LogPathFile.Recharge); StringBuilder payTypeDataBuilder = new StringBuilder(); payTypeDataBuilder.AppendFormat("usertype={0}", "1"); payTypeDataBuilder.AppendFormat("&txtotherusername={0}", System.Web.HttpUtility.UrlEncode(order.TargetAccount, Encoding.UTF8)); payTypeDataBuilder.AppendFormat("&txtreotherusername={0}", System.Web.HttpUtility.UrlEncode(order.TargetAccount, Encoding.UTF8)); payTypeDataBuilder.AppendFormat("&txtuserid={0}", txtUserid); payTypeDataBuilder.AppendFormat("&txtusername={0}", txtusername); result = PostAndGet.HttpPostString_HX("http://pay.hongxiu.com/charge/cp.aspx?paytype=votev2", payTypeDataBuilder.ToString(), ref cookie, "pay.hongxiu.com"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",订单第一步提交返回:" + result, LogPathFile.Recharge); if (result.Contains("此用户不存在")) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = "此用户不存在"; return(order); } result = PostAndGet.HttpGetString("http://pay.hongxiu.com/charge/TelChargeV2.aspx", "", ref cookie, "http://pay.hongxiu.com/charge/cp.aspx?paytype=votev2"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",订单第二步提交返回:" + result, LogPathFile.Recharge); string __VIEWSTATE = Regex.Match(result, @"id=""__VIEWSTATE"" value=""(.*?)""\s+/>").Groups [1].Value; string __EVENTVALIDATION = Regex.Match(result, @"id=""__EVENTVALIDATION"" value=""(.*?)""\s+/>").Groups[1].Value; StringBuilder chargeV2DataBuilder = new StringBuilder(); payTypeDataBuilder.AppendFormat("__VIEWSTATE={0}", __VIEWSTATE); payTypeDataBuilder.AppendFormat("&__EVENTVALIDATION={0}", __EVENTVALIDATION); payTypeDataBuilder.AppendFormat("&userid={0}", order.TargetAccount); payTypeDataBuilder.AppendFormat("&btnSubmit={0}", "=%E6%8F%90++%E4%BA%A4"); payTypeDataBuilder.AppendFormat("&txtusername={0}", chargeVbiNum); result = PostAndGet.HttpGetString("http://pay.hongxiu.com/charge/TelChargeV2.aspx", chargeV2DataBuilder.ToString(), ref cookie); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",订单第二步确认提交返回:" + result, LogPathFile.Recharge); result = PostAndGet.HttpGetString("http://pay.hongxiu.com/charge/ChargeStep3.aspx", "", ref cookie); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",订单第三步提交返回:" + result, LogPathFile.Recharge); //if (!result.Contains("充值确认")) //{ // totalPrice += chargeVbiNum; // continue; //} #endregion #region Vbi钱包充值 string spid = Regex.Match(result, @"name='spid'\s+value='(.*?)'>").Groups[1].Value; string spname = Regex.Match(result, @"name='spname'\s+value='(.*?)'>").Groups[1].Value; string spoid = Regex.Match(result, @"name='spoid'\s+value='(.*?)'>").Groups[1].Value; string spreq = Regex.Match(result, @"name='spreq'\s+value='(.*?)'>").Groups[1].Value; string sprec = Regex.Match(result, @"name='sprec'\s+value='(.*?)'>").Groups[1].Value; string userid = Regex.Match(result, @"name='userid'\s+value='(.*?)'>").Groups[1].Value; string userip = Regex.Match(result, @"name='userip'\s+value='(.*?)'>").Groups[1].Value; string spmd5 = Regex.Match(result, @"name='spmd5'\s+value='(.*?)'>").Groups[1].Value; string spcustom = Regex.Match(result, @"name='spcustom'\s+value='(.*?)'>").Groups[1].Value; string spversion = Regex.Match(result, @"name='spversion'\s+value='(.*?)'>").Groups[1].Value; string money = Regex.Match(result, @"name='money'\s+value='(.*?)'>").Groups[1].Value; string urlcode = Regex.Match(result, @"name='urlcode'\s+value='(.*?)'>").Groups[1].Value; StringBuilder vnetonePostdataBuilder = new StringBuilder(); vnetonePostdataBuilder.AppendFormat("spid={0}", spid); vnetonePostdataBuilder.AppendFormat("&spname={0}", System.Web.HttpUtility.UrlEncode(spname, Encoding.UTF8)); vnetonePostdataBuilder.AppendFormat("&spoid={0}", spoid); vnetonePostdataBuilder.AppendFormat("&spreq={0}", System.Web.HttpUtility.UrlEncode(spreq, Encoding.UTF8)); vnetonePostdataBuilder.AppendFormat("&sprec={0}", System.Web.HttpUtility.UrlEncode(sprec, Encoding.UTF8)); vnetonePostdataBuilder.AppendFormat("&userid={0}", userid); vnetonePostdataBuilder.AppendFormat("&userip={0}", userip); vnetonePostdataBuilder.AppendFormat("&spmd5={0}", spmd5); vnetonePostdataBuilder.AppendFormat("&spcustom={0}", System.Web.HttpUtility.UrlEncode(spcustom, Encoding.UTF8)); vnetonePostdataBuilder.AppendFormat("&spversion={0}", spversion); vnetonePostdataBuilder.AppendFormat("&money={0}", money); vnetonePostdataBuilder.AppendFormat("&urlcode={0}", urlcode); OrderChargeAccount orderChargeAccount = SQLOrderChargeAccount.GetChargeAccount(OrderChargeAccountType.Vbi); if (orderChargeAccount == null) { order.RechargeMsg += "未取到v币帐号||"; totalPrice++; isContinue++; continue; } result = VbiChargeHelper.VbiCharge(vnetonePostdataBuilder.ToString(), order, orderChargeAccount, cookie); #endregion #region 充值结果判断 if (result.Contains("成功") || result.Contains("您已成功充值")) { order.RechargeMsg += "充值成功||"; order.SuccessfulAmount += chargeVbiNum; orderChargeAccount.Balance = orderChargeAccount.Balance - chargeVbiNum; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); } else if (result.Contains("请五分钟后再登陆商户网站进行帐户查询")) { order.RechargeMsg += "充值成功(请五分钟后再登陆商户网站进行帐户查询)||"; order.SuccessfulAmount += chargeVbiNum; orderChargeAccount.Balance = orderChargeAccount.Balance - chargeVbiNum; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); } else if (result.Contains("操作失败")) { order.RechargeMsg += "操作失败||"; totalPrice += chargeVbiNum; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); isContinue++; } else if (result.Contains("充值过于频繁")) { order.RechargeMsg += "充值频繁||"; totalPrice += chargeVbiNum; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); isContinue++; } else if (result.Contains("验证码输入不正确")) { order.RechargeMsg += "验证码输入不正确||"; totalPrice += chargeVbiNum; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); isContinue++; } else if (result.Contains("账户余额不足")) { order.RechargeMsg += "账户余额不足||"; totalPrice += chargeVbiNum; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false, false); } else if (result.Contains("支付密码不正确")) { order.RechargeMsg += "支付密码不正确||"; totalPrice += chargeVbiNum; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false, false); } else if (result.Contains("用户不存在")) { order.RechargeMsg += "用户不存在||"; totalPrice += chargeVbiNum; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false, false); } else { order.RechargeMsg += "存疑||"; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); } #endregion #endregion } #region 订单状态判断 if (order.SuccessfulAmount >= totalPriceFixed) { order.RechargeStatus = (int)OrderRechargeStatus.successful; } else { order.RechargeStatus = (int)OrderRechargeStatus.suspicious; } #endregion return(order); } catch (Exception ex) { order.RechargeStatus = (int)OrderRechargeStatus.suspicious; WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",充值一场信息:" + ex.Message, LogPathFile.Exception); return(order); } }
public Order Query(Order order) { string MerchantID = PayAndQueryZhiXin.merchantID; string key = PayAndQueryZhiXin.key; string QueryUrl = PayAndQueryZhiXin.QueryUrl; CookieContainer coockie = new CookieContainer(); string dateStr = DateTime.Now.ToString("yyyyMMddHHmmss"); string mrch_no = MerchantID; // 商户编号 商户代号 是 20 string request_time = dateStr; // 请求时间 格式:yyyyMMddHHmmss 是 14 string client_order_no = order.OrderInsideID; // 商户订单号 是 32 string order_time = dateStr; // 订单下单时间:yyyyMMddHHmmss //注意: //1. 充值平台从order_time字段截取订单日期T(yyyyMMdd),查询该日期的订单数据。若无订单,则尝试查询(T-1)及(T+1)日期的订单数据。 //2. 仅提供近3个月的订单数据 是 14 string sign = MerchantID;// 签名数据 数据签名 是 32 string strmd5 = "client_order_no" + client_order_no + "mrch_no" + mrch_no + "order_time" + order_time + "request_time" + request_time + key; sign = Md5Helper.MD5Encrypt(strmd5); string json = "{\"mrch_no\":\"" + mrch_no + "\",\"request_time\":\"" + request_time + "\",\"client_order_no\":\"" + client_order_no + "\",\"order_time\":\"" + order_time + "\",\"sign\":\"" + sign + "\"}"; WriteLog.Write("方法:Query,订单号:" + order.OrderInsideID + " ZhiXin 订单查询参数:" + json, LogPathFile.Recharge.ToString()); string result = PostAndGet.HttpPostString_utf8(QueryUrl, json, ref coockie); WriteLog.Write("方法:Query,订单号:" + order.OrderInsideID + " ZhiXin 订单查询:" + result, LogPathFile.Recharge.ToString()); // 1:充值中 2:充值成功 6:充值失败 string code = Regex.Match(result, @"""code"":""(.*?)""").Groups[1].Value; string up_order_no = Regex.Match(result, @"""up_order_no"":""(.*?)""").Groups[1].Value; string recharge_status = Regex.Match(result, @"""recharge_status"":""(.*?)""").Groups[1].Value; string desc = Regex.Match(result, @"""desc"":""(.*?)""").Groups[1].Value; string message = Regex.Match(result, @"""message"":""(.*?)""").Groups[1].Value; if (code == "2") { if (recharge_status == "2") { order.RechargeStatus = (int)OrderRechargeStatus.successful; order.RechargeMsg = desc + up_order_no; } else if (recharge_status == "6") { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = desc + up_order_no; } else if (recharge_status == "1") { //充值中 } } else if (code == "600" || code == "602" || code == "603" || code == "606" || code == "622" || code == "623" || code == "624" || code == "615" || code == "637" || code == "715") { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = message + up_order_no; } else { order.RechargeStatus = (int)OrderRechargeStatus.suspicious; order.RechargeMsg = EnumService.GetDescription(OrderRechargeStatus.suspicious); } #region Code //2 操作成功 预受理 提交成功,订单充值中 //600 商户禁用,接口已关闭 预受理 失败 //602 订单提交失败,未充值 预受理 失败 //603 请求数据格式错误 预受理 失败 //606 数据签名错误 预受理 失败 //622 商户不存在 预受理 失败 //623 通道维护 预受理 失败 //624 产品未配置 预受理 失败 //615 号码归属地未配置 预受理 失败 //637 流量充值未配置 预受理 失败 //751 IP地址限制 预受理 失败 //625 重复订单号 预受理 存疑 //查询订单状态或人工核实 //其他返回码 网络问题导致提交异常或其他返回码 预受理 存疑 //查询订单状态或人工核实 #endregion #region recharge_status //2 操作成功 订单状态查询 操作成功,根据recharge_status判定订单状态 //recharge_status:1,充值中 //recharge_status:2,充值成功 //recharge_status:6,充值失败 //626 未查询到订单信息 订单状态查询 1. 请检查order_time(订单下单时间)字段是否准确,该字段影响订单查询结果。 // 2. 在订单提交10分钟后,订单查询接口仍未查询到订单信息,订单可作失败处理 //603 请求数据不正确或查询异常 订单状态查询 再次查询或人工核实。若返回该状态码,不能做订单失败处理。 #endregion return(order); }
public static string VbiCharge_Max(string data, Order order, OrderChargeAccount orderChargeAccount, CookieContainer cookie) { try { #region 固话钱包 string result = PostAndGet.HttpPostString("http://s2.vnetone.com/Default.aspx", data, ref cookie); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",订单第三步提交返回:" + result, LogPathFile.Recharge); if (result.Contains("操作失败")) { return("操作失败_F"); } string __VIEWSTATE = Regex.Match(result, @"id=""__VIEWSTATE"" value=""(.*?)"" />").Groups[1].Value; string __EVENTVALIDATION = Regex.Match(result, @"id=""__EVENTVALIDATION"" value=""(.*?)"" />").Groups[1].Value; #endregion #region 获取代充帐号 string txtQBCard = orderChargeAccount.ChargeAccount; //代充账号 string txtQBPwd = orderChargeAccount.PayPassword; //支付密码 order.ChargeAccountInfo = order.ChargeAccountInfo + txtQBCard + "," + txtQBPwd + "||"; #endregion #region 钱包最后一步提交 int reChargeCount = 0; //验证码重试次数 ReCharge: string txtQBValCode = ""; //验证码 int codeid = 0; WrapperHelp.GetCodeByByte_UU("http://s2.vnetone.com/Validate/GetImageCodeSinWallet.aspx?time=148311417206464", ref cookie, 1004, ref txtQBValCode, ref codeid); StringBuilder PostdataBuilder = new StringBuilder(); PostdataBuilder.AppendFormat("__VIEWSTATE={0}", System.Web.HttpUtility.UrlEncode(__VIEWSTATE, Encoding.UTF8)); PostdataBuilder.AppendFormat("&__EVENTVALIDATION={0}", System.Web.HttpUtility.UrlEncode(__EVENTVALIDATION, Encoding.UTF8)); PostdataBuilder.AppendFormat("&uid9qb={0}", System.Web.HttpUtility.UrlEncode(txtQBCard, Encoding.UTF8)); PostdataBuilder.AppendFormat("&zfpwd9qb={0}", VbiChargeHelper.GetPwdMethod(new string[] { txtQBPwd })); PostdataBuilder.AppendFormat("&TextBox8={0}", txtQBValCode); PostdataBuilder.AppendFormat("&ImageButton1.x={0}", "62"); PostdataBuilder.AppendFormat("&ImageButton1.y={0}", "10"); result = PostAndGet.HttpPostString("http://s2.vnetone.com/Default.aspx", PostdataBuilder.ToString(), ref cookie, "http://s2.vnetone.com/Default.aspx"); if (result.Contains("验证码输入不正确") && reChargeCount < 10) { WrapperHelp.reportError(codeid); reChargeCount++; goto ReCharge; } WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",订单第四步提交参数:" + PostdataBuilder.ToString() + ",订单第四步提交返回:" + result, LogPathFile.Recharge); #endregion return(result); } catch (Exception ex) { WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",充值异常信息:" + ex.Message, LogPathFile.Exception); return("充值异常"); } }
bool ReCharge(Order order, int payNum, string payuid, CookieContainer cookie, ref string CardNumber, ref string status, ref string msg) { #region 参数提交 string ordercollectUrl = "http://pay.web.7k7k.com/ordercollect"; StringBuilder ordercollectStr = new StringBuilder(); ordercollectStr.AppendFormat("payuid={0}", payuid); ordercollectStr.AppendFormat("&paywhere={0}", "2"); string result = PostAndGet.HttpPostString_HX(ordercollectUrl, ordercollectStr.ToString(), ref cookie, "pay.web.7k7k.com", "http://pay.web.7k7k.com/?qq-pf-to=pcqq.c2c"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",订单第一步提交返回:" + result, LogPathFile.Recharge); string cid = Regex.Match(result, @"""cid"":""(.*?)"",").Groups[1].Value; Cards cards = SQLCards.GetChargeCards(OrderChargeAccountType.MMCard, payNum); if (cards == null) { status = "失败"; msg = "取卡失败||"; return(true); } CardNumber = cards.CardNumber; string payorderUrl = "http://pay.web.7k7k.com/payorder"; StringBuilder payorderStr = new StringBuilder(); payorderStr.AppendFormat("paywhere={0}", "2"); payorderStr.AppendFormat("&paychannel={0}", "30"); payorderStr.AppendFormat("&confirmusername={0}", order.TargetAccount); payorderStr.AppendFormat("&payuid={0}", payuid); payorderStr.AppendFormat("&gametext={0}", "1.%E9%80%89%E6%8B%A9%E6%B8%B8%E6%88%8F"); payorderStr.AppendFormat("&gid={0}", ""); payorderStr.AppendFormat("&servertext={0}", "2.%E9%80%89%E6%8B%A9%E5%8C%BA%E6%9C%8D"); payorderStr.AppendFormat("&server_id={0}", ""); payorderStr.AppendFormat("&cardnumber={0}", cards.CardNumber); payorderStr.AppendFormat("&cardpass={0}", cards.CardPassWord); payorderStr.AppendFormat("&kbyue={0}", ""); payorderStr.AppendFormat("&passstatus={0}", "0"); payorderStr.AppendFormat("&select_paytype={0}", "1"); payorderStr.AppendFormat("&select_bank={0}", "ICBC-NET-B2C"); payorderStr.AppendFormat("&category={0}", "1"); payorderStr.AppendFormat("&cid={0}", cid); payorderStr.AppendFormat("&amt={0}", payNum); payorderStr.AppendFormat("&user_sta={0}", "true"); result = PostAndGet.HttpPostString(payorderUrl, payorderStr.ToString(), ref cookie); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",米米卡提交返回:" + result, LogPathFile.Recharge); if (result.Contains("充值失败")) { status = "失败"; msg = "充值失败(充值失败,请确认您的卡号密码后重试)||"; cards.ReChargeStatus = (int)OrderRechargeStatus.untreated; cards.ReChargeMsg += msg; SQLCards.UpdateCards_ByMultiple(cards); return(true); } else if (result.Contains("充值成功")) { status = "成功"; msg = cid + "充值成功||"; cards.ReChargeStatus = (int)OrderRechargeStatus.successful; cards.ReChargeMsg += msg; SQLCards.UpdateCards_ByMultiple(cards); return(true); } else if (result.Contains("米米卡余额不足")) { status = "失败"; msg = "余额不足||"; cards.ReChargeStatus = (int)OrderRechargeStatus.failure; cards.ReChargeMsg += msg; SQLCards.UpdateCards_ByMultiple(cards); return(true); } else if (result.Contains("提交失败")) { status = "失败"; if (result.Contains("订单号重复")) { msg = "订单号重复||"; } else { msg = "提交失败||"; } cards.ReChargeStatus = (int)OrderRechargeStatus.untreated; cards.ReChargeMsg += msg; SQLCards.UpdateCards_ByMultiple(cards); return(true); } else { status = "可疑"; msg = "充值存疑"; cards.ReChargeStatus = (int)OrderRechargeStatus.suspicious; cards.ReChargeMsg += msg; SQLCards.UpdateCards_ByMultiple(cards); return(false); } #endregion }
public Order Charge(Order order) { try { CookieContainer cookie = new CookieContainer(); decimal totalAmount = (decimal)order.BuyAmount; decimal totalAmountNum = totalAmount; int isContinue = 0; if (CheckStrHelper.IsChinese(order.TargetAccount)) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = "用户名不合法"; return(order); } order.TargetAccount = CheckChargeAccount(order.TargetAccount); string radPayType = "1"; if (order.RechargeModeName.Contains("帐号直充") || order.RechargeModeName.Contains("通用点") || order.RechargeModeName.Contains("游戏点数") || order.RechargeModeName.Contains("帐号充值")) { radPayType = "1"; } else if (order.RechargeModeName.Contains("寄售点") || order.RechargeModeName.Contains("点数寄售") || order.RechargeModeName.Contains("点卡交易/寄售")) { radPayType = "2"; } while (totalAmount > 0) { #region 提交充值 int chargeNum = 0; int vibiNum = 0; if (isContinue > 3) //充值频繁,重试三次 { break; } if (!GetChargeNum((int)totalAmount, ref chargeNum)) { break; } totalAmount = totalAmount - chargeNum; vibiNum = chargeNum * 2; string result = ""; #region 获取参数 帐号判断 result = PostAndGet.HttpGetString("http://www.vpay8.com/Fetch/wy/wpay.aspx", "", ref cookie); string __VIEWSTATE = Regex.Match(result, @"id=""__VIEWSTATE""\s+value=""(.*?)"" />").Groups[1].Value; string __EVENTVALIDATION = Regex.Match(result, @"id=""__EVENTVALIDATION""\s+value=""(.*?)"" />").Groups[1].Value; StringBuilder checkgetDataBuilder = new StringBuilder(); checkgetDataBuilder.AppendFormat("__VIEWSTATE={0}", System.Web.HttpUtility.UrlEncode(__VIEWSTATE)); checkgetDataBuilder.AppendFormat("&__EVENTVALIDATION={0}", System.Web.HttpUtility.UrlEncode(__EVENTVALIDATION)); checkgetDataBuilder.AppendFormat("&DropDownList1={0}", chargeNum * 10); checkgetDataBuilder.AppendFormat("&radPayType={0}", radPayType); checkgetDataBuilder.AppendFormat("&qqnum={0}", order.TargetAccount); checkgetDataBuilder.AppendFormat("&qqnum2={0}", order.TargetAccount); checkgetDataBuilder.AppendFormat("&Button2={0}", "%E6%8F%90%E4%BA%A4%E8%AE%A2%E5%8D%95"); result = PostAndGet.HttpPostString("http://www.vpay8.com/Fetch/wy/wpay.aspx", checkgetDataBuilder.ToString(), ref cookie, "http://www.vpay8.com/Fetch/wy/wpay.aspx"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "提交参数:" + checkgetDataBuilder.ToString() + ",订单第一步提交返回:" + result, LogPathFile.Recharge); if (result.Contains("请输入正确的网易通行证账号")) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = "帐号不存在"; return(order); } //string href = Regex.Match(result, @"<a href=""(.*?)"">").Groups[1].Value; ////http://www.vpay8.com/Fetch/wy/WSubmit.aspx?orderid=WY170313223559213118&pv=1&v=30&[email protected]&s=1788a04956cd27cc45de0d83f9ef010c //result = PostAndGet.HttpGetString(System.Web.HttpUtility.UrlDecode(href, Encoding.Default), checkgetDataBuilder.ToString(), ref cookie); //WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount // + ",订单第二步提交返回:" + result, LogPathFile.Recharge); #endregion #region Vbi钱包充值 string spid = Regex.Match(result, @"<input name='spid'\s+type=""hidden""\s+value='(.*?)' >").Groups[1].Value; string spname = Regex.Match(result, @"<input name='spname'\s+type=""hidden""\s+value='(.*?)'> ").Groups[1].Value; string spoid = Regex.Match(result, @"<input name='spoid'\s+type=""hidden""\s+value='(.*?)' >").Groups[1].Value; string spreq = Regex.Match(result, @"<input name='spreq'\s+type=""hidden""\s+value='(.*?)' >").Groups[1].Value; string sprec = Regex.Match(result, @"<input name='sprec'\s+type=""hidden""\s+value='(.*?)' >").Groups[1].Value; string userid = Regex.Match(result, @"<input name='userid'\s+type=""hidden""\s+value='(.*?)' >").Groups[1].Value; string userip = Regex.Match(result, @"<input name='userip'\s+type=""hidden""\s+value='(.*?)' >").Groups[1].Value; string spmd5 = Regex.Match(result, @"<input name='spmd5'\s+type=""hidden""\s+value='(.*?)' >").Groups[1].Value; string spcustom = Regex.Match(result, @"<input name='spcustom'\s+type=""hidden""\s+value='(.*?)' >").Groups[1].Value; string spversion = Regex.Match(result, @"<input name='spversion'\s+type=""hidden""\s+value='(.*?)' >").Groups[1].Value; string urlcode = Regex.Match(result, @"<input name='urlcode'\s+type=hidden\s+value='(.*?)' >").Groups[1].Value; string spzf = Regex.Match(result, @"<input name='spzf'\s+type=""hidden""\s+value='(.*?)' >").Groups[1].Value; string money = Regex.Match(result, @"<input name='money'\s+type=""hidden""\s+value='(.*?)' >").Groups[1].Value; StringBuilder vnetonePostdataBuilder = new StringBuilder(); vnetonePostdataBuilder.AppendFormat("spid={0}", spid); vnetonePostdataBuilder.AppendFormat("&spname={0}", System.Web.HttpUtility.UrlEncode(spname, Encoding.UTF8)); vnetonePostdataBuilder.AppendFormat("&spoid={0}", spoid); vnetonePostdataBuilder.AppendFormat("&spreq={0}", System.Web.HttpUtility.UrlEncode(spreq, Encoding.UTF8)); vnetonePostdataBuilder.AppendFormat("&sprec={0}", System.Web.HttpUtility.UrlEncode(sprec, Encoding.UTF8)); vnetonePostdataBuilder.AppendFormat("&userid={0}", System.Web.HttpUtility.UrlEncode(userid, Encoding.UTF8)); vnetonePostdataBuilder.AppendFormat("&userip={0}", userip); vnetonePostdataBuilder.AppendFormat("&spmd5={0}", spmd5); vnetonePostdataBuilder.AppendFormat("&spcustom={0}", System.Web.HttpUtility.UrlEncode(spcustom, Encoding.UTF8)); vnetonePostdataBuilder.AppendFormat("&spversion={0}", spversion); vnetonePostdataBuilder.AppendFormat("&urlcode={0}", urlcode); vnetonePostdataBuilder.AppendFormat("&spzf={0}", spzf); vnetonePostdataBuilder.AppendFormat("&money={0}", money); OrderChargeAccount orderChargeAccount = SQLOrderChargeAccount.GetChargeAccount(OrderChargeAccountType.Vbi); if (orderChargeAccount == null) { order.RechargeMsg += "未取到v币帐号||"; isContinue++; continue; } result = VbiChargeHelper.VbiCharge(vnetonePostdataBuilder.ToString(), order, orderChargeAccount, cookie, vibiNum); #endregion #region 充值结果判断 if (result.Contains("成功") || result.Contains("您已成功充值") || result.Contains("成功充值")) { order.RechargeMsg += spoid + "充值成功||"; order.SuccessfulAmount += chargeNum; orderChargeAccount.Balance = orderChargeAccount.Balance - chargeNum; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); } else if (result.Contains("请五分钟后再登陆商户网站进行帐户查询")) { order.RechargeMsg += spoid + "充值成功(请五分钟后再登陆商户网站进行帐户查询)||"; order.SuccessfulAmount += chargeNum; orderChargeAccount.Balance = orderChargeAccount.Balance - chargeNum; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); } else if (result.Contains("操作失败")) { order.RechargeMsg += spoid + "操作失败||"; totalAmount += chargeNum; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); isContinue++; } else if (result.Contains("充值过于频繁")) { order.RechargeMsg += "充值频繁||"; totalAmount += chargeNum; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); isContinue++; } else if (result.Contains("验证码输入不正确")) { order.RechargeMsg += spoid + "验证码输入不正确||"; totalAmount += chargeNum; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); isContinue++; } else if (result.Contains("账户余额不足")) { order.RechargeMsg += "账户余额不足||"; totalAmount += chargeNum;; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false, false); isContinue++; } else if (result.Contains("支付密码不正确")) { order.RechargeMsg += spoid + "支付密码不正确||"; totalAmount += chargeNum;; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false, false); isContinue++; } else if (result.Contains("用户不存在")) { order.RechargeMsg += spoid + "用户不存在||"; totalAmount += chargeNum;; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false, false); isContinue++; } else if (result.Contains("操作_Failure")) { order.RechargeMsg += spoid + "帐号错误||"; totalAmount += chargeNum;; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); isContinue++; } else { order.RechargeMsg += spoid + "存疑||"; SQLOrderChargeAccount.UpdateChargeAccount(orderChargeAccount, false); isContinue++; } #endregion #endregion } #region 订单状态判断 if (order.SuccessfulAmount >= totalAmountNum) { order.RechargeStatus = (int)OrderRechargeStatus.successful; } else if (order.SuccessfulAmount <= 0) { if (order.RechargeMsg.Contains("帐号错误") || order.RechargeMsg.Contains("用户不存在")) { order.RechargeStatus = (int)OrderRechargeStatus.failure; } else { order.RechargeStatus = (int)OrderRechargeStatus.suspicious; } } else { order.RechargeStatus = (int)OrderRechargeStatus.suspicious; } #endregion return(order); } catch (Exception ex) { order.RechargeStatus = (int)OrderRechargeStatus.suspicious; WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",充值异常信息:" + ex.Message, LogPathFile.Exception); return(order); } }
bool ReCharge(Order order, int payNum, CookieContainer cookie, ref string CardNumber, ref string status, ref string msg) { #region 参数提交 //nickname=可是地方和高科技&channelid=6&channelname=纵游一卡通&money=50&yeepay_type=ZY&v=1496835901593 StringBuilder checkStr = new StringBuilder(); checkStr.AppendFormat("nickname={0}", order.TargetAccount); checkStr.AppendFormat("&channelid={0}", "6"); checkStr.AppendFormat("&channelname={0}", "纵游一卡通"); checkStr.AppendFormat("&money={0}", (int)payNum); checkStr.AppendFormat("&yeepay_type={0}", "ZY"); checkStr.AppendFormat("&v={0}", "1496835901593"); string result = PostAndGet.HttpPostString_HY("http://pay.hanyou.com/pay.do", checkStr.ToString(), ref cookie, "pay.hanyou.com", "http://pay.hanyou.com/"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",帐号检测提交返回:" + result, LogPathFile.Recharge); //{"msg":"该昵称不存在","code":1,"nickName":"可是地方和高科技"} if (result.Contains("该昵称不存在")) { status = "失败"; msg = "用户不存在||"; return(false); } if (!result.Contains("确认充值")) { status = "失败"; msg = "确认提交订单失败||"; return(true); } string channelid = Regex.Match(result, @"name=""channelid"" value=""(.*?)"" />").Groups[1].Value; string userid = Regex.Match(result, @"name=""userid"" value=""(.*?)"" />").Groups[1].Value; string nickname = Regex.Match(result, @"name=""nickname"" value=""(.*?)"" />").Groups[1].Value; string unionid = Regex.Match(result, @"name=""unionid"" value=""(.*?)"" />").Groups[1].Value; string money = Regex.Match(result, @"name=""money"" value=""(.*?)"" />").Groups[1].Value; string yeepay_type = Regex.Match(result, @"name=""yeepay_type"" value=""(.*?)"" />").Groups[1].Value; StringBuilder placeorderStr = new StringBuilder(); placeorderStr.AppendFormat("channelid={0}", channelid); placeorderStr.AppendFormat("&userid={0}", userid); placeorderStr.AppendFormat("&nickname={0}", nickname); placeorderStr.AppendFormat("&unionid={0}", unionid); placeorderStr.AppendFormat("&money={0}", money); placeorderStr.AppendFormat("&yeepay_type={0}", yeepay_type); result = PostAndGet.HttpPostString_HY("http://pay.hanyou.com/order/placeorder.do", placeorderStr.ToString(), ref cookie, "pay.hanyou.com", "http://pay.hanyou.com/"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",订单第一步提交返回:" + result, LogPathFile.Recharge); #endregion #region 纵游卡提交 Cards cards = SQLCards.GetChargeCards(OrderChargeAccountType.ZYCard, (decimal)order.ProductParValue); if (cards == null) { status = "失败"; msg = "取卡失败||"; return(true); } CardNumber = cards.CardNumber; string bizType = Regex.Match(result, @"name=\\""bizType\\"" value=\\""(.*?)\\""\/>").Groups[1].Value; string merchantNo = Regex.Match(result, @"name=\\""merchantNo\\"" value=\\""(.*?)\\""\/>").Groups[1].Value; string merchantOrderNo = Regex.Match(result, @"name=\\""merchantOrderNo\\"" value=\\""(.*?)\\""\/>").Groups[1].Value; string requestAmount = Regex.Match(result, @"name=\\""requestAmount\\"" value=\\""(.*?)\\""\/>").Groups[1].Value; string url = Regex.Match(result, @"name=\\""url\\"" value=\\""(.*?)\\""\/>").Groups[1].Value; string cardCode = Regex.Match(result, @"name=\\""cardCode\\"" value=\\""(.*?)\\""\/>").Groups[1].Value; string productName = Regex.Match(result, @"name=\\""productName\\"" value=\\""(.*?)\\""\/>").Groups[1].Value; string hmac = Regex.Match(result, @"name=\\""hmac\\"" value=\\""(.*?)\\""\/>").Groups[1].Value; string yeeykUrl = "http://www.yeeyk.com/yeex-xcard-app/createOrder"; StringBuilder yeeykStr = new StringBuilder(); yeeykStr.AppendFormat("bizType={0}", bizType); yeeykStr.AppendFormat("&merchantNo={0}", merchantNo); yeeykStr.AppendFormat("&merchantOrderNo={0}", merchantOrderNo); yeeykStr.AppendFormat("&requestAmount={0}", requestAmount); yeeykStr.AppendFormat("&url={0}", System.Web.HttpUtility.UrlEncode(url, Encoding.Default)); yeeykStr.AppendFormat("&cardCode={0}", cardCode); yeeykStr.AppendFormat("&productName={0}", System.Web.HttpUtility.UrlEncode(productName, Encoding.UTF8)); yeeykStr.AppendFormat("&hmac={0}", hmac); result = PostAndGet.HttpPostString(yeeykUrl, yeeykStr.ToString(), ref cookie, "http://pay.hanyou.com/"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",纵游卡收卡台提交返回:" + result, LogPathFile.Recharge); result = PostAndGet.HttpPostString("http://www.yeeyk.com/yeex-xcard-app/card/cardRule?cardType=ZY", "", ref cookie, "http://www.yeeyk.com/yeex-xcard-app/createOrder"); string acquiringURL = "http://www.yeeyk.com/yeex-xcard-app/acquiring"; //?amount=1&cardNo=703015036002529&cardType=ZY&customerNumber=10011829538&password=339745869503044&payAmount=50.00&requestId=yeeyk_201706071950562364486631 StringBuilder acquiringStr = new StringBuilder(); acquiringStr.AppendFormat("amount={0}", "1"); acquiringStr.AppendFormat("&cardNo={0}", cards.CardNumber); acquiringStr.AppendFormat("&cardType={0}", "ZY"); acquiringStr.AppendFormat("&customerNumber={0}", merchantNo); acquiringStr.AppendFormat("&password={0}", cards.CardPassWord); acquiringStr.AppendFormat("&payAmount={0}", payNum.ToString() + ".00"); acquiringStr.AppendFormat("&requestId={0}", merchantOrderNo); result = PostAndGet.HttpPostString(acquiringURL + "?" + acquiringStr.ToString(), "", ref cookie, "http://www.yeeyk.com/yeex-xcard-app/createOrder"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",纵游卡提交返回:" + result, LogPathFile.Recharge); if (!result.Contains("收单成功")) { status = "失败"; msg = "纵游卡提交失败||"; return(true); } #endregion System.Threading.Thread.Sleep(5 * 1000); string orderno = merchantOrderNo.Substring(merchantOrderNo.IndexOf('_') + 1); #region 查询卡密结果 string queryResultURL = "http://www.yeeyk.com/yeex-xcard-app/queryResult?" + "customerNumber=" + merchantNo + "&requestId=" + merchantOrderNo; //?customerNumber=10011829538&requestId=yeeyk_201706071950562364486631 //http://www.yeeyk.com/yeex-xcard-app/queryResult?customerNumber=10011829538&requestId=yeeyk_201706122324593034531264 result = PostAndGet.HttpPostString(queryResultURL, "", ref cookie, "http://www.yeeyk.com/yeex-xcard-app/createOrder"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",纵游卡提交结果查询返回:" + result, LogPathFile.Recharge); string code = Regex.Match(result, @"""code"" : ""(.*?)""").Groups[1].Value; string confirmResultURL = "http://www.yeeyk.com/yeex-xcard-app/confirmResult?orderKey=" + code; result = PostAndGet.HttpGetString_9Y(confirmResultURL, "", ref cookie, "www.yeeyk.com", "http://www.yeeyk.com/yeex-xcard-app/createOrder"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",纵游卡提交结果查询最终返回:" + result, LogPathFile.Recharge); if (result.Contains("充值成功") || result.Contains("订单支付成功")) { status = "成功"; msg = orderno + "充值成功||"; cards.ReChargeStatus = (int)OrderRechargeStatus.successful; cards.ReChargeMsg += msg; SQLCards.UpdateCards_ByMultiple(cards); return(true); } else if (result.Contains("订单支付失败")) { status = "失败"; msg = orderno + "订单支付失败||"; cards.ReChargeStatus = (int)OrderRechargeStatus.untreated; cards.ReChargeMsg += msg; SQLCards.UpdateCards_ByMultiple(cards); return(true); } else { status = "成功"; msg = orderno + "订单提交成功查询结果失败||"; cards.ReChargeStatus = (int)OrderRechargeStatus.successful; cards.ReChargeMsg += msg; SQLCards.UpdateCards_ByMultiple(cards); return(true); } #endregion }
public Order Charge(Order order) { try { int totalPrice = (int)order.BuyAmount; int totalPriceFixed = totalPrice; int isContinue = 0; if (CheckStrHelper.IsChinese(order.TargetAccount)) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = "用户名不合法(4-32位数字字母和_组合)"; return(order); } //用户名不合法(4-32位数字字母和_组合) if (order.TargetAccount.Length < 4 || order.TargetAccount.Length > 32) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = "用户名不合法(4-32位数字字母和_组合)"; return(order); } if (order.BuyAmount % 10 != 0) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = "充值数量不正确"; return(order); } CookieContainer cookie = new CookieContainer(); string checkAccount = PostAndGet.HttpGetString("http://pay.web.7k7k.com/checkuser/?username="******"", ref cookie, "http://pay.web.7k7k.com/?qq-pf-to=pcqq.c2c"); WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",帐号检测提交返回:" + checkAccount, LogPathFile.Recharge); string status = Regex.Match(checkAccount, @"""status"":""(.*?)""").Groups[1].Value; if (status.Equals("-1")) { order.RechargeStatus = (int)OrderRechargeStatus.failure; order.RechargeMsg = "帐号错误"; return(order); } string uid = Regex.Match(checkAccount, @"""uid"":(.*?)}").Groups[1].Value; while (totalPrice > 0) { if (isContinue >= 3) { break; //重试三次 } //totalPrice--; string result = "存疑"; string msg = ""; string CardNumber = string.Empty; int payNum = 0; if (!GetPayNum(totalPrice, ref payNum)) { isContinue++; continue; } else { totalPrice = totalPrice - payNum; } if (!string.IsNullOrEmpty(order.RechargeMsg) || !string.IsNullOrEmpty(CardNumber)) { System.Threading.Thread.Sleep(10 * 1000); } bool bo = ReCharge(order, payNum, uid, cookie, ref CardNumber, ref result, ref msg); order.RechargeMsg += msg; if (!string.IsNullOrEmpty(CardNumber)) { order.ChargeAccountInfo += CardNumber + "||"; } if (result.Contains("成功")) { order.SuccessfulAmount += payNum; } else if (result.Contains("失败")) { if (bo) { //重复提交 cookie = new CookieContainer(); totalPrice += payNum; isContinue++; } else { break; //订单失败直接返回 } } else { break; } } #region 订单状态判断 if (order.SuccessfulAmount >= totalPriceFixed) { order.RechargeStatus = (int)OrderRechargeStatus.successful; } else if (order.SuccessfulAmount == 0 && order.RechargeMsg.Contains("充值已达每日上限")) { order.RechargeStatus = (int)OrderRechargeStatus.failure; } else { order.RechargeStatus = (int)OrderRechargeStatus.suspicious; } #endregion return(order); } catch (Exception ex) { order.RechargeStatus = (int)OrderRechargeStatus.suspicious; WriteLog.Write("订单号:" + order.OrderInsideID + ",代充商品:" + order.ProductName + "代充帐号:" + order.TargetAccount + ",充值异常信息:" + ex.Message, LogPathFile.Exception); return(order); } }
public void getmoyuAreaAndServer(string gamename, string areaname, string servername, ref string areaid, ref string serverid) { try { string url = "https://xmlserver.99.com/my/mycharge.xml?0.8311741468522764"; switch (gamename) { case "魔域": url = "https://xmlserver.99.com/my/mycharge.xml?0.8311741468522764"; break; case "魔域掉钱版": url = "https://xmlserver.99.com/my/Chsjmy.xml?0.5738079243209351"; break; case "魔域口袋版": url = "https://xmlserver.99.com/my/mysjcharge.xml?0.3160789587639954"; break; case "机战": url = "https://xmlserver.99.com//jz/jzcharge.xml?0.8663311481081863"; break; case "征服": url = "https://xmlserver.99.com/zf/zfcharge.xml?0.9778757448608422"; break; default: url = "https://xmlserver.99.com/my/mycharge.xml?0.8311741468522764"; break; } Dictionary <string, string> dicArea = new Dictionary <string, string>(); Dictionary <string, List <Dictionary <string, string> > > dicServer = new Dictionary <string, List <Dictionary <string, string> > >(); CookieContainer coockie = new CookieContainer(); string result = PostAndGet.HttpGetString(url, "", ref coockie); XmlDocument docArea = new XmlDocument(); docArea.LoadXml(result); //加载Xml文件 XmlElement rootArea = docArea.DocumentElement; //获取根节点 XmlNodeList AreaNodes = rootArea.GetElementsByTagName("MainTable"); //获取area foreach (XmlNode node in AreaNodes) { //string Code = ((XmlElement)node).GetAttribute("Code"); //获取Code属性值 string key = ((XmlElement)node).GetElementsByTagName("key")[0].InnerText; string name = ((XmlElement)node).GetElementsByTagName("name")[0].InnerText; dicArea.Add(key, name); } XmlDocument docServer = new XmlDocument(); docServer.LoadXml(result); //加载Xml文件 XmlElement rootServer = docServer.DocumentElement; //获取根节点 XmlNodeList ServerNodes = rootServer.GetElementsByTagName("SubTable"); //获取sever foreach (XmlNode node in ServerNodes) { string key = ((XmlElement)node).GetElementsByTagName("key")[0].InnerText; string name = ((XmlElement)node).GetElementsByTagName("name")[0].InnerText; string ParentKey = ((XmlElement)node).GetElementsByTagName("ParentKey")[0].InnerText; Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add(key, name); bool isNew = true; foreach (string serverkey in dicServer.Keys) { if (ParentKey == serverkey) { dicServer[serverkey].Add(dic); isNew = false; break; } } if (isNew) { List <Dictionary <string, string> > lst = new List <Dictionary <string, string> >(); lst.Add(dic); dicServer.Add(ParentKey, lst); } } if (!string.IsNullOrEmpty(areaname)) { foreach (string item in dicArea.Keys) { if (dicArea[item] == areaname) { areaid = item; break; } } } if (!string.IsNullOrEmpty(areaname) && !string.IsNullOrEmpty(servername)) { foreach (string key in dicArea.Keys) { if (dicArea[key] == areaname) { foreach (string parentKey in dicServer.Keys) { if (parentKey == key) { foreach (Dictionary <string, string> dic in dicServer[parentKey]) { foreach (string serverkey in dic.Keys) { if (servername == dic[serverkey]) { serverid = serverkey; break; } } } } } } } } } catch (Exception ex) { WriteLog.Write("方法:getmoyuAreaAndServer,异常:" + ex.Message, LogPathFile.Exception.ToString()); throw; } }