public void Test() { try { List <WXMessageLog_EX> mlist = mss.GetOrderNoPayed(); foreach (var m in mlist) { if (!string.IsNullOrEmpty(m.FromUserName)) { mss.SaveWXMessageLog(new ORG_WXMessage_Log { CreateTime = DateTime.Now, EventID = m.ID, EventType = 1 }); string token = Token(mjuserid); var temp = new { first = new { value = "未支付提醒通知", color = "#173177" }, type = new { value = "项目", color = "#173177" }, e_title = new { value = "小时光SPA预约", color = "#173177" }, o_id = new { value = m.ORDER_NO, color = "#173177" }, order_date = new { value = m.CREATE_DATE.ToString("yyyy.MM.dd HH:mm"), color = "#173177" }, o_money = new { value = m.PAY_AMT, color = "#173177" }, remark = new { value = "\n" + "Hi,您预约的小时光SPA还未支付,超过10分钟订单自动取消哦~", color = "#CD0000" } }; string message = SendTemplateMessage(token, m.FromUserName, "Or5LLJHk2GFu_9uLkeEKmCgvFU8p1BlokArSeAe6jaQ", "#FF0000", temp, WebUrl + "/wechat/spa/dingdan.aspx"); } } List <WXMessageLog_EX> llist = mss.GetOrderClosed(); foreach (var m in llist) { if (!string.IsNullOrEmpty(m.FromUserName)) { mss.SaveWXMessageLog(new ORG_WXMessage_Log { CreateTime = DateTime.Now, EventID = m.ID, EventType = 3 }); string token = Token(mjuserid); var temp = new { first = new { value = "您好,您有一笔交易已关闭。", color = "#173177" }, keyword1 = new { value = m.ORDER_NO, color = "#173177" }, keyword2 = new { value = m.CREATE_DATE.ToString("yyyy.MM.dd HH:mm"), color = "#173177" }, keyword3 = new { value = "订单支付超时", color = "#173177" }, keyword4 = new { value = m.OverdueDate.ToString("yyyy.MM.dd HH:mm"), color = "#173177" }, remark = new { value = "\n" + "感谢您的选择,请及时查看确认。如有疑问,请咨询客服:176-2116-0808", color = "#CD0000" } }; string message = SendTemplateMessage(token, m.FromUserName, "vxtsFe76nhOMAEXz_8GvgxsQbpAxBsR5iD0_uRXBuww", "#FF0000", temp, WebUrl + "/wechat/spa/dingdan.aspx"); } } } catch (Exception ex) { mss.SaveLog(new WXLOG { CON = ex.Message + "," + ex.StackTrace, TIME = DateTime.Now }); } }
protected void Page_Load(object sender, EventArgs e) { //Session["FromUserName"] = "******"; //Session["ToUserName"] = "******"; //oQaIMwG_9lanE3f5VtvOSrErmfic if (!IsPostBack) { Base(); if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null)) { string user = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString(); string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString(); Session["FromUserName"] = user; Session["ToUserName"] = user2; try { Bind(user); } catch (Exception ex) { WXLOG log = new WXLOG(); log.CON = ex.Message.ToString() + "Order"; log.TIME = DateTime.Now; mss.SaveLog(log); } } } }
protected void Page_Load(object sender, EventArgs e) { //Session["FromUserName"] = "******"; //Session["ToUserName"] = "******"; if (!IsPostBack) { Base(); if (Request.QueryString["s"] == null) { if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null)) { string user = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString(); string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString(); Session["FromUserName"] = user; Session["ToUserName"] = user2; try { Bind(user); } catch (Exception ex) { WXLOG log = new WXLOG(); log.CON = ex.Message.ToString() + "Member"; log.TIME = DateTime.Now; mss.SaveLog(log); } } else { Response.Redirect(AuthCode(Request.Url.AbsoluteUri)); } } else if (Request.QueryString["s"] != null) { string html = "<option value='0'>请选择城市</option>"; List <City> list = mss.GetCityByReg(Request.QueryString["s"]); foreach (City c in list) { html += "<option value='" + c.CityCode + "'>" + c.CityName + "</option>"; } Response.Write(html); Response.End(); } } }
const string Token = "puman"; //与微信平台那边填写的token一致 protected void Page_Load(object sender, EventArgs e) { string postStr = ""; if (Request.HttpMethod.ToLower() == "post") { Stream s = System.Web.HttpContext.Current.Request.InputStream; byte[] b = new byte[s.Length]; s.Read(b, 0, (int)s.Length); postStr = Encoding.UTF8.GetString(b); WXLOG log = new WXLOG { CON = postStr + "INDEX2", TIME = DateTime.Now }; mss.SaveLog(log); } else { } }
/// <summary> /// 微信支付 /// </summary> /// <param name="order"></param> private void WX(Pet_XXL_Order order) { string appid = GetAppid(mjuserid); //公众号,固定 string mch_id = "1261198501"; //商户号,固定 string nonce_str = Guid.NewGuid().ToString("d").Replace("-", "").Substring(0, 25); //随机码 string body = order.GoodsName; //商品描述 string notify_url = WebUrl + "/wechat/order/Notify.aspx"; string openid = order.FromUserName; //微信编号 string out_trade_no = order.OrderNo; //商户订单编号 string spbill_create_ip = GetLoginIp(); //ip地址 string total_fee = Convert.ToInt32(order.TotalPrice * 100).ToString(); //总价,分 string trade_type = "JSAPI"; //交易类型 string key = "7M8Doa2lesq70RbvjhhpZGjeqcuJDReZ"; //商户key string attach = order.OrderNo; //附加数据 string[] ArrTmp = { "appid=" + appid, "mch_id=" + mch_id, "nonce_str=" + nonce_str, "body=" + body, "notify_url=" + notify_url, "openid=" + openid, "out_trade_no=" + out_trade_no, "spbill_create_ip=" + spbill_create_ip, "total_fee=" + total_fee, "trade_type=" + trade_type, "attach=" + attach }; Array.Sort(ArrTmp); //字典排序 string tmpStr = string.Join("&", ArrTmp); tmpStr += "&key=" + key; string sign = getMD5(tmpStr).ToUpper(); string resxml = string.Format(@"<xml><appid>{0}</appid><mch_id>{1}</mch_id><nonce_str>{2}</nonce_str><attach>{3}</attach> <body>{4}</body> <notify_url>{5}</notify_url> <openid>{6}</openid> <out_trade_no>{7}</out_trade_no> <spbill_create_ip>{8}</spbill_create_ip> <total_fee>{9}</total_fee> <trade_type>{10}</trade_type> <sign>{11}</sign> </xml>", appid, mch_id, nonce_str, attach, body, notify_url, openid, out_trade_no, spbill_create_ip, total_fee, trade_type, sign); string url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; string jg = HttpXmlPostRequest(url, resxml, Encoding.UTF8); WXLOG log = new WXLOG { CON = resxml + "," + tmpStr + "," + jg + "zhifu", TIME = DateTime.Now }; mss.SaveLog(log); XmlDocument doc = new XmlDocument(); doc.LoadXml(jg); XmlElement rootElement = doc.DocumentElement; string prepay_id = rootElement.SelectSingleNode("prepay_id") == null ? "" : rootElement.SelectSingleNode("prepay_id").InnerXml.Replace("<![CDATA[", "").Replace("]]>", ""); if (prepay_id != "") { string timeStamp = ConvertDateTimeInt(DateTime.Now).ToString(); string package = "prepay_id=" + prepay_id; string signType = "MD5"; string[] ArrTmp2 = { "appId=" + appid, "nonceStr=" + nonce_str, "timeStamp=" + timeStamp, "package=" + package, "signType=" + signType }; Array.Sort(ArrTmp2); //字典排序 string tmpStr2 = string.Join("&", ArrTmp2); tmpStr2 += "&key=" + key; string sign2 = getMD5(tmpStr2).ToUpper(); WXLOG log2 = new WXLOG { CON = resxml + "," + tmpStr + "," + tmpStr2 + "," + jg + "INDEX", TIME = DateTime.Now }; mss.SaveLog(log2); Response.Write("{\"appId\":\"" + appid + "\",\"nonceStr\":\"" + nonce_str + "\",\"timeStamp\":\"" + timeStamp + "\",\"package\":\"" + package + "\",\"signType\":\"" + signType + "\",\"paySign\":\"" + sign2 + "\",\"st\":0}"); Response.End(); } else { Response.Write("{\"err_code\":\"" + rootElement.SelectSingleNode("err_code_des").InnerXml.Replace("<![CDATA[", "").Replace("]]>", "") + "\",\"st\":1}"); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.Params["para"] == null) { Response.Write(" <input type='hidden'' value='" + Server.UrlEncode(AbsoluteUri) + "' id='url' />"); } } if (Request.QueryString["para"] != null) { try { string appid = GetAppid(mjuserid); //公众号,固定 string mch_id = "1238277202"; //商户号,固定 string nonce_str = Guid.NewGuid().ToString("d").Replace("-", "").Substring(0, 25); //随机码 string body = "手工半湿粮"; //商品描述 string notify_url = "http://cw.meijiewd.com/wechat/test/index2.aspx"; string openid = "o0UMCj6Y9wcOeRVu0hJ0yx2MxCZY"; //微信编号 string out_trade_no = "1415659991"; //商户订单编号 string spbill_create_ip = GetLoginIp(); //ip地址 string total_fee = "1"; //总价,分 string trade_type = "JSAPI"; //交易类型 string key = "7M8Doa2lesq70RbvjhhpZGjeqcuJDReZ"; //商户key string attach = "支付测试"; //附加数据 string[] ArrTmp = { "appid=" + appid, "mch_id=" + mch_id, "nonce_str=" + nonce_str, "body=" + body, "notify_url=" + notify_url, "openid=" + openid, "out_trade_no=" + out_trade_no, "spbill_create_ip=" + spbill_create_ip, "total_fee=" + total_fee, "trade_type=" + trade_type, "attach=" + attach }; Array.Sort(ArrTmp); //字典排序 string tmpStr = string.Join("&", ArrTmp); tmpStr += "&key=" + key; string sign = getMD5(tmpStr).ToUpper(); string resxml = string.Format(@"<xml><appid>{0}</appid><mch_id>{1}</mch_id><nonce_str>{2}</nonce_str><attach>{3}</attach> <body>{4}</body> <notify_url>{5}</notify_url> <openid>{6}</openid> <out_trade_no>{7}</out_trade_no> <spbill_create_ip>{8}</spbill_create_ip> <total_fee>{9}</total_fee> <trade_type>{10}</trade_type> <sign>{11}</sign> </xml>", appid, mch_id, nonce_str, attach, body, notify_url, openid, out_trade_no, spbill_create_ip, total_fee, trade_type, sign); string url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; string jg = HttpXmlPostRequest(url, resxml, Encoding.UTF8); WXLOG log = new WXLOG { CON = resxml + "," + tmpStr + "," + jg + "INDEX", TIME = DateTime.Now }; mss.SaveLog(log); XmlDocument doc = new XmlDocument(); doc.LoadXml(jg); XmlElement rootElement = doc.DocumentElement; string prepay_id = rootElement.SelectSingleNode("prepay_id") == null ? "" : rootElement.SelectSingleNode("prepay_id").InnerXml.Replace("<![CDATA[", "").Replace("]]>", ""); if (prepay_id != "") { string timeStamp = ConvertDateTimeInt(DateTime.Now).ToString(); string package = "prepay_id=" + prepay_id; string signType = "MD5"; string[] ArrTmp2 = { "appId=" + appid, "nonceStr=" + nonce_str, "timeStamp=" + timeStamp, "package=" + package, "signType=" + signType }; Array.Sort(ArrTmp2); //字典排序 string tmpStr2 = string.Join("&", ArrTmp2); tmpStr2 += "&key=" + key; string sign2 = getMD5(tmpStr2).ToUpper(); WXLOG log2 = new WXLOG { CON = resxml + "," + tmpStr + "," + tmpStr2 + "," + jg + "INDEX", TIME = DateTime.Now }; mss.SaveLog(log2); Response.Write("{\"appId\":\"" + appid + "\",\"nonceStr\":\"" + nonce_str + "\",\"timeStamp\":\"" + timeStamp + "\",\"package\":\"" + package + "\",\"signType\":\"" + signType + "\",\"paySign\":\"" + sign2 + "\",\"st\":0}"); Response.End(); } else { Response.Write("{\"err_code\":\"" + rootElement.SelectSingleNode("err_code_des").InnerXml.Replace("<![CDATA[", "").Replace("]]>", "") + "\",\"st\":1}"); Response.End(); } } catch (Exception ex) { WXLOG log = new WXLOG { CON = ex.Message + "," + ex.StackTrace, TIME = DateTime.Now }; mss.SaveLog(log); } } }
const string Token = "puman"; //与微信平台那边填写的token一致 protected void Page_Load(object sender, EventArgs e) { string postStr = ""; //WXLOG log2 = new WXLOG { CON = postStr + "weixin", TIME = DateTime.Now }; //mss.SaveLog(log2); if (Request.HttpMethod.ToLower() == "post") { Stream s = System.Web.HttpContext.Current.Request.InputStream; byte[] b = new byte[s.Length]; s.Read(b, 0, (int)s.Length); postStr = Encoding.UTF8.GetString(b); if (!string.IsNullOrEmpty(postStr)) { //封装请求类 XmlDocument doc = new XmlDocument(); doc.LoadXml(postStr); XmlElement rootElement = doc.DocumentElement; string result_code = rootElement.SelectSingleNode("result_code").InnerXml.Replace("<![CDATA[", "").Replace("]]>", ""); if (result_code == "SUCCESS") { string orderno = rootElement.SelectSingleNode("out_trade_no").InnerXml.Replace("<![CDATA[", "").Replace("]]>", ""); string bank_type = rootElement.SelectSingleNode("bank_type").InnerXml.Replace("<![CDATA[", "").Replace("]]>", ""); string transaction_id = rootElement.SelectSingleNode("transaction_id").InnerXml.Replace("<![CDATA[", "").Replace("]]>", ""); Pet_XXL_Order order = nvbo.GetPetXXLOrder(orderno); if (order != null && order.OrderState != 2) { //Pet_XXL_Address add = nvbo.GetAddress(order.AID.Value); //if (add != null) //{ // new SendDX().Send2("我们已收到您的付款,感谢您的支持,半湿粮将会在24小时后统一配送。", add.Phone); //} order.OrderState = 2; order.BankType = bank_type; order.OutOrderNo = transaction_id; nvbo.SavePetXXLOrder(order); //if (order.yhqid != null && order.yhqid != 0) //{ //} try { OAauth_Log o = mss.GetOA(order.FromUserName); if (o != null) { Pet_JiuZhu_Info j = nvbo.GetJiuZhuInfo(order.Source.Value); if (j != null && (j.JZType == 1 || j.JZType == 2)) { Pet_JiuZhu_Love l = new Pet_JiuZhu_Love { CreateTime = DateTime.Now, Detail = "捐助基地[" + j.NickName + "][" + (j.JZType == 1 ? "捐粮" : "捐款") + "]", FromUserName = order.FromUserName, OID = order.ID, Love = j.JZType == 1 ? Convert.ToInt32(order.TotalPrice) : Convert.ToInt32(order.TotalPrice / 2) }; int lid = nvbo.SavePetJiuZhuLove(l); if (lid > 0) { o.TotalLove = (o.TotalLove ?? 0) + l.Love; o.SurLove = (o.SurLove ?? 0) + l.Love; mss.SaveOA(o); } } } } catch (Exception) { } try { if (order.UrlPara > 0)//非小程序 { string token = Token(mjuserid); var temp = new { first = new { value = "我们已收到您的微信付款", color = "#173177" }, orderMoneySum = new { value = order.TotalPrice.ToString() + "元", color = "#173177" }, orderProductName = new { value = order.GoodsName, color = "#173177" }, Remark = new { value = "\n" + "我们已收到您的爱心。", color = "#CD0000" } }; if (order.PJ != null && order.PJ != 0) { temp = new { first = new { value = "我们已收到您的微信付款", color = "#173177" }, orderMoneySum = new { value = order.TotalPrice.ToString() + "元", color = "#173177" }, orderProductName = new { value = order.GoodsName, color = "#173177" }, Remark = new { value = "\n" + "我们已收到您的爱心,您已成功捐粮" + Math.Round(order.TotalPrice.Value / 16, 2) + "kg,并且您的爱心被放大,由宠物管家赞助为其配捐" + Math.Round(order.PJ.Value / 16, 2) + "kg", color = "#CD0000" } }; } string message = SendTemplateMessage(token, order.FromUserName, "qLJpWtjKj8zm3j8cwOe0u3u7qHwQ04cSx2UUvvVu-Ug", "#FF0000", temp, WebUrl + "/wechat/test/tz.aspx?tousername="******"yyyy年MM月dd日 HH:mm"), color = "#173177" }, keyword2 = new { value = order.TotalPrice.ToString() + "元", color = "#173177" }, keyword3 = new { value = order.GoodsName, color = "#173177" }, keyword4 = new { value = "为毛孩子筹粮/筹款", color = "#173177" }, keyword5 = new { value = order.OrderNo, color = "#173177" } }; string message = SendTemplateMessageSR(token, order.FromUserName, "IuoZZEIkILzvazy94NRpYrQ9usZ0wc3RyeSSp85gfmA", "#FF0000", temp, "pages/Pet/Detail/Detail?id=" + order.Source, order.buyer_logon_id); mss.SaveLog(new WXLOG { CON = message, TIME = DateTime.Now }); } } catch (Exception) { } Response.Write("success"); Response.End(); } } //WXLOG log = new WXLOG { CON = postStr + "weixin", TIME = DateTime.Now }; //mss.SaveLog(log); } } }