public int mystar = 0; //我关注的 protected void Page_Load(object sender, EventArgs e) { 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; } 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(); if (Request.QueryString["para"] == null) { oa = mss.GetOA(user);//根据微信号获取到的信息 myzc = nvbo.GetMyJiuZhuCount(user); mycl = nvbo.GetMyJiuZhuMoney(user, 1); myck = nvbo.GetMyJiuZhuMoney(user, 2); mypost = nvbo.GetMyPostJiuZhuCount(user); mystar = nvbo.GetMyStarJiuZhuCount(user); } else { string html = ""; List <MyJiuZhu> mlist = nvbo.GetMyJiuZhuList(user, int.Parse(Request.Params["jztype"]), int.Parse(Request.Params["page"])); foreach (var m in mlist) { if (Request.Params["jztype"] == "1") { html += string.Format(@"<li><a href=""detail.aspx?id={4}&p={5}""> <div class=""imgbox""> <img src=""{0}""></div> <div class=""jiluinfo""> <p><strong>{1}</strong></p> <p>所捐狗粮:<bdo>{2}</bdo>kg</p> <p>捐款次数:<bdo>{3}</bdo>次</p> </div> </a> </li>", WebUrl + m.CImg, m.NickName, Math.Round(m.je / 16, 2), m.cs, m.ID, Request.Params["p"]); } else { html += string.Format(@"<li><a href=""detail.aspx?id={4}&p={5}""> <div class=""imgbox""> <img src=""{0}""></div> <div class=""jiluinfo""> <p><strong>{1}</strong></p> <p>所捐狗粮:<bdo>{2}</bdo>元</p> <p>捐款次数:<bdo>{3}</bdo>次</p> </div> </a> </li>", WebUrl + m.CImg, m.NickName, m.je, m.cs, m.ID, Request.Params["p"]); } } Response.Write(html); Response.End(); } } }
//发送模板消息 private JsonSMsg TemplateSend(Template1 text) { JsonSMsg rMsg = new JsonSMsg(); OAauth_Log oa = mss.GetOA(text.Openid); WeiPage w = new WeiPage(); string token = w.Token(AppConfig.FWHOriginalID); rMsg.Data += "," + token; var temp = new { first = new { value = text.first, color = "#173177" }, ADA_number = new { value = text.ADA_number, color = "#173177" }, ADA_name = new { value = text.ADA_name, color = "#173177" }, ADA_date = new { value = text.ADA_date, color = "#173177" }, remark = new { value = "\n" + text.remark, color = "#000000" } }; string message = SendTemplateMessage(token, text.Openid, text.TemplateID, "#FF0000", temp, "http://www.censh.com", text.first); result data = JsonConvert.DeserializeObject <result>(message); if (data != null) { rMsg.Status = data.errcode; rMsg.Message = data.errmsg; } else { rMsg.Status = -1; rMsg.Message = "出现异常"; } return(rMsg); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["para"] == null) { if ((Request.QueryString["openid"] != null) || Session["FromUserName"] != null) { //WriteTxt("结束授权"); string user = Request.QueryString["openid"] == null ? Session["FromUserName"].ToString() : Request.QueryString["openid"].ToString(); string access_token = Request.QueryString["Access_token"] == null ? Session["Access_token"].ToString() : Request.QueryString["Access_token"].ToString(); Session["FromUserName"] = user; Session["Access_token"] = access_token; HttpCookie cookie = Request.Cookies["XYH_COUPON"]; if (cookie == null) { cookie = new HttpCookie("XYH_COUPON"); } cookie.Values.Set("FromUserName", user); string url = "https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token + "&openid=" + user + "&lang=zh_CN"; string token = PostRequest(url); WriteTxt(url); WriteTxt(token); OpenInfo autho = JsonConvert.DeserializeObject <OpenInfo>(token); if (!string.IsNullOrWhiteSpace(autho.headimgurl)) { MySmallShopService mss = new MySmallShopService(); OAauth_Log oa = mss.GetOA(user, "商业集团送券活动"); if (oa == null) { oa = new OAauth_Log(); oa.FromUserName = user; oa.ToUserName = "******"; oa.headimgurl = autho.headimgurl; oa.Nickname = autho.nickname; oa.CreateDate = DateTime.Now; mss.SaveOA(oa); } } XHYCouponService _xyhService = new XHYCouponService(); //判断是否参加并且可以领取卡券 WXCouponGiveInfo model = _xyhService.GetWXCouponGiveInfoByOpenid(user, "SYJT"); if (model != null) { if (model.GetCoupon == 1) { var phone = model.Mobile; Response.Redirect("list.html?mobile=" + phone); } } } else { //WriteTxt("开始授权"); OAuth(AbsoluteUri); } } }
//public Pet_JiuZhu_PeiJuan pj = new Pet_JiuZhu_PeiJuan { PJ = 0, YJ = 0 }; protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["para"] == null) { //HttpCookie cookie = Request.Cookies["cookiedtgohome"]; //if (cookie == null) //{ // cookie = new HttpCookie("cookiedtgohome"); // cookie.Expires = DateTime.Now.AddDays(3); // cookie.Name = "cookiedtgohome"; // cookie.Value = DateTime.Now.AddDays(3).ToString("yyyy.MM.dd"); // HttpContext.Current.Response.Cookies.Add(cookie); // BaseLoad2(); //} //else //{ // DateTime dt = DateTime.Parse(cookie.Value); // if (dt < DateTime.Now) // { // cookie.Value = DateTime.Now.AddDays(3).ToString("yyyy.MM.dd"); // cookie.Expires = DateTime.Now.AddDays(3); // HttpContext.Current.Response.Cookies.Add(cookie); // BaseLoad2(); // } // else // { // BaseLoad(); // } //} if (Request.Params["para"] == null) { Response.Write(" <input type='hidden' value='" + Server.UrlEncode(AbsoluteUri) + "' id='url' />"); } //ordercount = nvbo.GetOrderCount(); //orderprice = nvbo.GetOrderTotalPrice(); try { if (Request.QueryString["id"] != null || Request.QueryString["state"] != null) { j = nvbo.GetJiuZhuInfo(int.Parse(Request.QueryString["id"] == null ? Request.QueryString["state"] : Request.QueryString["id"])); if (j != null) { nlist = nvbo.GetJiuZhuNewsList(j.ID); 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(); isstar = nvbo.GetIsStarJiuZhu(user, j.ID); } } //pj = nvbo.GetPeiJuan(DateTime.Now); //if (pj == null) // pj = new Pet_JiuZhu_PeiJuan { PJ = 0, YJ = 0 }; } else { Response.Redirect("detail.aspx?id=1"); } } catch (Exception) { Response.Redirect("detail.aspx?id=1"); } } else if (Request.QueryString["para"] == "tj") { int jztype = int.Parse(Request.Params["jztype"]); List <OrderEX> list = nvbo.GetOrderList(int.Parse(Request.Params["page"]), int.Parse(Request.QueryString["iid"])); string html = ""; // if (int.Parse(Request.Params["page"]) == 1) // html = @"<li> // <p> // <img src=""http://SPACRM.meijiewd.com/assets/images/logo.jpg""> // 小宠回家 支持了<strong>300千克</strong></p> // <p><bdo style=""width:100%;"">2016-08-25 17:03:25</bdo></p> // <p> // <bdo class=""txtinfo"" style=""width:100%;"">支持!</bdo> // </p> // </li>"; foreach (OrderEX o in list) { try { if (jztype == 1) { html += string.Format(@"<li> <div class=""comconli""> <p> <img src=""{0}""> {1} 支持了<strong>{2}千克{5}</strong></p> <p><bdo style=""width:95%;"">{3}</bdo></p> <p> <bdo class=""txtinfo"" style=""width:90%;"">{4}</bdo> </p> </div> <div class=""aipet-pinglun-box"" id=""aipet-pinglun-box{6}""> <div class=""pinglun-bar""><span onClick=""javascript:layerpl({6});"">回复</span></div> {7} </div> </li>", o.headimgurl, o.Nickname + GetZFBName(o.buyer_logon_id, o.Nickname), Math.Round(o.TotalPrice / 16, 3), o.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), o.CourierRemark == "" ? "支持" : ReplaceKeyWord(o.CourierRemark), o.pj == 0 ? "" : "(获得配捐" + Math.Round(o.pj / 16, 2) + "kg)", o.ID, GetPL(o.ID)); } else if (jztype == 2) { html += string.Format(@"<li> <div class=""comconli""><p> <img src=""{0}""> {1} 支持了<strong>{2}元</strong></p> <p><bdo style=""width:95%;"">{3}</bdo></p> <p> <bdo class=""txtinfo"" style=""width:90%;"">{4}</bdo> </p></div> <div class=""aipet-pinglun-box"" id=""aipet-pinglun-box{6}""> <div class=""pinglun-bar""><span onClick=""javascript:layerpl({5});"">回复</span></div> {6} </div> </li>", o.headimgurl, o.Nickname + GetZFBName(o.buyer_logon_id, o.Nickname), o.TotalPrice, o.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), o.CourierRemark == "" ? "支持" : ReplaceKeyWord(o.CourierRemark), o.ID, GetPL(o.ID)); } } catch (Exception) { } } if (list.Count == 0) { html = ""; } Response.Write(html); Response.End(); } else if (Request.QueryString["para"] == "star") { 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(); int num = nvbo.GetIsStarJiuZhu(user, int.Parse(Request.QueryString["jid"])); if (num > 0) { nvbo.DeleteJiuZhuStar(user, int.Parse(Request.QueryString["jid"])); Response.Write("{\"st\":2}"); } else { nvbo.SaveJiuZhuStar(new Pet_JiuZhu_Star { CreateTime = DateTime.Now, FromUserName = user, JID = int.Parse(Request.QueryString["jid"]) }); Response.Write("{\"st\":1}"); } } else { Response.Write("{\"st\":3}"); } Response.End(); } else if (Request.QueryString["para"] == "pl") { 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(); int num = nvbo.IsHaveOrderByOpenid(user, int.Parse(Request.QueryString["jid"])); Pet_JiuZhu_Info pj = nvbo.GetJiuZhuInfo(int.Parse(Request.QueryString["jid"])); if (num == 0 && pj.FromUserName != user && user != "oloJGv4lWL-TS8yn8uo4Fu1rbVTI" && user != "oloJGvzwelDQjIKMMWC8Z6ngM7gk" && user != "oloJGvx3hLkCNadLGIpAMimz2Xwc") { Response.Write("{\"st\":2,\"msg\":\"你没有支持该项目,不能评论。\"}"); } else { OAauth_Log o = mss.GetOA(user); if (o != null) { nvbo.SavePetComment(new Pet_JiuZhu_comment { CreateTime = DateTime.Now, Detail = Request.Params["detail"], FromUserName = user, OID = int.Parse(Request.Params["oid"]), HeadImage = o.headimgurl, NiceName = o.Nickname }); Response.Write("{\"st\":1,\"msg\":\"<p><strong style='color:#689cc3;'>" + o.Nickname + ":</strong>" + Request.Params["detail"] + "</p>\"}"); } else { Response.Write("{\"st\":2,\"msg\":\"异常\"}"); } } } else { Response.Write("{\"st\":3}"); } Response.End(); } }
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); } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["para"] != null && Request.QueryString["para"] == "SendDX") { Random r = new Random(); int num = r.Next(100000, 999999); string message = "本次获取的验证码是" + num + "。"; string zt = new SendDX().Send(message, Request.Params["phone"]); if (zt == "发送成功") { Session["RanPhone"] = Request.Params["phone"]; Session["RanNum"] = num.ToString(); Response.Write("{\"message\":\"发送成功。\",\"status\":\"" + 0 + "\"}"); } else { Response.Write("{\"message\":\"发送失败。\",\"status\":\"" + -1 + "\"}"); } Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "bang") { if (Session["RanNum"] == null) { Response.Write("{\"message\":\"请先获取验证码。\",\"status\":\"" + -1 + "\"}"); } else if (Request.QueryString["phone"] != Session["RanPhone"].ToString() || Request.QueryString["yzm"] != Session["RanNum"].ToString()) { Response.Write("{\"message\":\"输入的验证码有误。\",\"status\":\"" + -1 + "\"}"); } else { string url = "wo.aspx"; OAauth_Log oa1 = mss.GetOAByPhone(Request.QueryString["phone"]);//根据手机号码获取到的信息 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(); oa = mss.GetOA(user);//根据微信号获取到的信息 if (oa != null && !string.IsNullOrEmpty(oa.Phone)) { Response.Write("{\"message\":\"你已经绑定。\",\"status\":\"" + -1 + "\"}"); } //else if (oa != null && oa1 != null && !string.IsNullOrEmpty(oa1.FromUserName) && oa1.FromUserName != null&&oa1.ToUserName!="web") //根据手机号码获取到的用户信息,微信号码不同 //{ // Response.Write("{\"message\":\"该手机已被其他微信绑定。\",\"status\":\"" + -1 + "\"}"); //} //可绑定多个账号 else { if (oa != null && oa1 != null && oa1.ID != oa.ID) //根据手机号获取到另一个来自网页的绑定的信息,将手机号绑定到有微信号的信息中,删除无手机号的信息 { oa.Phone = Request.QueryString["phone"]; //mss.DeteleOA(oa1.ID); //保留原有账号不删除,保留web版账号 } else if (oa != null) { oa.Phone = Request.QueryString["phone"]; } else { oa = new OAauth_Log { CreateDate = DateTime.Now, FromUserName = user, ToUserName = "", Nickname = "用户", Phone = Request.QueryString["phone"] }; } mss.SaveOA(oa); Session["FromUserName"] = oa.FromUserName; Session["ToUserName"] = oa.ToUserName; if (Session["beforeurl2"] != null) { url = Session["beforeurl2"].ToString().Replace("*", "&"); } Response.Write("{\"message\":\"登录成功\",\"status\":\"" + 1 + "\",\"url\":\"" + url + "\"}"); } } else { if (oa1 == null) //web版登录 { oa = new OAauth_Log { CreateDate = DateTime.Now, FromUserName = Guid.NewGuid().ToString("d"), ToUserName = "******", Nickname = "用户", Phone = Request.QueryString["phone"] }; mss.SaveOA(oa); Session["FromUserName"] = oa.FromUserName; Session["ToUserName"] = oa.ToUserName; if (Session["beforeurl2"] != null) { url = Session["beforeurl2"].ToString().Replace("*", "&"); } Response.Write("{\"message\":\"登录成功\",\"status\":\"" + 1 + "\",\"url\":\"" + url + "\"}"); } else { Session["FromUserName"] = oa1.FromUserName; Session["ToUserName"] = oa1.ToUserName; if (Session["beforeurl2"] != null) { url = Session["beforeurl2"].ToString().Replace("*", "&"); } Response.Write("{\"message\":\"登录成功\",\"status\":\"" + 1 + "\",\"url\":\"" + url + "\"}"); } } } Response.End(); } else { if (Request.QueryString["beforeurl2"] != null && Session["beforeurl2"] == null) { Session["beforeurl2"] = Request.QueryString["beforeurl2"]; } 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(); oa = mss.GetOA(user);//根据微信号获取到的信息 } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["para"] == null && Request.Files.Count == 0) { //HttpCookie cookie = Request.Cookies["cookiedtgohome"]; //if (cookie == null) //{ // cookie = new HttpCookie("cookiedtgohome"); // cookie.Expires = DateTime.Now.AddDays(3); // cookie.Name = "cookiedtgohome"; // cookie.Value = DateTime.Now.AddDays(3).ToString("yyyy.MM.dd"); // HttpContext.Current.Response.Cookies.Add(cookie); // BaseLoad2(); //} //else //{ // DateTime dt = DateTime.Parse(cookie.Value); // if (dt < DateTime.Now) // { // cookie.Value = DateTime.Now.AddDays(3).ToString("yyyy.MM.dd"); // cookie.Expires = DateTime.Now.AddDays(3); // HttpContext.Current.Response.Cookies.Add(cookie); // BaseLoad2(); // } // else // { // BaseLoad(); // } //} 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; OAauth_Log oa = mss.GetOA(user); if (oa != null && string.IsNullOrEmpty(oa.Phone)) { Response.Redirect("bangphone.aspx?beforeurl2=" + AbsoluteUri.Replace("&", "*")); } else { Pet_JiuZhu_ShenQing sq = nvbo.GetJiuZhuShenQing(user); if (sq != null) { Response.Redirect("sq2.aspx"); } } } } else if (Request.QueryString["para"] == null && Request.Files.Count > 0 && (Request.Files[0].InputStream.Length > 0 || (Request["pic"] != null && Request["Pic"].Trim() != ""))) { HttpPostedFile file = Request.Files[0]; string Extension = Path.GetExtension(file.FileName).ToLower(); byte[] data = new byte[file.InputStream.Length]; file.InputStream.Read(data, 0, data.Length); string url = "/home/ViewImage.do"; string remark = "";// Request["filename"]; FILES fileEntity = _mservice.UploadFile(Extension, file.ContentType, data, url, remark); fileEntity.REMARK = ConfigurationSettings.AppSettings["WebUrl"] + fileEntity.FILE_URL; Response.Write("{\"url\":\"" + fileEntity.REMARK + "\",\"id\":\"" + fileEntity.ID + "\",\"d\":\"" + fileEntity.FILE_URL + "\"}"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "delete") { FILES f = _mservice.GetUploadFile(int.Parse(Request.QueryString["id"])); if (f != null) { File.Delete(f.FILE_NAME); _mservice.DeleteFiles(f.ID); } Response.Write("ok"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "tj") { 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; string[] pics1 = Request.Params["pic1"].Split('*'); string[] pics2 = Request.Params["pic2"].Split('*'); Pet_JiuZhu_ShenQing sq = new Pet_JiuZhu_ShenQing { CardNo = Request.Params["cardno"], CreateTime = DateTime.Now, FromUserName = user, JDName = Request.Params["jdname"], Name = Request.Params["name"], Phone = Request.Params["phone"], WXNo = Request.Params["wxno"], State = 0 }; if (pics1.Length > 1) { sq.JDImg1 = pics1[0]; } if (pics1.Length > 2) { sq.JDImg2 = pics1[1]; } if (pics1.Length > 3) { sq.JDImg3 = pics1[2]; } if (pics1.Length > 4) { sq.JDImg4 = pics1[3]; } if (pics1.Length > 5) { sq.JDImg5 = pics1[4]; } if (pics2.Length > 1) { sq.CardNoImg1 = pics2[0]; } if (pics2.Length > 2) { sq.CardNoImg2 = pics2[1]; } int id = nvbo.SaveJiuZhuShenQing(sq); if (id > 0) { Response.Write("{\"msg\":\"您的资料已经提交,我们会在1个工作日进行资料审核。\",\"st\":\"1\",\"url\":\"\"}"); Response.End(); } else { Response.Write("{\"msg\":\"失败\",\"st\":\"-1\",\"url\":\"\"}"); Response.End(); } } } }
/// <summary> /// 海报1 /// </summary> /// <param name="openid"></param> /// <returns></returns> public string SeadSeaNews(string openid) { string img = "/assets/img/bottom.jpg"; img = Server.MapPath(img); string headimg = "/wechat/spa/image/logo.jpg"; string qrimg = "/wechat/spa/image/logo.jpg"; OAauth_Log oa = mss.GetOA(openid); if (oa != null) { if (!string.IsNullOrEmpty(oa.MEDIA_ID) && oa.MEDIA_Time.HasValue && oa.MEDIA_Time > DateTime.Now) { return(oa.MEDIA_ID); //如果已有海报,并且未过期,则直接返回之前的海报。 } if (string.IsNullOrEmpty(oa.Ticket)) //如果没有生成过邀请二维码,则生成一个。 { //string access_token = w.Token(w.mjuserid); string jason = "{\"action_name\": \"QR_LIMIT_SCENE\", \"action_info\": {\"scene\": {\"scene_id\": " + (oa.ID + 10000) + "}}}"; //oa的id增加一万 string resMessage = WeiPage.HttpXmlPostRequest("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + Token(mjuserid), jason, Encoding.UTF8); string[] a = resMessage.Split('\"'); if (a.Length > 3) { oa.Ticket = Server.UrlEncode(a[3]); DownQRImage(oa.Ticket); qrimg = "/wechat/QRImage/" + oa.Ticket + ".jpg"; } } else { qrimg = "/wechat/QRImage/" + oa.Ticket + ".jpg"; } qrimg = Server.MapPath(qrimg); if (!string.IsNullOrEmpty(oa.DownPic)) { headimg = oa.DownPic; } else if (!string.IsNullOrEmpty(oa.headimgurl)) { string down = DownHeadImage(oa); if (!string.IsNullOrEmpty(down)) { headimg = down; } } headimg = Server.MapPath(headimg); string img2 = @"E:\ASPNETTempFiles\seanews\"; if (!System.IO.Directory.Exists(img2)) { Directory.CreateDirectory(img2); } oa.SeaImg = Guid.NewGuid().ToString(); img2 += oa.SeaImg + ".jpg"; if (File.Exists(img) && File.Exists(headimg) && File.Exists(qrimg)) { ImageWriter iw = new ImageWriter(); System.Drawing.Bitmap bm = new System.Drawing.Bitmap(headimg); System.Drawing.Image newImage = CutEllipse(bm, new Rectangle(0, 0, bm.Width, bm.Height), new Size(200, 200)); iw.SaveWatermark(new System.Drawing.Bitmap(img), (Bitmap)newImage, ImageWriter.WatermarkPosition.LeftTop, 90, 70, new System.Drawing.Bitmap(qrimg), ImageWriter.WatermarkPosition.LeftBottom, 220, 50, img2, oa.Nickname);; // f.FILE_NAME, Server.MapPath("~/assets/images/shuiyin.png"), Server.MapPath("~/assets/images/shuiyin2.png"), Server.MapPath("~/assets/images/shuiyin3.png"), 0.3f, ImageWriter.WatermarkPosition.Center, 10, f.FILE_NAME); } if (File.Exists(img2)) { List <string> imglist = new List <string>(); imglist.Add(img2); string a = HttpUploadFile("https://api.weixin.qq.com/cgi-bin/media/upload?access_token=" + Token(mjuserid) + "&type=image", "图片", "application/x-jpg", new System.Collections.Specialized.NameValueCollection { }, imglist); Rootobject root = JsonConvert.DeserializeObject <Rootobject>(a); if (root.media_id != null) { oa.MEDIA_ID = root.media_id; oa.MEDIA_Time = DateTime.Now.AddDays(3).AddHours(-2); mss.SaveOA(oa); return(root.media_id); string message = @"{ ""touser"":""{0}"", ""msgtype"":""image"", ""image"": { ""media_id"":""{1}"" } }"; message = message.Replace("{0}", oa.FromUserName).Replace("{1}", root.media_id); string Access_token = Token(mjuserid); var postUrl = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + Access_token; string d = message; //d = d.Replace("{0}", "oS7pm1iNL2P2pjdgHO3xC2NRdWE8").Replace("{1}", Message); string resMessage = HttpXmlPostRequest(postUrl, d, Encoding.UTF8); //Response.Write(resMessage); } } } return("err"); }
public string OldAndNew(WXCUST_MSG_HIS requestXML, string resxml, int num) { OrderService osbo = new OrderService(); MySmallShopService mss = new MySmallShopService(); OAauth_Log oa = mss.GetOA(num - 10000); if (oa != null) { lock (lockobject) { OAauth_Log o = SaveOA(requestXML.FROMUSERNAME, requestXML.TOUSERNAME); using (TransScope scope = new TransScope(System.Configuration.ConfigurationManager.ConnectionStrings[SPACRM.Common.AppConfig.MainDbKey].ConnectionString)) { if (o != null && requestXML.WXEVENT.ToLower() == "subscribe") { if (o.FromUserName != oa.FromUserName) { int jie = 0; if (DateTime.Now < DateTime.Parse(ActiveEndDate)) { jie = 2; } Cust_Old_New old = new Cust_Old_New { CreateTime = DateTime.Now, FromUserName = oa.FromUserName, OrderID = 0, Price = 20, State = 0, ToUserName = o.FromUserName, ToUserNickName = o.Nickname, Jie = jie }; osbo.SaveCustOldNew(old); //给推荐人一个抽奖码 if (DateTime.Now < DateTime.Parse(ActiveEndDate)) { try { string token = Token(mjuserid); var temp = new { first = new { value = "活动状态变更通知", color = "#173177" }, keyword1 = new { value = "棒棒哒!您邀请的好友**关注【佰草集汉方SPA】啦!", color = "#173177" }, keyword2 = new { value = "小集", color = "#173177" }, keyword3 = new { value = "以礼邀约,迎接初夏", color = "#173177" }, keyword4 = new { value = "2018年4月27日18:00:00 - 5月3日23:59:59", color = "#173177" }, }; string message = SendTemplateMessage(token, oa.FromUserName, ActiveStateChangeTmpId, "#FF0000", temp, WebUrl + "/wechat/SPA/HFOldAndNew.aspx");//Seapage2 } catch (Exception) { } } } } resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[感谢您的关注,小集在此等候多时啦!\n\n注册绑定即可获得380元代金券\n凭券消费入店,还可领取入店礼“佰草集汉方SPA金致玉妍院线产品2件套” 一份\n\n<a href='" + WebUrl + "/wechat/SPA/HFOldAndNew.aspx'>邀好友赢大奖</a> \n活动奖品:赢佰草集太极.昼御夜养.源生霜、清肌养颜太极泥、三丽鸥KITTY礼品杯\n\n保存下图并分享参与活动吧!]]></Content><FuncFlag>0</FuncFlag></xml>"; //生成海报 if (DateTime.Now < DateTime.Parse(ActiveEndDate)) { } scope.Commit(); } } } return(resxml); }
/// <summary> /// 回复消息(微信信息返回) /// </summary> /// <param name="weixinXML"></param> private void ResponseMsg(WXCUST_MSG_HIS requestXML) { WriteTxt(requestXML.MSGTYPE); string resxml = "<xml><ToUserName><![CDATA[" + requestXML.FROMUSERNAME + "]]></ToUserName><FromUserName><![CDATA[" + requestXML.TOUSERNAME + "]]></FromUserName><CreateTime>" + ConvertDateTimeInt(DateTime.Now) + "</CreateTime>"; try { if (requestXML.MSGTYPE == "text") { if (requestXML.CONTENT == "海报") { } else { int count = 0; List <Information_EX> list = sbo.GetModelList(string.Format(" ((KeyWords like '%{0}%' and MatchingType=0) or (KeyWords ='{0}' and MatchingType=1)) AND replytype={1} and ToUserName='******'", requestXML.CONTENT, 1, requestXML.TOUSERNAME)); if (list.Count == 1 || (list.Count > 1 && list[0].MsgType != "news")) { Information_EX f = list[0];// ibo.GetModel(requestXML.EventKey, 4); //自定义菜单回复 if (f != null) { switch (f.MsgType) { case "text": resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[" + f.Content + "]]></Content><FuncFlag>0</FuncFlag></xml>"; break; case "news": resxml += "<MsgType><![CDATA[news]]></MsgType><ArticleCount>1</ArticleCount><Articles>"; resxml += "<item><Title><![CDATA[" + f.Title + "]]></Title><Description><![CDATA[" + f.Description + "]]></Description><PicUrl><![CDATA[" + ConfigurationSettings.AppSettings["WebUrl"] + f.PicUrl + "]]></PicUrl><Url><![CDATA[" + (f.IsURL ? (f.FulltextUrl.Contains("?id") ? (f.FulltextUrl + "&FromUserName="******"&ToUserName="******"") : (f.FulltextUrl + "?FromUserName="******"&ToUserName="******"")) : (ConfigurationSettings.AppSettings["WebUrl"] + "/GraphicDisplay.aspx?id=" + f.DID)) + "]]></Url></item>"; //URL是点击之后跳转去那里,这里跳转到百度 resxml += "</Articles><FuncFlag>0</FuncFlag></xml>"; break; case "music": resxml += string.Format(@"<MsgType><![CDATA[music]]></MsgType> <Music> <Title><![CDATA[{0}]]></Title> <Description><![CDATA[{1}]]></Description> <MusicUrl><![CDATA[{2}]]></MusicUrl> <HQMusicUrl><![CDATA[{2}]]></HQMusicUrl> </Music> <FuncFlag>0</FuncFlag> </xml>", f.Title, f.Description, ConfigurationSettings.AppSettings["WebUrl"] + f.PicUrl); break; default: //resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[感谢您的支持]]></Content><FuncFlag>0</FuncFlag></xml>"; break; } } } else if (list.Count > 1) //多图 { count = list.Count; resxml += "<MsgType><![CDATA[news]]></MsgType><ArticleCount>" + count + "</ArticleCount><Articles>"; for (int i = 0; i < count; i++) { resxml += "<item><Title><![CDATA[" + list[i].Title + "]]></Title><Description><![CDATA[" + list[i].Description + "]]></Description><PicUrl><![CDATA[" + ConfigurationSettings.AppSettings["WebUrl"] + list[i].PicUrl + "]]></PicUrl><Url><![CDATA[" + (list[i].IsURL ? (list[i].FulltextUrl.Contains("?id") ? (list[i].FulltextUrl + "&FromUserName="******"&ToUserName="******"") : (list[i].FulltextUrl + "?FromUserName="******"&ToUserName="******"")) : (ConfigurationSettings.AppSettings["WebUrl"] + "/GraphicDisplay.aspx?id=" + list[i].DID)) + "]]></Url></item>";//URL是点击之后跳转去那里,这里跳转到百度 } resxml += "</Articles><FuncFlag>0</FuncFlag></xml>"; } else { list = sbo.GetModelList(string.Format(" replytype={0} and ToUserName='******'", 3, requestXML.TOUSERNAME)); if (list.Count == 1 || (list.Count > 1 && list[0].MsgType != "news")) { Information_EX f = list[0]; if (f != null) { switch (f.MsgType) { case "text": resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[" + f.Content + "]]></Content><FuncFlag>0</FuncFlag></xml>"; break; case "news": resxml += "<MsgType><![CDATA[news]]></MsgType><ArticleCount>1</ArticleCount><Articles>"; resxml += "<item><Title><![CDATA[" + f.Title + "]]></Title><Description><![CDATA[" + f.Description + "]]></Description><PicUrl><![CDATA[" + ConfigurationSettings.AppSettings["WebUrl"] + f.PicUrl + "]]></PicUrl><Url><![CDATA[" + (f.IsURL ? (f.FulltextUrl.Contains("?id") ? (f.FulltextUrl + "&FromUserName="******"&ToUserName="******"") : (f.FulltextUrl + "?FromUserName="******"&ToUserName="******"")) : (ConfigurationSettings.AppSettings["WebUrl"] + "/GraphicDisplay.aspx?id=" + f.DID)) + "]]></Url></item>"; //URL是点击之后跳转去那里,这里跳转到百度 resxml += "</Articles><FuncFlag>0</FuncFlag></xml>"; break; case "music": resxml += string.Format(@"<MsgType><![CDATA[music]]></MsgType> <Music> <Title><![CDATA[{0}]]></Title> <Description><![CDATA[{1}]]></Description> <MusicUrl><![CDATA[{2}]]></MusicUrl> <HQMusicUrl><![CDATA[{2}]]></HQMusicUrl> </Music> <FuncFlag>0</FuncFlag> </xml>", f.Title, f.Description, ConfigurationSettings.AppSettings["WebUrl"] + f.PicUrl); break; default: //resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[感谢您的支持]]></Content><FuncFlag>0</FuncFlag></xml>"; break; } } } else if (list.Count > 1) //多图 { int count2 = list.Count; resxml += "<MsgType><![CDATA[news]]></MsgType><ArticleCount>" + count + "</ArticleCount><Articles>"; for (int z = 0; z < count2; z++) { resxml += "<item><Title><![CDATA[" + list[z].Title + "]]></Title><Description><![CDATA[" + list[z].Description + "]]></Description><PicUrl><![CDATA[" + ConfigurationSettings.AppSettings["WebUrl"] + list[z].PicUrl + "]]></PicUrl><Url><![CDATA[" + (list[z].IsURL ? (list[z].FulltextUrl.Contains("?id") ? (list[z].FulltextUrl + "&FromUserName="******"&ToUserName="******"") : (list[z].FulltextUrl + "?FromUserName="******"&ToUserName="******"")) : (ConfigurationSettings.AppSettings["WebUrl"] + "/GraphicDisplay.aspx?id=" + list[z].DID)) + "]]></Url></item>";//URL是点击之后跳转去那里,这里跳转到百度 } resxml += "</Articles><FuncFlag>0</FuncFlag></xml>"; } } } } else if (requestXML.MSGTYPE == "event") { if (requestXML.WXEVENT == "CLICK") { WriteTxt("CLICK"); if (requestXML.EVENTKEY == InviteMenuId) { resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[分享海报邀请新用户,福利多多:\n• 邀请关注,赢佰草集太极.昼御夜养.源生霜、清肌养颜太极泥、三丽鸥KITTY礼品杯\n• 关注后注册绑定,还可获得380元代金券 \n\n点击进入<a href='" + WebUrl + "/wechat/SPA/HFOldAndNew.aspx'>活动主会场</a>\n分享海报,赢惊喜大礼!]]></Content><FuncFlag>0</FuncFlag></xml>"; } else { List <CustomMenu_EX> list = sbo.GetCustomMenuModelList(string.Format(" c.ID='{0}'", requestXML.EVENTKEY)); if (list.Count == 1 || (list.Count > 1 && list[0].MsgType != "news")) { CustomMenu_EX f = list[0];// ibo.GetModel(requestXML.EventKey, 4); //自定义菜单回复 if (f != null) { switch (f.MsgType) { case "text": resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[" + f.Content + "]]></Content><FuncFlag>0</FuncFlag></xml>"; break; case "news": resxml += "<MsgType><![CDATA[news]]></MsgType><ArticleCount>1</ArticleCount><Articles>"; resxml += "<item><Title><![CDATA[" + f.Title + "]]></Title><Description><![CDATA[" + f.Description + "]]></Description><PicUrl><![CDATA[" + ConfigurationSettings.AppSettings["WebUrl"] + f.PicUrl + "]]></PicUrl><Url><![CDATA[" + (f.IsURL ? (f.FulltextUrl.Contains("?id") ? (f.FulltextUrl + "&FromUserName="******"&ToUserName="******"") : (f.FulltextUrl + "?FromUserName="******"&ToUserName="******"")) : (ConfigurationSettings.AppSettings["WebUrl"] + "/GraphicDisplay.aspx?id=" + f.DID)) + "]]></Url></item>"; //URL是点击之后跳转去那里,这里跳转到百度 resxml += "</Articles><FuncFlag>0</FuncFlag></xml>"; break; case "music": resxml += string.Format(@"<MsgType><![CDATA[music]]></MsgType> <Music> <Title><![CDATA[{0}]]></Title> <Description><![CDATA[{1}]]></Description> <MusicUrl><![CDATA[{2}]]></MusicUrl> <HQMusicUrl><![CDATA[{2}]]></HQMusicUrl> </Music> <FuncFlag>0</FuncFlag> </xml>", f.Title, f.Description, ConfigurationSettings.AppSettings["WebUrl"] + f.PicUrl); break; default: //resxml += "<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[感谢您的支持]]></Content><FuncFlag>0</FuncFlag></xml>"; break; } } } else if (list.Count > 1) //多图 { int count = list.Count; resxml += "<MsgType><![CDATA[news]]></MsgType><ArticleCount>" + count + "</ArticleCount><Articles>"; for (int i = 0; i < count; i++) { resxml += "<item><Title><![CDATA[" + list[i].Title + "]]></Title><Description><![CDATA[" + list[i].Description + "]]></Description><PicUrl><![CDATA[" + ConfigurationSettings.AppSettings["WebUrl"] + list[i].PicUrl + "]]></PicUrl><Url><![CDATA[" + (list[i].IsURL ? (list[i].FulltextUrl.Contains("?id") ? (list[i].FulltextUrl + "&FromUserName="******"&ToUserName="******"") : (list[i].FulltextUrl + "?FromUserName="******"&ToUserName="******"")) : (ConfigurationSettings.AppSettings["WebUrl"] + "/GraphicDisplay.aspx?id=" + list[i].DID)) + "]]></Url></item>";//URL是点击之后跳转去那里,这里跳转到百度 } resxml += "</Articles><FuncFlag>0</FuncFlag></xml>"; } } } else if (requestXML.WXEVENT == "unsubscribe") { //取消关注 把粉丝表更新状态为0 WriteTxt("取消关注"); if (DateTime.Now < DateTime.Parse(ActiveEndDate)) { InsertFS(requestXML.FROMUSERNAME, requestXML.TOUSERNAME, 0); //插入粉丝信息 if (DateTime.Now < DateTime.Parse(ActiveEndDate)) { MySmallShopService mss = new MySmallShopService(); //将表Cust_Old_New中的Jie改成 - 1 ToUserName = openid //将表Cust_Old_New中的Jie改成 - 1 FromUserName = openid ToUserName = fx mss.UpdateCustOldNewJie(requestXML.FROMUSERNAME); //将表OAauth_Log中的字段SeaImg = '' 参加活动数量-1 OAauth_Log oa = mss.GetOA(requestXML.FROMUSERNAME); if (oa != null) { oa.SeaImg = ""; oa.SeaSource = null; mss.SaveOA(oa); } } } } else if (requestXML.WXEVENT.ToLower() == "location") //获取地理位置 { WriteTxt("获取地理位置"); } else if (requestXML.WXEVENT.ToLower() == "scan" || (requestXML.WXEVENT.ToLower() == "subscribe" && requestXML.EVENTKEY.ToLower().Contains("qrscene"))) //扫描二维码 { WriteTxt("扫二维码"); string EVENTKEY = requestXML.EVENTKEY; requestXML.EVENTKEY = requestXML.EVENTKEY.ToLower().Contains("qrscene") ? requestXML.EVENTKEY.Split('_')[1] : requestXML.EVENTKEY; int num = int.Parse(requestXML.EVENTKEY); if (requestXML.WXEVENT.ToLower() == "subscribe") { if (num > 10000) //邀请海报 { resxml = OldAndNew(requestXML, resxml, num); } resxml = Subscribe(requestXML, resxml); } } //关注 else if (requestXML.WXEVENT.ToLower() == "subscribe") { WriteTxt("关注"); resxml = Subscribe(requestXML, resxml); if (DateTime.Now < DateTime.Parse(ActiveEndDate)) { } } } requestXML.RESXML = resxml; if (!resxml.Contains("</xml>")) { resxml = ""; } AddCUST_MSG_HISHandler handler = new AddCUST_MSG_HISHandler(sbo.AddCUST_MSG_HIS); int result = handler.Invoke(requestXML); //sbo.AddCUST_MSG_HIS(requestXML); } catch (Exception ex) { resxml = ""; } finally { Response.Write(resxml); Response.End(); } }
public void SeadSeaNews(string openid) { string img = "/assets/img/bottom.jpg"; img = Server.MapPath(img); string headimg = "/wechat/spa/image/logo.jpg"; OAauth_Log oa = mss.GetOA(openid); if (oa != null) { if (!string.IsNullOrEmpty(oa.DownPic)) { headimg = oa.DownPic; } else if (!string.IsNullOrEmpty(oa.headimgurl)) { string down = DownHeadImage(oa); if (!string.IsNullOrEmpty(down)) { headimg = down; } } headimg = @"D:\小时光POS系统" + headimg.Replace("~", ""); string img2 = @"D:\ASPNETTempFiles\seanews\"; if (!System.IO.Directory.Exists(img2)) { Directory.CreateDirectory(img2); } img2 += Guid.NewGuid() + ".jpg"; if (File.Exists(img) && File.Exists(headimg)) { ImageWriter iw = new ImageWriter(); iw.SaveWatermark(new System.Drawing.Bitmap(img), new System.Drawing.Bitmap(headimg), ImageWriter.WatermarkPosition.Top, 50, img2);// f.FILE_NAME, Server.MapPath("~/assets/images/shuiyin.png"), Server.MapPath("~/assets/images/shuiyin2.png"), Server.MapPath("~/assets/images/shuiyin3.png"), 0.3f, ImageWriter.WatermarkPosition.Center, 10, f.FILE_NAME); } if (File.Exists(img2)) { List <string> imglist = new List <string>(); imglist.Add(img2); string a = HttpUploadFile("https://api.weixin.qq.com/cgi-bin/media/upload?access_token=" + Token(mjuserid) + "&type=image", "图片", "application/x-jpg", new System.Collections.Specialized.NameValueCollection { }, imglist); Rootobject root = JsonConvert.DeserializeObject <Rootobject>(a); if (root.media_id != null) { string message = @"{ ""touser"":""{0}"", ""msgtype"":""image"", ""image"": { ""media_id"":""{1}"" } }"; message = message.Replace("{0}", oa.FromUserName).Replace("{1}", root.media_id); string Access_token = Token(mjuserid); var postUrl = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + Access_token; string d = message; //d = d.Replace("{0}", "oS7pm1iNL2P2pjdgHO3xC2NRdWE8").Replace("{1}", Message); string resMessage = HttpXmlPostRequest(postUrl, d, Encoding.UTF8); //Response.Write(resMessage); } } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["para"] == null && Request.Files.Count == 0) { //HttpCookie cookie = Request.Cookies["cookiedtgohome"]; //if (cookie == null) //{ // cookie = new HttpCookie("cookiedtgohome"); // cookie.Expires = DateTime.Now.AddDays(3); // cookie.Name = "cookiedtgohome"; // cookie.Value = DateTime.Now.AddDays(3).ToString("yyyy.MM.dd"); // HttpContext.Current.Response.Cookies.Add(cookie); // BaseLoad2(); //} //else //{ // DateTime dt = DateTime.Parse(cookie.Value); // if (dt < DateTime.Now) // { // cookie.Value = DateTime.Now.AddDays(3).ToString("yyyy.MM.dd"); // cookie.Expires = DateTime.Now.AddDays(3); // HttpContext.Current.Response.Cookies.Add(cookie); // BaseLoad2(); // } // else // { // BaseLoad(); // } //} 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; Pet_JiuZhu_ShenQing sq = nvbo.GetJiuZhuShenQing(user); if (sq == null) { Response.Redirect("sq1.aspx"); } } } else if (Request.QueryString["para"] == null && Request.Files.Count > 0 && (Request.Files[0].InputStream.Length > 0 || (Request["pic"] != null && Request["Pic"].Trim() != ""))) { HttpPostedFile file = Request.Files[0]; string Extension = Path.GetExtension(file.FileName).ToLower(); byte[] data = new byte[file.InputStream.Length]; file.InputStream.Read(data, 0, data.Length); string url = "/home/ViewImage.do"; string remark = "";// Request["filename"]; FILES fileEntity = _mservice.UploadFile(Extension, file.ContentType, data, url, remark); fileEntity.REMARK = ConfigurationSettings.AppSettings["WebUrl"] + fileEntity.FILE_URL; Response.Write("{\"url\":\"" + fileEntity.REMARK + "\",\"id\":\"" + fileEntity.ID + "\",\"d\":\"" + fileEntity.FILE_URL + "\"}"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "delete") { FILES f = _mservice.GetUploadFile(int.Parse(Request.QueryString["id"])); if (f != null) { File.Delete(f.FILE_NAME); _mservice.DeleteFiles(f.ID); } Response.Write("ok"); Response.End(); } else if (Request.QueryString["para"] != null && Request.QueryString["para"] == "tj") { 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; string[] pics = Request.Params["pic"].Split('*'); string[] pics2 = Request.Params["pic2"].Split('*'); Pet_JiuZhu_ShenQing sq = nvbo.GetJiuZhuShenQing(user); OAauth_Log o = mss.GetOA(user); if (sq != null && o != null) { Pet_JiuZhu_Info j = new Pet_JiuZhu_Info { CreateTime = DateTime.Now, Detail = Request.Params["xq"], EndTime = DateTime.Parse(Request.Params["endtime"]), FromUserName = user, Goal = int.Parse(Request.Params["mb"]), NickName = sq.JDName, State = 0, PX = 0, RD = 0, JZType = Request.Params["jztype"] == "发起筹粮" ? 1 : 2, Title = Request.Params["bt"] }; if (pics.Length > 1) { j.Img1 = pics[0]; } if (pics.Length > 2) { j.Img2 = pics[1]; } if (pics.Length > 3) { j.Img3 = pics[2]; } if (pics.Length > 4) { j.Img4 = pics[3]; } if (pics.Length > 5) { j.Img5 = pics[4]; } if (pics.Length > 6) { j.Img6 = pics[5]; } if (pics.Length > 7) { j.Img7 = pics[6]; } if (pics.Length > 8) { j.Img8 = pics[7]; } if (pics2.Length > 1) { j.HeadImage = WebUrl + pics2[0]; } int id = nvbo.SaveJiuZhuInfo(j); //j.PX = 100 + id; //j.ID = id; //nvbo.SaveJiuZhuInfo(j); //if (j.JZType == 1) // nvbo.Save50Order(id); if (id > 0) { try { j.ID = id; Task.Factory.StartNew(new Action(() => { j.CImg = CutImage2(j.Img1, 1, j.CImg, true, false); //截一张长图,八张方图,一张logo j.SImg1 = CutImage2(j.Img1, 2, j.SImg1); j.SImg2 = CutImage2(j.Img2, 2, j.SImg2); j.SImg3 = CutImage2(j.Img3, 2, j.SImg3); j.SImg4 = CutImage2(j.Img4, 2, j.SImg4); j.SImg5 = CutImage2(j.Img5, 2, j.SImg5); j.SImg6 = CutImage2(j.Img6, 2, j.SImg6); j.SImg7 = CutImage2(j.Img7, 2, j.SImg7); j.SImg8 = CutImage2(j.Img8, 2, j.SImg8); string himg = CutImage2(j.HeadImage, 2, j.HeadImage, true, false); if (himg != j.HeadImage && himg != "") { j.HeadImage = WebUrl + himg; } nvbo.SaveJiuZhuInfo(j); string token = Token(mjuserid); var temp2 = new { first = new { value = "审核通知", color = "#173177" }, keyword1 = new { value = j.Title, color = "#173177" }, keyword2 = new { value = "审核中", color = "#173177" }, keyword3 = new { value = "审核中", color = "#173177" }, remark = new { value = "\n您提交的信息已进入审核,工作人员将会与您联系。", color = "#CD0000" } }; string message = SendTemplateMessage(token, j.FromUserName, "HRPL3i5IEKvWlHRm846Mf5y2bBJQ7iRv4ats-ZqbaE8", "#FF0000", temp2, WebUrl + "/wechat/order/chou.aspx"); })); } catch (Exception) { } Response.Write("{\"msg\":\"您的项目已经提交,我们会在1个工作日进行资料审核。\",\"st\":\"1\",\"url\":\"\"}"); Response.End(); } else { Response.Write("{\"msg\":\"失败\",\"st\":\"-1\",\"url\":\"\"}"); Response.End(); } } } } //else //{ // Response.Write(""); // Response.End(); //} }
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("]]>", ""); string openid = rootElement.SelectSingleNode("openid").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; order.FromUserName = openid; 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 { 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="******"o3L1MwYudOztZTDDA6yPIhWapZH4", "o3L1MwVjlBoenaSbN5FIXwzQmgNM","o3L1MwZ00yPDw1Ymsk_V4Por1ce4" }; //foreach (string o in op) //{ // var temp2 = new // { // first = new { value = "新订单提醒", color = "#173177" }, // OrderSn = new { value = order.OrderNo, color = "#173177" }, // OrderStatus = new { value = "已支付", color = "#173177" }, // remark = new { value = "\n" + order.GoodsName + "," + order.TotalPrice.ToString() + "元", color = "#CD0000" } // }; // message = SendTemplateMessage(token, o, "wY05AHjKkPAmyygWfzM0D1EWeGOrzCAZDI6c1jmGPGY", "#FF0000", temp2, WebUrl + "/wechat/test/tz.aspx?tousername="******"<xml> <return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> </xml>"); Response.End(); } } //WXLOG log = new WXLOG { CON = postStr + "weixin", TIME = DateTime.Now }; //mss.SaveLog(log); } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["oid"] != null) { string[] oids = Request.QueryString["oid"].Split(','); if (oids.Length > 2) { order = nvbo.GetOrder(int.Parse(oids[0])); if (order != null) { if (order.OrderNo == oids[2]) { if (order.CreateTime.Value.AddMinutes(10) > DateTime.Now)//十分钟之内 { o = mss.GetOA(order.FromUserName); jz = nvbo.GetJiuZhuInfo(order.Source.Value); } else { Response.Redirect("chou.aspx?p=" + oids[1]); //Response.Write("<h1>本页面已过期,感谢您的支持!</h1>"); //Response.End(); } } else { Response.Write("<h1>感谢您的支持!</h1>"); Response.End(); } } else { Response.Write("<h1>感谢您的支持!</h1>"); Response.End(); } } else { Response.Write("<h1>感谢您的支持!</h1>"); Response.End(); } } else if (Request.QueryString["para"] != null) { order = nvbo.GetOrder(int.Parse(Request.Params["oid"])); if (order != null) { if (order.OrderNo == Request.Params["orderno"]) { if (order.CreateTime.Value.AddMinutes(30) > DateTime.Now)//十分钟之内 { order.CourierRemark = Request.Params["remark"]; nvbo.SaveOrder(order); Response.Write("{\"st\":0,\"msg\":\"提交成功\"}"); Response.End(); } else { Response.Write("{\"st\":1,\"msg\":\"本页面已过期\"}"); Response.End(); } } else { Response.Write("{\"st\":1,\"msg\":\"提交成功\"}"); Response.End(); } } } else { Response.Write("<h1>感谢您的支持!</h1>"); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { string postStr = ""; //else //{ //WXLOG log = new WXLOG { CON = Request.Params[""] + "INDEX2", TIME = DateTime.Now }; //mss.SaveLog(log); if (Request.Params["out_trade_no"] != null && Request.Params["trade_status"] != null) { if (Request.Params["trade_status"] == "TRADE_SUCCESS") { Pet_XXL_Order order = nvbo.GetPetXXLOrder(Request.Params["out_trade_no"]); 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 = ""; order.OutOrderNo = Request.Params["trade_no"]; if (Request.Params["buyer_logon_id"] != null) { order.buyer_logon_id = Request.Params["buyer_logon_id"]; } else if (Request.Params["buyer_email"] != null) { order.buyer_logon_id = Request.Params["buyer_email"]; } nvbo.SavePetXXLOrder(order); 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 { 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="******"o3L1MwYudOztZTDDA6yPIhWapZH4", "o3L1MwVjlBoenaSbN5FIXwzQmgNM", "o3L1MwZ00yPDw1Ymsk_V4Por1ce4" }; //foreach (string o in op) //{ // var temp2 = new // { // first = new { value = "新订单提醒", color = "#173177" }, // OrderSn = new { value = order.OrderNo, color = "#173177" }, // OrderStatus = new { value = "已支付", color = "#173177" }, // remark = new { value = "\n" + order.GoodsName + "," + order.TotalPrice.ToString() + "元", color = "#CD0000" } // }; // message = SendTemplateMessage(token, o, "wY05AHjKkPAmyygWfzM0D1EWeGOrzCAZDI6c1jmGPGY", "#FF0000", temp2, WebUrl + "/wechat/test/tz.aspx?tousername="******"success"); Response.End(); } } } //WXLOG log2 = new WXLOG { CON = Request.Params.AllKeys + "zhifubao", TIME = DateTime.Now }; //mss.SaveLog(log2); //string cs = ""; //for (int i = 0; i < Request.Form.Count; i++) //{ // if (Request.Form.Keys[i].ToString().Substring(0, 1) != "_") // cs += Request.Form.Keys[i].ToString() + " = " + Request.Form[i].ToString()+"&"; //} //WXLOG log3 = new WXLOG { CON = cs + "zhifubao", TIME = DateTime.Now }; //mss.SaveLog(log3); //} }