public int tuwen_recordid = 0; //图文消息id protected void Page_Load(object sender, EventArgs e) { tuwen_recordid = Request["tuwen_recordid"].ConvertTo <int>(0); if (UserHelper.ValidateLogin()) { int comid = UserHelper.CurrentCompany.ID; WeiXinBasic wxbasic = new WeiXinBasicData().GetWxBasicByComId(comid); if (wxbasic != null) { if (wxbasic.Weixintype == 4) { isrenzheng = 1; } else { isrenzheng = 0; } } else { isrenzheng = 0; } } else { Response.Redirect("/Manage/index1.html"); } }
private string GetOpenId_2(string codee, int comid) { WeiXinBasic basicc = new WeiXinBasicData().GetWxBasicByComId(comid); string openid = ""; if (basicc != null) { string st = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + basicc.AppId + "&secret=" + basicc.AppSecret + "&code=" + codee + "&grant_type=authorization_code"; XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + new GetUrlData().HttpGet(st) + "}"); try { XmlElement rootElement = doc.DocumentElement; openid = rootElement.SelectSingleNode("openid").InnerText; return(openid); } catch { return(""); } } else { return(""); } }
private void GetOpenId(string codee, int comid) { WeiXinBasic basicc = new WeiXinBasicData().GetWxBasicByComId(comid); if (basicc != null) { string st = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + basicc.AppId + "&secret=" + basicc.AppSecret + "&code=" + codee + "&grant_type=authorization_code"; XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + new GetUrlData().HttpGet(st) + "}"); XmlElement rootElement = doc.DocumentElement; string openid = rootElement.SelectSingleNode("openid").InnerText; //根据微信号获取用户信息,使用户处于登录状态 string data = new B2bCrmData().GetB2bCrm(openid, comid, out userinfo); if (data == "OK") { HttpCookie cookie = new HttpCookie("AccountId"); //实例化HttpCookie类并添加值 cookie.Value = userinfo.Id.ToString(); cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); var returnmd5 = EncryptionHelper.ToMD5(userinfo.Idcard.ToString() + userinfo.Id.ToString(), "UTF-8"); cookie = new HttpCookie("AccountKey"); //实例化HttpCookie类并添加值 cookie.Value = returnmd5; cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); cookie = new HttpCookie("openid"); //实例化HttpCookie类并添加值 cookie.Value = openid; cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); } } }
protected void Page_Load(object sender, EventArgs e) { if (UserHelper.ValidateLogin()) { B2b_company company = UserHelper.CurrentCompany; //判断是否进行过微信接口设置,没有设置过进入微信接口设置页面 WeiXinBasic b = new WeiXinBasicData().GetWxBasicByComId(company.ID); if (b == null) { Response.Redirect("/weixin/ShangJiaSet2.aspx"); } //显示菜单列表 int pageindex = 1; int pagesize = 10; int comid = company.ID; GetMenuList(pageindex, pagesize, comid);//获得微信菜单 } else { Response.Redirect("/Manage/index1.html"); } }
public string gongsilogo = ""; //公司logo protected void Page_Load(object sender, EventArgs e) { string u = Request.ServerVariables["HTTP_USER_AGENT"]; bool bo = detectmobilebrowser.HttpUserAgent(u);//判断是否是手机访问 string RequestUrl = HttpContext.Current.Request.ServerVariables["SERVER_NAME"].Trim().ToLower(); #region 如果符合shop101.etown.cn的格式,根据微信配置信息获得公司信息(基本信息和扩展信息) if (Domain_def.Domain_yanzheng(RequestUrl)) { WeiXinBasic wxbasic = new WeiXinBasicData().GetWeiXinBasicByDomain(RequestUrl); #region 如果配置了微信接口信息,获得公司信息 if (wxbasic != null) { int comid = wxbasic.Comid; cominfo = B2bCompanyData.GetAllComMsg(comid); //判断访问路径来源:1.微信认证商家直接点击自定义菜单链接过来,微信端传递过来code ; string weixincode = Request["code"].ConvertTo <string>(""); if (weixincode != "") { if (cominfo != null) { GetOpenId(weixincode, cominfo.ID); GetComLogo(cominfo.ID); } } //2.微信未认证商家点击链接过来,传递过来openid和一次性密码(a.正确的openid和一次性密码,则实现会员登录和获得会员信息所在公司信息;b.一次性密码错误或者没有传递则 通过客户端保存数据获得用户信息) string openid = Request["openid"].ConvertTo <string>(""); string weixinpass = Request["weixinpass"].ConvertTo <string>(""); if (openid != "") { if (cominfo != null) { VerifyOneOffPass(openid, weixinpass, cominfo.ID); GetComLogo(cominfo.ID); } } } #endregion #region 如果没有配置微信接口信息,不处理 else { } #endregion } #endregion #region 如果不符合shop101.etown.cn的格式,不处理 else { } #endregion }
protected void Page_Load(object sender, EventArgs e) { //string entrystr = CreateSign(param, SERCERT); //Label1.Text = entrystr; //string s = new GetUrlData().HttpPost("http://test.etown.cn/taobao_ms/notice.ashx", "consume_type=0&encrypt_mobile=135****1292&item_title=测 shi用&md5_mobile=6822345AB56EF852B8642667C00BDB2D&method=send&num=1&num_iid=45314406703&order_id=962887495594762&seller_nick=快乐票务&send_type=2&sign=AF6853A9CB546199D2C8511A19C3C6C7&sku_properties=门票种类:成人票;门票类型:电子票&sms_template=验证码$code.您已成功订购快乐票务提供的测 shi用,有效期2015/06/10至2015/06/10,消费时请出示本短信以验证.如有疑问,请联系卖家.&sub_method=1&sub_outer_iid=5100&taobao_sid=51061508×tamp=2015-06-10 10:56:08&token=bfbcff3b07ede0e9e3aef0f5e7570594&type=1&valid_ends=2015-06-10 23:59:59&valid_start=2015-06-10 00:00:00&weeks=[1,2,3,4,5,6,7]"); //var orderdata = OrderJsonData.insertyuohuiquan(4495, "osaHEjsHg4_hZUHVHPvT4aRUV67M"); //测试 分销订单 //int orderid = 0; //string data = OrderJsonData.AgentOrder(11, "1078", "1", "3", "test", "13488761102", "2015-5-12", "etowncs", 0, out orderid, 0,1, "", "", "", 0, "", "", "", "", 0,0,0,1); // string RequestDomin = "shop106.etown.cn"; // string Requestfile = System.Web.HttpContext.Current.Request.ServerVariables["Url"].ToLower(); //根据访问的域名获得公司信息 // WeiXinBasic basicc = new WeiXinBasicData().GetWeiXinBasicByDomain(RequestDomin); // 微信端模板消息发送测试 //new Weixin_tmplmsgManage().WxTmplMsg_OrderNewCreate(21736); ////2时间差测试 //TimeSpan ts = DateTime.Parse("2014-08-05 20:20:20") - DateTime.Parse("2014-08-03 20:20:20"); //Label1.Text = ts.TotalSeconds.ToString(); ////3微信端接收消息测试 WeiXinBasic basic = new WeiXinBasicData().GetWxBasicByComId(2571); string postStr = "<xml>" + "<ToUserName><![CDATA[gh_d1adc6b97854]]></ToUserName>" + "<FromUserName><![CDATA[o3XEUwpl8H0NeDkxwARaxuNllgi4]]></FromUserName> " + "<CreateTime>" + new WeiXinManage().ConvertDateTimeInt(DateTime.Now) + "</CreateTime>" + "<MsgType><![CDATA[text]]></MsgType>" + "<Content><![CDATA[123132123132312313212313123]]></Content>" + "<MsgId>1234567890123456</MsgId>" + "</xml>"; //string postStr = "<xml><ToUserName><![CDATA[gh_262af05c61ba]]></ToUserName>" + // "<FromUserName><![CDATA[osaHEjsHg4_hZUHVHPvT4aRUV67M]]></FromUserName>" + // "<CreateTime>" + new WeiXinManage().ConvertDateTimeInt(DateTime.Now) + "</CreateTime>" + // "<MsgType><![CDATA[event]]></MsgType>" + // "<Event><![CDATA[scancode_push]]></Event>" + // "<EventKey><![CDATA[1375]]></EventKey>" + // "<ScanCodeInfo><ScanType><![CDATA[qrcode]]></ScanType>" + // "<ScanResult><![CDATA[1]]></ScanResult>" + // "</ScanCodeInfo>" + // "</xml>"; new WeiXinManage().Handle(postStr, basic); //查询支付,并修改为支付成功 //basicc.Weixintype = 4; //int order_no = 0; //string retunstr = new PayReturnSendEticketData().PayReturnSendEticket("1006800634201505130128130325", order_no, 0, "TRADE_SUCCESS1"); //var testweixin = new WeiXinManage(); //var test = testweixin.WeixinMessageChannel(0, 106, "osaHEjoMhcIIjzUjcbCl0O8BhpDI", "test", 1, "", basicc); //var retmessage = WeixinMessageChannel(0, basic.Comid, requestXML.FromUserName, requestXML.Content, 1, "", basic); }
protected void Page_Load(object sender, EventArgs e) { userweixin = Request["userweixin"].ConvertTo <string>(""); guwenweixin = Request["guwenweixin"].ConvertTo <string>(""); if (Domain_def.Domain_yanzheng(RequestUrl))//如果符合shop101.etown.cn的格式,则从多微信商户基本信息表中获取comid { //先通过正则表达式获取COMid comid = Int32.Parse(Domain_def.Domain_Huoqu(RequestUrl).ToString()); } if (comid == 0)//如果非标准格式,查询 是否有绑定的域名 { var domaincomid = B2bCompanyData.GetComId(RequestUrl); if (domaincomid != null) { comid = domaincomid.Com_id; } } #region 微信语音播放接口会用到 string url = Request.Url.ToString(); //根据传入参数openid、comid 得到 access_token、jsapi_ticket、noncestr、timestamp、 url(当前网页的URL,不包含#及其后面部分) WeiXinBasic basic = new WeiXinBasicData().GetWxBasicByComId(comid); if (basic != null) { appId = basic.AppId; timestamp = new WeixinVoiceUtil().CreatenTimestamp(); nonceStr = new WeixinVoiceUtil().CreatenNonce_str(); WXAccessToken maccesstoken = new WeixinVoiceUtil().GetAccessToken(comid, basic.AppId, basic.AppSecret); if (maccesstoken != null) { string jsapi_ticket = new WeixinVoiceUtil().GetTickect(maccesstoken.ACCESS_TOKEN, comid); if (jsapi_ticket == "") { isrightwxset = 0; } else { string beforesha1_signature = ""; signature = new WeixinVoiceUtil().GetSignature(jsapi_ticket, nonceStr, timestamp, url, out beforesha1_signature); } } else { isrightwxset = 0; } } else { isrightwxset = 0; } #endregion }
public int isrightwxset = 1; //微信接口设置信息是否正确 protected void Page_Load(object sender, EventArgs e) { openid = Request["openid"].ConvertTo <string>(""); uid = Request["uid"].ConvertTo <int>(0); weixinpass = Request["weixinpass"].ConvertTo <string>(""); comid = Request["comid"].ConvertTo <int>(0); clientuptypemark = Request["clienttypemark"].ConvertTo <int>(0); #region 微信语音播放接口会用到 string url = Request.Url.ToString(); //根据传入参数openid、comid 得到 access_token、jsapi_ticket、noncestr、timestamp、 url(当前网页的URL,不包含#及其后面部分) WeiXinBasic basic = new WeiXinBasicData().GetWxBasicByComId(comid); if (basic != null) { appId = basic.AppId; timestamp = new WeixinVoiceUtil().CreatenTimestamp(); nonceStr = new WeixinVoiceUtil().CreatenNonce_str(); WXAccessToken maccesstoken = new WeixinVoiceUtil().GetAccessToken(comid, basic.AppId, basic.AppSecret); if (maccesstoken != null) { string jsapi_ticket = new WeixinVoiceUtil().GetTickect(maccesstoken.ACCESS_TOKEN, comid); if (jsapi_ticket == "") { isrightwxset = 0; } else { string beforesha1_signature = ""; signature = new WeixinVoiceUtil().GetSignature(jsapi_ticket, nonceStr, timestamp, url, out beforesha1_signature); } } else { isrightwxset = 0; } } else { isrightwxset = 0; } #endregion #region 注释掉 //string str = "260,110"; //int strnum = str.IndexOf(',', 0); //string a = str.Substring(0, strnum); //int d = str.Length; //string b = str; //string f = str.Substring(strnum+1, str.Length-strnum); //string c = a + b; #endregion }
protected void Button1_Click(object sender, EventArgs e) { initJavascript(); //根据公司id得到开发者凭据 WeiXinBasic basicc = new WeiXinBasicData().GetWxBasicByComId(comid); if (basicc != null) { //获取凭证(首先判断数据库是否存在凭证以及是否过期,如过期,重新获取) WXAccessToken token = GetAccessToken(comid, basicc.AppId, basicc.AppSecret); //获得以前总共抓取关注者列表的次数 int MaxOtainNo = new ObtainGzListLogData().GetMaxObtainNo(comid); //计算需要向微信端发送请求次数 int weixintotal = AskWeixinTotal(token.ACCESS_TOKEN);//获得关注微信用户总数目 if (weixintotal == 0) { Literal1.Text = "获得关注微信用户总数目出错"; return; } int askno = int.Parse(Math.Ceiling((double)weixintotal / (double)10000).ToString()); for (int i = 0; i < askno; i++) { if (i == 0)//第一次请求,发送无参数next_openid { AskWeixin(token.ACCESS_TOKEN, "", MaxOtainNo + 1); } else //第一次以后请求,发送带参数next_openid { string next_openid = new ObtainGzListLogData().GetNextOpenId(comid, MaxOtainNo + 1); if (next_openid != "") { AskWeixin(token.ACCESS_TOKEN, next_openid, MaxOtainNo + 1); } } } //BindGrid(comid, MaxOtainNo + 1); UnloadJavascript(); Literal1.Text = "共获取微信关注用户数量:" + weixintotal; } else { UnloadJavascript(); Literal1.Text = "公司开发者凭据获取有误"; } }
public string httphead = "http://";//由于苹果手机微信链接 没有http:// 不识别,所以需要添加 protected void Page_Load(object sender, EventArgs e) { WeiXinManage _wx = new WeiXinManage(); //string postStr = "<xml><ToUserName><![CDATA[toUser]]></ToUserName>" + // "<FromUserName><![CDATA[FromUser]]></FromUserName>" + // "<CreateTime>123456789</CreateTime>" + // "<MsgType><![CDATA[event]]></MsgType>" + // "<Event><![CDATA[CLICK]]></Event>" + // "<EventKey><![CDATA[V_OPENCARD]]></EventKey>" + // "</xml>"; //_wx.Handle(postStr); //获取访问的域名 string RequestDomin = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToLower(); string Requestfile = System.Web.HttpContext.Current.Request.ServerVariables["Url"].ToLower(); //根据访问的域名获得公司信息 WeiXinBasic basicc = new WeiXinBasicData().GetWeiXinBasicByDomain(RequestDomin); 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); if (!string.IsNullOrEmpty(postStr)) //请求处理 { _wx.Handle(postStr, basicc); Handle(postStr, basicc); } } else { _wx.Auth(basicc); } }
public string token = ""; //公司token 16个随机字母+数字 protected void Page_Load(object sender, EventArgs e) { int comid = UserHelper.CurrentCompany.ID; //微信接口设置信息:没有设置过,直接把商家接收微信请求地址url和token直接录入数据库 WeiXinBasic b = new WeiXinBasicData().GetWxBasicByComId(comid); if (b == null) { url = "http://shop" + comid + ".etown.cn/weixin/index.aspx"; domain = "shop" + comid + ".etown.cn"; token = RandomHelper.RandCode(20); int r = new WeiXinBasicData().Editwxbasicstep1(0, 0, comid, domain, url, token); } }
protected void Page_Load(object sender, EventArgs e) { if (UserHelper.ValidateLogin()) { B2b_company company = UserHelper.CurrentCompany; comid = company.ID; } //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "001"); #region 微信扫描二维码,都用易城微信号的 comid = 106; string url = Request.Url.ToString(); //根据传入参数openid、comid 得到 access_token、jsapi_ticket、noncestr、timestamp、 url(当前网页的URL,不包含#及其后面部分) WeiXinBasic basic = new WeiXinBasicData().GetWxBasicByComId(comid); if (basic != null) { appId = basic.AppId; timestamp = new WeixinVoiceUtil().CreatenTimestamp(); nonceStr = new WeixinVoiceUtil().CreatenNonce_str(); WXAccessToken maccesstoken = new WeixinVoiceUtil().GetAccessToken(comid, basic.AppId, basic.AppSecret); if (maccesstoken != null) { string jsapi_ticket = new WeixinVoiceUtil().GetTickect(maccesstoken.ACCESS_TOKEN, comid); if (jsapi_ticket == "") { isrightwxset = 0; } else { string beforesha1_signature = ""; signature = new WeixinVoiceUtil().GetSignature(jsapi_ticket, nonceStr, timestamp, url, out beforesha1_signature); } } else { isrightwxset = 0; } } else { isrightwxset = 0; } #endregion }
public int isrenzheng = 1;//1已认证;0未认证 protected void Page_Load(object sender, EventArgs e) { int userid = UserHelper.CurrentUserId(); IsParentCompanyUser = new B2bCompanyManagerUserData().IsParentCompanyUser(userid); ObtainGzListSplit lastSplit = new ObtainGzListSplitData().LastSplitNoByComid(comid);//最后一次拆分记录 if (lastSplit != null) { BindGrid2(comid, lastSplit.Splitno, lastSplit.Obtainno); } if (UserHelper.ValidateLogin()) { int comidd = UserHelper.CurrentCompany.ID; WeiXinBasic wxbasic = new WeiXinBasicData().GetWxBasicByComId(comidd); if (wxbasic != null) { if (wxbasic.Weixintype == 4) { isrenzheng = 1; } else { isrenzheng = 0; } } else { isrenzheng = 0; } } else { Response.Redirect("/Manage/index1.html"); } }
public int isrenzheng = 1; //1已认证;0未认证 protected void Page_Load(object sender, EventArgs e) { isqudao = Request["isqudao"].ConvertTo <string>("2"); isrun = Request["isrun"].ConvertTo <string>("0,1"); if (!IsPostBack) { hid_key.Value = ""; GridView2.DataSource = GetAllTerms(isqudao);//获得 渠道单位/活动 列表 GridView2.DataBind(); if (UserHelper.ValidateLogin()) { int comid = UserHelper.CurrentCompany.ID; WeiXinBasic wxbasic = new WeiXinBasicData().GetWxBasicByComId(comid); if (wxbasic != null) { if (wxbasic.Weixintype == 4) { isrenzheng = 1; } else { isrenzheng = 0; } } else { isrenzheng = 0; } } else { Response.Redirect("/Manage/index1.html"); } } }
private void GetOpenId(ref int comid) { //完整url、域名、参数 string urlstr = Request.Url.ToString(); string hoststr = HttpContext.Current.Request.Url.Host; string paramstr = HttpContext.Current.Request.Url.Query; //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "urlstr:" + urlstr + "\r\n----------------------------------------\r\n" + "hoststr:" + hoststr + "\r\n----------------------------------------\r\n" + "paramstr:" + paramstr); //根据域名获取comid comid = int.Parse(Regex.Match(hoststr, "\\d{1,}").ToString()); if (comid == 0) { return; } //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "Cookiehelp.GetCookie(openid):" + Cookiehelp.GetCookie("openid")); //判断openid是否存在于cookie中 if (Cookiehelp.GetCookie("openid") != "") { Openid = Cookiehelp.GetCookie("openid"); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "openid:" + Openid); } else { //判断code值是否存在,存在获取openid,并且保存到cookie中; if (Request["code"].ConvertTo <string>("") != "") { string code = Request["code"]; //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "code:" + code); WeiXinBasic basic = new WeiXinBasicData().GetWxBasicByComId(comid); if (basic == null) { return; } //必须为认证服务号才含有网页授权获取用户openid的权限 if (basic.Weixintype == 4) { string requrl = string.Format( "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code", basic.AppId, basic.AppSecret, code); string returnStr = HttpUtil.Send("", requrl); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "returnStr:" + returnStr); var obj = JsonConvert.DeserializeObject <ModelOpenID>(returnStr); Openid = obj.openid; //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "获取的openid:" + Openid); //向cookie添加值 Cookiehelp.WriteCookie("openid", Openid, DateTime.Now.AddDays(30)); } } else //code值不存在,把域名、完整网址、参数部分 保存到数据库 请求网址记录表ReqUrl_Log,返回标识列值Mid; { ReqUrl_Log requrllog = new ReqUrl_Log { mid = 0, urlstr = urlstr, hoststr = hoststr, paramstr = paramstr, subtime = DateTime.Now }; int mid = new ReqUrl_LogHelper().InsReqUrlLog(requrllog); WeiXinBasic basic = new WeiXinBasicData().GetWxBasicByComId(comid); if (basic == null) { return; } //必须为认证服务号才含有网页授权获取用户openid的权限 if (basic.Weixintype == 4) { string redirect_url = urlstr.Replace(".aspx" + paramstr, "_wx_" + mid + ".aspx"); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "redirect_url:" + redirect_url); scopeurl = WeiXinJsonData.GetFollowOpenLinkUrl(comid, redirect_url); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "scopeurl:" + scopeurl); } } } }
public static string SendWxMsg(int comid, string tousername, int type, string img, string txt, string mediaid, string fromusername) { //B2b_company_manageuser manageuser = UserHelper.CurrentUser();//客服信息(账户表B2b_company_manageuser) B2b_crm crm = new B2bCrmData().GetB2bCrmByWeiXin(tousername); if (crm == null) { return(JsonConvert.SerializeObject(new { type = 1, msg = "发送客服消息失败" })); } //else //{ // if (crm.Whetherwxfocus == false) // { // return JsonConvert.SerializeObject(new { type = 1, msg = "微信用户已经取消了关注" }); // } //} WeiXinBasic basicc = new WeiXinBasicData().GetWxBasicByComId(comid); if (basicc != null) { //获取凭证(首先判断数据库是否存在凭证以及是否过期,如过期,重新获取) WXAccessToken token = WeiXinManage.GetAccessToken(comid, basicc.AppId, basicc.AppSecret); //发送文本信息 string err = "";//返回错误原因 string createmenuurl = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + token.ACCESS_TOKEN; string createmenutext1 = ""; //微信菜单内容 if (type == 1) //文本 { createmenutext1 = "{\"touser\":\"" + tousername + "\", \"msgtype\":\"text\",\"text\":{\"content\":\"" + txt + "\"}}"; } if (type == 2)//语音 { if (mediaid != "") { createmenutext1 = "{\"touser\":\"" + tousername + "\", \"msgtype\":\"voice\",\"voice\":{\"media_id\":\"" + mediaid + "\"}}"; } else { return(JsonConvert.SerializeObject(new { type = 1, msg = "语音mediaid不可为空" })); } } if (type == 3)//图片 { if (mediaid != "") { createmenutext1 = "{\"touser\":\"" + tousername + "\", \"msgtype\":\"image\",\"image\":{\"media_id\":\"" + mediaid + "\"}}"; } else { return(JsonConvert.SerializeObject(new { type = 1, msg = "图片mediaid不可为空" })); } } if (err.Length > 0) { return(JsonConvert.SerializeObject(new { type = 1, msg = err })); } else { string createmenuutret = new GetUrlData().HttpPost(createmenuurl, createmenutext1); XmlDocument createselfmenudoc = (XmlDocument)JsonConvert.DeserializeXmlNode("{\"root\":" + createmenuutret + "}"); XmlElement createselfmenurootElement = createselfmenudoc.DocumentElement; string createerrcode = createselfmenurootElement.SelectSingleNode("errcode").InnerText; if (createerrcode != "0") { //短信提示 ,查询会员账户,并检测是否今天发送过短信,如果发送过就不发送了,每天发送一次 var crmdata = new B2bCrmData(); var crminfo = crmdata.b2b_crmH5(tousername, comid); if (crminfo != null) { if (crminfo.Phone != "") { var smstixing = new WxRequestXmlData().GetWxErr_sms_SendMsgList(comid, crminfo.Phone); if (smstixing == 0) { var smstixinginsert = new WxRequestXmlData().InsertWxErr_sms_SendMsgList(comid, crminfo.Phone); if (smstixinginsert != 0) { var cominfo = B2bCompanyData.GetCompany(comid); string comname = ""; string weixincom = ""; if (cominfo != null) { comname = cominfo.Com_name; weixincom = cominfo.B2bcompanyinfo.Weixinname; } ////发送短信 //var smsmsg = ""; //var smssendback = SendSmsHelper.SendSms(crminfo.Phone, "有一条给您发送微信消息接收失败 请关注" + comname + "微信账户: " + weixincom + " ,输入“我的消息”获取消息内容!", comid, out smsmsg); } } } } //发送客服信息,信息内容录入数据库 if (type == 1)//文本 { RequestXML retRequestXML = new RequestXML(); retRequestXML.PostStr = createmenutext1; retRequestXML.ToUserName = tousername; //retRequestXML.FromUserName = new WeiXinBasicData().GetWxBasicByComId(comid).Weixinno.ConvertTo<string>(""); retRequestXML.FromUserName = fromusername; retRequestXML.CreateTime = ConvertDateTimeInt(DateTime.Now).ToString(); retRequestXML.MsgType = "text"; retRequestXML.Content = txt; retRequestXML.contentType = false; retRequestXML.Comid = comid; retRequestXML.Sendstate = 0;//发送状态为 未发送 int inswxexchangemsg = new WxRequestXmlData().EditWxRequestXmlLog(retRequestXML); } //发送客服信息,信息内容录入数据库 if (type == 2)//语音 { RequestXML retRequestXML = new RequestXML(); retRequestXML.PostStr = createmenutext1; retRequestXML.ToUserName = tousername; //retRequestXML.FromUserName = new WeiXinBasicData().GetWxBasicByComId(comid).Weixinno.ConvertTo<string>(""); retRequestXML.FromUserName = fromusername; retRequestXML.CreateTime = ConvertDateTimeInt(DateTime.Now).ToString(); retRequestXML.MsgType = "voice"; retRequestXML.Recognition = txt; retRequestXML.contentType = false; retRequestXML.Comid = comid; retRequestXML.MediaId = mediaid; retRequestXML.Sendstate = 0;//发送状态为 未发送 int inswxexchangemsg = new WxRequestXmlData().EditWxRequestXmlLog(retRequestXML); } if (type == 3)//图片 { RequestXML retRequestXML = new RequestXML(); retRequestXML.PostStr = createmenutext1; retRequestXML.ToUserName = tousername; //retRequestXML.FromUserName = new WeiXinBasicData().GetWxBasicByComId(comid).Weixinno.ConvertTo<string>(""); retRequestXML.FromUserName = fromusername; retRequestXML.CreateTime = ConvertDateTimeInt(DateTime.Now).ToString(); retRequestXML.MsgType = "image"; retRequestXML.PicUrl = img; retRequestXML.contentType = false; retRequestXML.Comid = comid; retRequestXML.Sendstate = 0;//发送状态为 未发送 int inswxexchangemsg = new WxRequestXmlData().EditWxRequestXmlLog(retRequestXML); } return(JsonConvert.SerializeObject(new { type = 1, msg = "回复客服信息失败" + createerrcode })); } else { //发送客服信息,信息内容录入数据库 if (type == 1)//文本 { RequestXML retRequestXML = new RequestXML(); retRequestXML.PostStr = createmenutext1; retRequestXML.ToUserName = tousername; //retRequestXML.FromUserName = new WeiXinBasicData().GetWxBasicByComId(comid).Weixinno.ConvertTo<string>(""); retRequestXML.FromUserName = fromusername; retRequestXML.CreateTime = ConvertDateTimeInt(DateTime.Now).ToString(); retRequestXML.MsgType = "text"; retRequestXML.Content = txt; retRequestXML.contentType = false; retRequestXML.Comid = comid; retRequestXML.Sendstate = 1;//发送状态为 未发送 //retRequestXML.Manageuserid = manageuser.Id; //retRequestXML.Manageusername = manageuser.Accounts; int inswxexchangemsg = new WxRequestXmlData().EditWxRequestXmlLog(retRequestXML); } //发送客服信息,信息内容录入数据库 if (type == 2)//语音 { RequestXML retRequestXML = new RequestXML(); retRequestXML.PostStr = createmenutext1; retRequestXML.ToUserName = tousername; //retRequestXML.FromUserName = new WeiXinBasicData().GetWxBasicByComId(comid).Weixinno.ConvertTo<string>(""); retRequestXML.FromUserName = fromusername; retRequestXML.CreateTime = ConvertDateTimeInt(DateTime.Now).ToString(); retRequestXML.MsgType = "voice"; retRequestXML.Recognition = txt; retRequestXML.contentType = false; retRequestXML.Comid = comid; retRequestXML.MediaId = mediaid; retRequestXML.Sendstate = 1;//发送状态为 未发送 //retRequestXML.Manageuserid = manageuser.Id; //retRequestXML.Manageusername = manageuser.Accounts; int inswxexchangemsg = new WxRequestXmlData().EditWxRequestXmlLog(retRequestXML); } if (type == 3)//图片 { RequestXML retRequestXML = new RequestXML(); retRequestXML.PostStr = createmenutext1; retRequestXML.ToUserName = tousername; //retRequestXML.FromUserName = new WeiXinBasicData().GetWxBasicByComId(comid).Weixinno.ConvertTo<string>(""); retRequestXML.FromUserName = fromusername; retRequestXML.CreateTime = ConvertDateTimeInt(DateTime.Now).ToString(); retRequestXML.MsgType = "image"; retRequestXML.PicUrl = img; retRequestXML.contentType = false; retRequestXML.Comid = comid; retRequestXML.Sendstate = 1;//发送状态为 未发送 //retRequestXML.Manageuserid = manageuser.Id; //retRequestXML.Manageusername = manageuser.Accounts; int inswxexchangemsg = new WxRequestXmlData().EditWxRequestXmlLog(retRequestXML); } return(JsonConvert.SerializeObject(new { type = 100, msg = "回复客服信息成功" })); } } } else { return(JsonConvert.SerializeObject(new { type = 1, msg = "" })); } }
protected void bt_upload_Click(object sender, EventArgs e) { try { if (FileUpload1.PostedFile.FileName == "") { this.lb_info.Text = "请选择文件!"; return; } else { string filepath = FileUpload1.PostedFile.FileName; if (!IsAllowedExtension(FileUpload1)) { this.lb_info.Text = "上传文件格式不正确,只支持jpg!"; } else { string filename = filepath.Substring(filepath.LastIndexOf("\\") + 1); string suffix = filename.Split('.')[1]; //获取上传文件的后缀 string newfilename = DateTime.Now.ToString("yyyyMMddhhmmss") + "." + suffix; //重命名上传文件 string Filepath = Server.MapPath("/WxGroupSendUploadFile/"); //设置上传文件的保存路径 if (!Directory.Exists(Filepath)) //判断路径是否存在 { Directory.CreateDirectory(Filepath); //如果不存在创建文件夹 } FileUpload1.PostedFile.SaveAs(Filepath + newfilename); WeiXinBasic basic = new WeiXinBasicData().GetWxBasicByComId(comid); WXAccessToken m_accesstoken = new Weixin_tmplmsgManage().GetAccessToken(basic.Comid, basic.AppId, basic.AppSecret); if (m_accesstoken == null) { Image1.ImageUrl = "/WxGroupSendUploadFile/" + newfilename; this.lb_info.Text = "上传图片成功,获取微信调用接口凭证失败!"; return; } string thumb_media_id = new WxUploadDownManage().UploadMultimedia(m_accesstoken.ACCESS_TOKEN, "image", Filepath + newfilename); if (thumb_media_id != null) { if (thumb_media_id == "") { this.lb_info.Text = "上传图片失败!"; } else { Image1.ImageUrl = "/WxGroupSendUploadFile/" + newfilename; hid_thumb_media_id.Value = thumb_media_id; this.lb_info.Text = "上传图片成功!"; } } else { this.lb_info.Text = "上传图片失败!"; } } } } catch (Exception ex) { this.lb_info.Text = "上传发生错误!原因:" + ex.ToString(); } }
public bool iswxsubscribenum = false; //是否是微信认证订阅号/订阅号 protected void Page_Load(object sender, EventArgs e) { string u = Request.ServerVariables["HTTP_USER_AGENT"]; bo = detectmobilebrowser.HttpUserAgent(u); proclass = Request["proclass"].ConvertTo <int>(0); projectid = Request["projectid"].ConvertTo <int>(0); //string u = Request.ServerVariables["HTTP_USER_AGENT"]; //bool bo = detectmobilebrowser.HttpUserAgent(u); id = Request["id"].ConvertTo <int>(0); num = Request["num"].ConvertTo <int>(1); nowdate = DateTime.Now.ToString("yyyy-MM-dd"); nowtoday = DateTime.Now; buyuid = Request["buyuid"].ConvertTo <int>(0); tocomid = Request["tocomid"].ConvertTo <int>(0); pno = Request["pno"].ConvertTo <string>(""); if (id != 0) { B2b_com_pro pro = new B2bComProData().GetProById(id.ToString()); if (pro != null) { isSetVisitDate = pro.isSetVisitDate; // 作废超时未支付订单,完成回滚操作 int rs = new B2bComProData().CancelOvertimeOrder(pro); if (pro.Source_type == 4) { iscanbook = 1; } else { iscanbook = new B2bComProData().IsYouxiao(pro.Id, pro.Server_type, pro.Pro_start, pro.Pro_end, pro.Pro_state);//判断产品是否有效:1.票务,直接判断有效期 和产品上线状态2.酒店,跟团游,当地游 则判断是否含有有效的房态/团期 以及产品上下线状态 } //判断微信 是否是认证服务号 WeiXinBasic mbasic = new WeiXinBasicData().GetWxBasicByComId(pro.Com_id); if (mbasic == null) { iswxsubscribenum = false; } else { if (mbasic.Weixintype == 1 || mbasic.Weixintype == 2) { iswxsubscribenum = true; } else { iswxsubscribenum = false; } } pro_servertype = pro.Server_type; pickuppoint = pro.pickuppoint; dropoffpoint = pro.dropoffpoint; childreduce = pro.Childreduce; imgurl = FileSerivce.GetImgUrl(pro.Imgurl); //实物产品必须进入 新商城页面订购 if (pro.Server_type == 11) { Response.Redirect("/h5/order/pro.aspx?id=" + id); } face_price = pro.Face_price; manyspeci = pro.Manyspeci; //如果多规格读取规格 if (manyspeci == 1) { gglist = new B2b_com_pro_SpeciData().Getgglist(pro.Id); } } if (pro.Ispanicbuy == 1) { panic_begintime = pro.Panic_begintime; panicbuy_endtime = pro.Panicbuy_endtime; TimeSpan tss = pro.Panic_begintime - nowtoday; var day = tss.Days * 24 * 3600;; //这是相差的天数 var h = tss.Hours * 3600; //这是相差的小时数, var m = tss.Minutes * 60; var s = tss.Seconds; shijiacha = day + h + m + s; } projectid = pro.Projectid; comid = pro.Com_id; pro_name = pro.Pro_name; price = pro.Advise_price.ToString(); if (price == "0.00" || price == "0") { price = "0"; } else { CommonFunc.OperTwoDecimal(price); //price = price.IndexOf(".") != -1 ? price.Substring(0, price.IndexOf(".")) : price; } nowdate = DateTime.Now.ToString("yyyy-MM-dd"); summary = "包含服务:" + pro.Service_Contain; sumaryend = summary; if (pro.Service_NotContain != "") { sumaryend += "</br> 不包含服务:" + pro.Service_NotContain + "</br>"; } if (pro.Precautions != "") { sumaryend += "注意事项:" + pro.Precautions; } //如果服务类型是 票务; 则备注信息中 显示 电子码使用限制 if (pro.Server_type == 1) { if (pro.Iscanuseonsameday == 0)//电子码当天不可用 { sumaryend = "此产品当天预订不可用<br>" + sumaryend; } if (pro.Iscanuseonsameday == 1)//电子码当天可用 { sumaryend = "此产品当天预订可用<br>" + sumaryend; } if (pro.Iscanuseonsameday == 2)//电子码出票2小时内不可用 { sumaryend = "此产品出票2小时内不可用<br>" + sumaryend; } } if (summary.Length > 30) { summary = summary.Substring(0, 30); } if (summary.Length > 150) { summary = summary.Substring(0, 150) + "..."; } remark = pro.Pro_Remark; pro_num = pro.Pro_number; if (pro_num == 0) { pro_max = 100; pro_min = 1; } else { pro_min = 1; pro_max = pro_num; } if (pno != "") { pro_max = 1; string pno1 = EncryptionHelper.EticketPnoDES(pno, 1);//解密 var prodata = new B2bEticketData(); var eticketinfo = prodata.GetEticketDetail(pno1); if (eticketinfo != null) { Use_pnum = eticketinfo.Use_pnum;//重新设定最大数 不能大于可以预定数量 bindingname = eticketinfo.bindingname; bindingphone = eticketinfo.bindingphone; bindingcard = eticketinfo.bindingcard; } //查询绑定状态 var busbindingdata = new Bus_FeeticketData(); var busbindinginfo = busbindingdata.Bus_Feeticket_proById(0, 0, id, pno1); if (busbindinginfo != null) { limitweek = busbindinginfo.limitweek; limitweekdaynum = busbindinginfo.limitweekdaynum; limitweekendnum = busbindinginfo.limitweekendnum; if (busbindinginfo.Busid != 0) { var busfeetticketinfo = busbindingdata.GetBus_FeeticketById(busbindinginfo.Busid, eticketinfo.Com_id); if (busfeetticketinfo != null) { Iuse = busfeetticketinfo.Iuse; } } } //如果不是限制个人使用 则 最大限购数不为 电子票剩余使用量 if (Iuse == 0) { pro_max = Use_pnum; } } if (pro.Server_type == 1) { pro_explain = pro.Pro_explain; } #region 产品有效期判定(微信模板--门票订单预订成功通知 中也有用到) provalidatemethod = pro.ProValidateMethod; //判断 1按产品有效期,2指定有效期 appointdate = pro.Appointdata; //1=一星期,,2=1个月,3=3个月,4=6个月,5=一年 iscanuseonsameday = pro.Iscanuseonsameday; //1当天可用,0当天不可用 DateTime pro_end = pro.Pro_end; //返回有效期 pro_youxiaoqi = new B2bComProData().GetPro_Youxiaoqi(pro.Pro_start, pro.Pro_end, provalidatemethod, appointdate, iscanuseonsameday); #endregion var commodel = B2bCompanyData.GetCompany(comid); if (commodel != null) { if (commodel.B2bcompanyinfo != null) { Wxfocus_url = commodel.B2bcompanyinfo.Wxfocus_url; Wxfocus_author = commodel.B2bcompanyinfo.Wxfocus_author; weixinname = commodel.B2bcompanyinfo.Weixinname; Scenic_intro = commodel.B2bcompanyinfo.Scenic_intro; } title = commodel.Com_name; } B2b_company_saleset procom = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (procom != null) { comlogo = FileSerivce.GetImgUrl(procom.Smalllogo.ConvertTo <int>(0)); logoimg = comlogo; } var saleset = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (saleset != null) { phone = saleset.Service_Phone; } //查询项目电话,如果有项目电话调取项目电话 var projectdata = new B2b_com_projectData(); var projectmodel = projectdata.GetProject(projectid, comid); if (projectmodel != null) { if (projectmodel.Mobile != "") { phone = projectmodel.Mobile; } } //从cookie中得到微信号 if (Request.Cookies["openid"] != null) { openid = Request.Cookies["openid"].Value; } B2bCrmData b2b_crm = new B2bCrmData(); if (openid != "") { B2b_crm b2bmodle = b2b_crm.b2b_crmH5(openid, comid); if (b2bmodle != null) { Imprest = b2bmodle.Imprest; Integral = b2bmodle.Integral; } } } }
public int isSetVisitDate = 0; //是否指定日期使用 public void Page_Load(object sender, EventArgs e) { string u = Request.ServerVariables["HTTP_USER_AGENT"]; bo = detectmobilebrowser.HttpUserAgent(u); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "Request.Url:" + Request.Url.ToString()); id = Request["id"].ConvertTo <string>(""); string temp_id = Request["id"].ConvertTo <string>(""); string temp_id_speciid = "0"; if (id.Contains("_"))//检验是否为购物车订单 { cart = 1; var id_arr = id.Replace('_', ','); //如果包含规格产品 var prospeciid = new B2bOrderData().SearchCartListBycartid(id_arr); if (prospeciid != null) { if (prospeciid.Count == 0) { //没有此购物车,跳转购物车重新选择产品 Response.Redirect("/h5/order/cart.aspx"); } id = ""; for (int i = 0; i < prospeciid.Count; i++) { id += prospeciid[i].Id + ","; id_speciid += prospeciid[i].Speciid + ","; temp_id = prospeciid[i].Id.ToString(); pro_id = temp_id; temp_id_speciid = prospeciid[i].Speciid.ToString(); } } else { //没有此购物车,跳转购物车重新选择产品 Response.Redirect("/h5/order/cart.aspx"); } } else { if (id.Contains("g"))//检验是否带规格 { var id_arr = id.Split('g'); id = id_arr[0]; //只针对直销单产品顶哦故 if (id_arr[1].Contains("s")) { var ids_arr = id_arr[1].Split('s'); id_speciid = ids_arr[0]; temp_id_speciid = ids_arr[0]; serverid = ids_arr[1]; serverid = serverid.Replace("A", ","); } else { id_speciid = id_arr[1]; temp_id_speciid = id_arr[1]; } temp_id = id_arr[0]; pro_id = id_arr[0]; } } //对规格默认赋值为0 if (temp_id_speciid == "") { temp_id_speciid = "0"; } if (Request.Cookies["temp_userid"] != null) { userid = Request.Cookies["temp_userid"].Value; } else { userid = Domain_def.HuoQu_Temp_UserId(); //Response.Cookies("userid").val(); HttpCookie cookie = new HttpCookie("temp_userid"); //实例化HttpCookie类并添加值 cookie.Value = userid; cookie.Expires = DateTime.Now.AddDays(365); Response.Cookies.Add(cookie); } num = Request["num"].ConvertTo <int>(1); string aRequestUrl = Request.ServerVariables["SERVER_NAME"].ToLower(); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "aRequestUrl:" + aRequestUrl); if (Domain_def.Domain_yanzheng(aRequestUrl))//如果符合shop101.etown.cn的格式 { //先通过正则表达式获取COMid comid = Int32.Parse(Domain_def.Domain_Huoqu(aRequestUrl).ToString()); } if (comid == 0)//如果非标准格式,查询 是否有绑定的域名 { var domaincomid = B2bCompanyData.GetComId(RequestUrl); if (domaincomid != null) { comid = domaincomid.Com_id; } } //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "comid:" + comid); #region 判断是否含有微信端传递过来的code值,不含有自刷新 code = Request.QueryString["code"].ConvertTo <string>(""); if (code == "") { selfrefreshurl = WeiXinJsonData.GetFollowOpenLinkUrlAboutPay(comid, "http://shop" + comid + ".etown.cn/wxpay/micromart_pay_" + num + "_" + id + ".aspx"); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "selfrefreshurl:" + selfrefreshurl); //Response.Redirect(refreshurl); } #endregion //buyuid = Request["buyuid"].ConvertTo<int>(0); //tocomid = Request["tocomid"].ConvertTo<int>(0); //uid = Request["uid"].ConvertTo<int>(0); //获取IP地址 uip = CommonFunc.GetRealIP(); nowdate = DateTime.Now.ToString("yyyy-MM-dd"); nowtoday = DateTime.Now; if (temp_id != "") { //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "a"); B2b_com_pro pro = new B2bComProData().GetProById(temp_id); if (pro == null) { //没有查询到产品,跳转购物车重新选择产品 Response.Redirect("/h5/order/cart.aspx"); } if (pro != null) { //判断微信 是否是认证服务号 WeiXinBasic mbasic = new WeiXinBasicData().GetWxBasicByComId(pro.Com_id); if (mbasic == null) { iswxsubscribenum = false; } else { if (mbasic.Weixintype == 1 || mbasic.Weixintype == 2) { iswxsubscribenum = true; } else { iswxsubscribenum = false; } } #region 微信端 共享收货地址接口 参数获取 //根据产品判断商家是否含有自己的微信支付:a.含有的话支付到商家;b.没有的话支付到平台的微信公众号账户中 B2b_finance_paytype model = new B2b_finance_paytypeData().GetFinancePayTypeByComid(pro.Com_id); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "b"); if (model != null) { //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "c"); //商家微信支付的所有参数都存在 if (model.Wx_appid != "" && model.Wx_appkey != "" && model.Wx_partnerid != "" && model.Wx_paysignkey != "") { appId = model.Wx_appid; appsecret = model.Wx_appkey; //appkey = model.Wx_paysignkey; //mchid = model.Wx_partnerid; //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "d"); issetfinancepaytype = true; if (code != "") { string url = string.Format( "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code", appId, appsecret, code); string returnStr = HttpUtil.Send("", url); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "returnStr:" + returnStr); var obj = JsonConvert.DeserializeObject <ModelOpenID>(returnStr); if (obj.openid == null) { //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "微信转发页面打开的,returnStr:" + returnStr); selfrefreshurl = WeiXinJsonData.GetFollowOpenLinkUrlAboutPay(comid, "http://shop" + comid + ".etown.cn/wxpay/micromart_pay_" + num + "_" + id + ".aspx"); Response.Redirect(selfrefreshurl); } if (obj != null) { timeStamp = TenpayUtil.getTimestamp(); nonceStr = TenpayUtil.getNoncestr(); access_tokenstring = obj.access_token; openid = obj.openid; HttpCookie newCookie = new HttpCookie("openid"); //往Cookie里面添加值,均为键/值对。Cookie可以根据关键字寻找到相应的值 newCookie.Values.Add("openid", openid); newCookie.Expires = DateTime.Now.AddDays(365); //Cookie的设置页面要用Response Response.AppendCookie(newCookie); //签名字段:appId、url(当前网页url)、timestamp、noncestr、accessToken var paySignReqHandler = new RequestHandler(Context); paySignReqHandler.setParameter("appid", appId); paySignReqHandler.setParameter("timestamp", timeStamp); paySignReqHandler.setParameter("noncestr", nonceStr); paySignReqHandler.setParameter("url", Request.Url.ToString()); paySignReqHandler.setParameter("accesstoken", obj.access_token); //addrSign = paySignReqHandler.CreateAddrSign(); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", appId + ";" + timeStamp + ";" + nonceStr + ";" + Request.Url.ToString() + ";" + obj.access_token + ";" + addrSign); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "Request.Url:" + Request.Url.ToString()); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "addrSign:" + addrSign); } } } } #endregion //票务产品,判断 是否抢购/限购,是的话 作废超时未支付订单,完成回滚操作 if (pro_servertype == 1) { if (pro.Ispanicbuy == 1 || pro.Ispanicbuy == 2) { int rs = new B2bComProData().CancelOvertimeOrder(pro); } } iscanbook = new B2bComProData().IsYouxiao(pro.Id, pro.Server_type, pro.Pro_start, pro.Pro_end, pro.Pro_state);//判断产品是否有效:1.票务,直接判断有效期 和产品上线状态2.酒店,跟团游,当地游 则判断是否含有有效的房态/团期 以及产品上下线状态 pro_servertype = pro.Server_type; pickuppoint = pro.pickuppoint; dropoffpoint = pro.dropoffpoint; issetidcard = pro.issetidcard; isSetVisitDate = pro.isSetVisitDate; childreduce = pro.Childreduce; pro_start = pro.Pro_start; pro_end = pro.Pro_end; } if (pro.Ispanicbuy == 1) { panic_begintime = pro.Panic_begintime; panicbuy_endtime = pro.Panicbuy_endtime; TimeSpan tss = pro.Panic_begintime - nowtoday; var day = tss.Days * 24 * 3600;; //这是相差的天数 var h = tss.Hours * 3600; //这是相差的小时数, var m = tss.Minutes * 60; var s = tss.Seconds; shijiacha = day + h + m + s; } projectid = pro.Projectid; comid = pro.Com_id; if (temp_id_speciid != "0") //如果规格非默认值,有规格传递,查询规格的价格 及名称 { //如果含有规格 B2b_com_pro prospeciid = new B2bComProData().GetProspeciidById(temp_id, int.Parse(temp_id_speciid)); if (prospeciid != null) { pro_name = pro.Pro_name + prospeciid.Pro_name; price = prospeciid.Advise_price; } } else { pro_name = pro.Pro_name; price = pro.Advise_price; } //如果有服务,增加服务价格 if (serverid != "") { var server_arr = serverid.Split(','); for (int i = 0; i < server_arr.Length; i++) { if (server_arr[i] != "") { var rentsrever = new RentserverData().Rentserverbyidandproid(int.Parse(server_arr[i]), int.Parse(temp_id)); if (rentsrever != null) { price += rentsrever.saleprice + rentsrever.serverDepositprice; } } } } imgurl = FileSerivce.GetImgUrl(pro.Imgurl); if (price == 0) { price = 0; } else { CommonFunc.OperTwoDecimal(price.ToString()); //price = price.IndexOf(".") != -1 ? price.Substring(0, price.IndexOf(".")) : price; } nowdate = DateTime.Now.ToString("yyyy-MM-dd"); if (pro.Service_Contain != "") { summary = "包含服务:" + pro.Service_Contain; } if (pro.Service_NotContain != "") { sumaryend = summary + "</br> 不包含服务:" + pro.Service_NotContain + "</br> 注意事项:" + pro.Precautions; } if (pro.Precautions != "") { sumaryend = summary + "</br> 注意事项:" + pro.Precautions; } //如果服务类型是 票务; 则备注信息中 显示 电子码使用限制 if (pro.Server_type == 1) { if (pro.Iscanuseonsameday == 0)//电子码当天不可用 { sumaryend = "此产品当天预订不可用<br>" + sumaryend; } if (pro.Iscanuseonsameday == 1)//电子码当天可用 { sumaryend = "此产品当天预订可用<br>" + sumaryend; } if (pro.Iscanuseonsameday == 2)//电子码出票2小时内不可用 { sumaryend = "此产品出票2小时内不可用<br>" + sumaryend; } } if (summary.Length > 30) { summary = summary.Substring(0, 30); } if (summary.Length > 150) { summary = summary.Substring(0, 150) + "..."; } remark = pro.Pro_Remark; pro_num = pro.Pro_number; if (pro_num == 0) { pro_max = 100; pro_min = 1; } else { pro_min = 1; pro_max = pro_num; } pro_explain = pro.Pro_explain; #region 产品有效期判定(微信模板--门票订单预订成功通知 中也有用到) provalidatemethod = pro.ProValidateMethod; //判断 1按产品有效期,2指定有效期 appointdate = pro.Appointdata; //1=一星期,,2=1个月,3=3个月,4=6个月,5=一年 iscanuseonsameday = pro.Iscanuseonsameday; //1当天可用,0当天不可用 pro_end = pro.Pro_end; //返回有效期 pro_youxiaoqi = new B2bComProData().GetPro_Youxiaoqi(pro.Pro_start, pro.Pro_end, provalidatemethod, appointdate, iscanuseonsameday); #endregion var commodel = B2bCompanyData.GetCompany(comid); if (commodel != null) { if (commodel.B2bcompanyinfo != null) { Wxfocus_url = commodel.B2bcompanyinfo.Wxfocus_url; Wxfocus_author = commodel.B2bcompanyinfo.Wxfocus_author;; } } var saleset = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (saleset != null) { phone = saleset.Service_Phone; } //查询项目电话,如果有项目电话调取项目电话 var projectdata = new B2b_com_projectData(); var projectmodel = projectdata.GetProject(projectid, comid); if (projectmodel != null) { if (projectmodel.Mobile != "") { phone = projectmodel.Mobile; } } //从cookie中得到微信号 if (Request.Cookies["openid"] != null) { openid = Request.Cookies["openid"].Value; } B2bCrmData b2b_crm = new B2bCrmData(); if (openid != "") { B2b_crm b2bmodle = b2b_crm.b2b_crmH5(openid, comid); if (b2bmodle != null) { Imprest = b2bmodle.Imprest; Integral = b2bmodle.Integral; } } } //如果是购物车产品,整体更换计算方式,以上至是读一个产品信息,并且读取用户的分销信息等 if (cart == 1) { cart_num = ""; //数量 price = 0; //单价 //获取购物车 的用户ID if (Request.Cookies["temp_userid"] != null) { userid = Request.Cookies["temp_userid"].Value; } cart_id = id; //赋值方便区分 if (userid != "") { var list = new B2bOrderData().SearchUserCartList(comid, userid, cart_id, id_speciid); if (list != null) { cart_id = ""; for (int i = 0; i < list.Count; i++) { cart_num += list[i].U_num + ","; cart_id += list[i].Id + ","; if (list[i].Speciid == 0) { price += list[i].U_num * list[i].Advise_price; //重新计算价格 } else { B2b_com_pro prospeciid = new B2bComProData().GetProspeciidById(list[i].Id.ToString(), list[i].Speciid);//如果含有规格参数 读取规格 if (prospeciid != null) { price += list[i].U_num * prospeciid.Advise_price; //重新计算价格 } } } if (cart_num != "") { if (cart_num.Substring(cart_num.Length - 1, 1) == ",") { cart_num = cart_num.Substring(0, cart_num.Length - 1); } } if (cart_id != "") { if (cart_id.Substring(cart_id.Length - 1, 1) == ",") { cart_id = cart_id.Substring(0, cart_id.Length - 1); } } } } } if (Domain_def.Domain_yanzheng(RequestUrl))//如果符合shop101.etown.cn的格式,则从多微信商户基本信息表中获取comid { //先通过正则表达式获取COMid comid = Int32.Parse(Domain_def.Domain_Huoqu(RequestUrl).ToString()); if (comid == 0) { comid = new WeiXinBasicData().GetWeiXinBasicByDomain(RequestUrl).Comid; } if (comid != 0) { var commodel = B2bCompanyData.GetCompany(comid); if (commodel != null) { if (commodel.B2bcompanyinfo != null) { Wxfocus_url = commodel.B2bcompanyinfo.Wxfocus_url; Wxfocus_author = commodel.B2bcompanyinfo.Wxfocus_author; weixinname = commodel.B2bcompanyinfo.Weixinname; Scenic_intro = commodel.B2bcompanyinfo.Scenic_intro; } title = commodel.Com_name; } B2b_company_saleset pro = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (pro != null) { comlogo = FileSerivce.GetImgUrl(pro.Smalllogo.ConvertTo <int>(0)); logoimg = comlogo; } ////获取微信平台端code //string weixincode = Request["code"].ConvertTo<string>(""); ////获取微信号和一次性密码 //openid = Request["openid"].ConvertTo<string>(""); //string weixinpass = Request["weixinpass"].ConvertTo<string>(""); ////获得会员信息 //GetCrmInfo(weixincode, openid, weixinpass); } } //获取BANNER,及logo //if (comid != 0) //{ // //根据公司id得到 直销设置 // B2b_company_saleset saleset = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); // if (saleset != null) // { // logoimg = FileSerivce.GetImgUrl(saleset.Smalllogo.ConvertTo<int>(0)); // } //} //微信转发访问归属渠道 if (uid != 0)//必须记录转发用户信息才能继续统计 { //判断有转发人的渠道 var crmdata = new B2bCrmData(); var pro = crmdata.Readuser(uid, comid);//读取转发人用户信息 string zhuanfa_phone = ""; if (pro != null) { zhuanfa_phone = pro.Phone; } if (zhuanfa_phone != "") { //转发人手机存在 MemberChannelData channeldata = new MemberChannelData(); var channeinfo = channeldata.GetPhoneComIdChannelDetail(zhuanfa_phone, comid); //查询渠道 if (channeinfo != null) { //转发人渠道记录COOKI HttpCookie cookie = new HttpCookie("ZF_ChanneId"); //实例化HttpCookie类并添加值 cookie.Value = channeinfo.Id.ToString(); cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); } } } }
public bool issetfinancepaytype = false;//是否设置了微信支付参数 public void Page_Load(object sender, EventArgs e) { string u = Request.ServerVariables["HTTP_USER_AGENT"]; bool bo = detectmobilebrowser.HttpUserAgent(u); uid = Request["uid"].ConvertTo <int>(0); //获取IP地址 uip = CommonFunc.GetRealIP(); id = Request["id"].ConvertTo <int>(0); nowdate = DateTime.Now.ToString("yyyy-MM-dd"); nowtoday = DateTime.Now; buyuid = Request["buyuid"].ConvertTo <int>(0); tocomid = Request["tocomid"].ConvertTo <int>(0); //获取随机用户ID if (Request.Cookies["temp_userid"] != null) { userid = Request.Cookies["temp_userid"].Value; } else { userid = Domain_def.HuoQu_Temp_UserId(); //Response.Cookies("userid").val(); HttpCookie cookie = new HttpCookie("temp_userid"); //实例化HttpCookie类并添加值 cookie.Value = userid; cookie.Expires = DateTime.Now.AddDays(365); Response.Cookies.Add(cookie); } if (id != 0) { B2b_com_pro pro = new B2bComProData().GetProById(id.ToString()); if (pro != null) { Ispanicbuy = pro.Ispanicbuy; //是否抢购或限购 Limitbuytotalnum = pro.Limitbuytotalnum; //限购数量 //根据产品判断商家是否含有自己的微信支付:a.含有的话支付到商家;b.没有的话支付到平台的微信公众号账户中 B2b_finance_paytype model = new B2b_finance_paytypeData().GetFinancePayTypeByComid(pro.Com_id); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "b"); if (model != null) { //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "c"); //商家微信支付的所有参数都存在 if (model.Wx_appid != "" && model.Wx_appkey != "" && model.Wx_partnerid != "" && model.Wx_paysignkey != "") { //appId = model.Wx_appid; //appsecret = model.Wx_appkey; //appkey = model.Wx_paysignkey; //mchid = model.Wx_partnerid; //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "d"); issetfinancepaytype = true; } } //票务产品,判断 是否抢购/限购,是的话 作废超时未支付订单,完成回滚操作 if (pro_servertype == 1) { if (pro.Ispanicbuy == 1 || pro.Ispanicbuy == 2) { int rs = new B2bComProData().CancelOvertimeOrder(pro); } } iscanbook = new B2bComProData().IsYouxiao(pro.Id, pro.Server_type, pro.Pro_start, pro.Pro_end, pro.Pro_state);//判断产品是否有效:1.票务,直接判断有效期 和产品上线状态2.酒店,跟团游,当地游 则判断是否含有有效的房态/团期 以及产品上下线状态 pro_servertype = pro.Server_type; pickuppoint = pro.pickuppoint; dropoffpoint = pro.dropoffpoint; childreduce = pro.Childreduce; } if (pro.Ispanicbuy == 1) { panic_begintime = pro.Panic_begintime; panicbuy_endtime = pro.Panicbuy_endtime; TimeSpan tss = pro.Panic_begintime - nowtoday; var day = tss.Days * 24 * 3600;; //这是相差的天数 var h = tss.Hours * 3600; //这是相差的小时数, var m = tss.Minutes * 60; var s = tss.Seconds; shijiacha = day + h + m + s; } projectid = pro.Projectid; comid = pro.Com_id; pro_name = pro.Pro_name; price = pro.Advise_price; face_price = pro.Face_price; limitbuytotalnum = pro.Limitbuytotalnum; imgurl = FileSerivce.GetImgUrl(pro.Imgurl); if (price == 0) { price = 0; } else { CommonFunc.OperTwoDecimal(price.ToString()); //price = price.IndexOf(".") != -1 ? price.Substring(0, price.IndexOf(".")) : price; } if (face_price != 0) { CommonFunc.OperTwoDecimal(face_price.ToString()); } nowdate = DateTime.Now.ToString("yyyy-MM-dd"); if (pro.Service_Contain != "") { sumaryend = pro.Service_Contain; } if (pro.Service_NotContain != "") { sumaryend = sumaryend + "</br> " + pro.Service_NotContain; } if (pro.Precautions != "") { sumaryend = sumaryend + "</br> " + pro.Precautions; } Server_type = pro.Server_type; //如果服务类型是 票务; 则备注信息中 显示 电子码使用限制 //if (pro.Server_type == 1) //{ // if (pro.Iscanuseonsameday == 0)//电子码当天不可用 // { // sumaryend = "此产品当天预订不可用<br>" + sumaryend; // } // if (pro.Iscanuseonsameday == 1)//电子码当天可用 // { // sumaryend = "此产品当天预订可用<br>" + sumaryend; // } // if (pro.Iscanuseonsameday == 2)//电子码出票2小时内不可用 // { // sumaryend = "此产品出票2小时内不可用<br>" + sumaryend; // } //} remark = pro.Pro_Remark; pro_num = pro.Pro_number; if (pro_num == 0) { pro_max = 100; pro_min = 1; } else { pro_min = 1; pro_max = pro_num; } pro_explain = pro.Pro_explain; #region 产品有效期判定(微信模板--门票订单预订成功通知 中也有用到) provalidatemethod = pro.ProValidateMethod; //判断 1按产品有效期,2指定有效期 appointdate = pro.Appointdata; //1=一星期,,2=1个月,3=3个月,4=6个月,5=一年 iscanuseonsameday = pro.Iscanuseonsameday; //1当天可用,0当天不可用 DateTime pro_end = pro.Pro_end; //返回有效期 pro_youxiaoqi = new B2bComProData().GetPro_Youxiaoqi(pro.Pro_start, pro.Pro_end, provalidatemethod, appointdate, iscanuseonsameday); #endregion var commodel = B2bCompanyData.GetCompany(comid); if (commodel != null) { if (commodel.B2bcompanyinfo != null) { Wxfocus_url = commodel.B2bcompanyinfo.Wxfocus_url; Wxfocus_author = commodel.B2bcompanyinfo.Wxfocus_author;; } } var saleset = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (saleset != null) { phone = saleset.Service_Phone; } //查询项目电话,如果有项目电话调取项目电话 var projectdata = new B2b_com_projectData(); var projectmodel = projectdata.GetProject(projectid, comid); if (projectmodel != null) { if (projectmodel.Mobile != "") { phone = projectmodel.Mobile; } } //从cookie中得到微信号 if (Request.Cookies["openid"] != null) { openid = Request.Cookies["openid"].Value; } B2bCrmData b2b_crm = new B2bCrmData(); if (openid != "") { B2b_crm b2bmodle = b2b_crm.b2b_crmH5(openid, comid); if (b2bmodle != null) { Imprest = b2bmodle.Imprest; Integral = b2bmodle.Integral; } } } if (Domain_def.Domain_yanzheng(RequestUrl))//如果符合shop101.etown.cn的格式,则从多微信商户基本信息表中获取comid { //先通过正则表达式获取COMid comid = Int32.Parse(Domain_def.Domain_Huoqu(RequestUrl).ToString()); } if (comid == 0)//如果非标准格式,查询 是否有绑定的域名 { var wxdomain = new WeiXinBasicData().GetWeiXinBasicByDomain(RequestUrl); if (wxdomain != null) { comid = wxdomain.Comid; } } if (comid != 0) { var commodel = B2bCompanyData.GetCompany(comid); if (commodel != null) { if (commodel.B2bcompanyinfo != null) { Wxfocus_url = commodel.B2bcompanyinfo.Wxfocus_url; Wxfocus_author = commodel.B2bcompanyinfo.Wxfocus_author; weixinname = commodel.B2bcompanyinfo.Weixinname; Scenic_intro = commodel.B2bcompanyinfo.Scenic_intro; } title = commodel.Com_name; } B2b_company_saleset pro = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (pro != null) { if (pro.Smalllogo != null && pro.Smalllogo != "") { comlogo = FileSerivce.GetImgUrl(pro.Smalllogo.ConvertTo <int>(0)); } } //获取微信平台端code string weixincode = Request["code"].ConvertTo <string>(""); //获取微信号和一次性密码 openid = Request["openid"].ConvertTo <string>(""); string weixinpass = Request["weixinpass"].ConvertTo <string>(""); //获得会员信息 GetCrmInfo(weixincode, openid, weixinpass); } //获取BANNER,及logo if (comid != 0) { //根据公司id得到 直销设置 B2b_company_saleset saleset = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (saleset != null) { logoimg = FileSerivce.GetImgUrl(saleset.Smalllogo.ConvertTo <int>(0)); } } //微信转发访问归属渠道 if (uid != 0)//必须记录转发用户信息才能继续统计 { //判断有转发人的渠道 var crmdata = new B2bCrmData(); var pro = crmdata.Readuser(uid, comid);//读取转发人用户信息 string zhuanfa_phone = ""; if (pro != null) { zhuanfa_phone = pro.Phone; } if (zhuanfa_phone != "") { //转发人手机存在 MemberChannelData channeldata = new MemberChannelData(); var channeinfo = channeldata.GetPhoneComIdChannelDetail(zhuanfa_phone, comid); //查询渠道 if (channeinfo != null) { //转发人渠道记录COOKI HttpCookie cookie = new HttpCookie("ZF_ChanneId"); //实例化HttpCookie类并添加值 cookie.Value = channeinfo.Id.ToString(); cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); } } } }
public int isrightwxset = 1; //微信接口设置信息是否正确 #endregion protected void Page_Load(object sender, EventArgs e) { MasterId = Request["MasterId"].ConvertTo <int>(0); come = Request["come"].ConvertTo <string>(""); B2b_company_manageuser manageruser = B2bCompanyManagerUserData.GetUser(MasterId); if (manageruser != null) { MasterId = manageruser.Id; MasterName = manageruser.Employeename; CompanyName = B2bCompanyData.GetCompanyByUid(manageruser.Id).Com_name; Tel = manageruser.Tel; Viewtel = manageruser.Viewtel; comid = manageruser.Com_id; B2bCrmData crmdata = new B2bCrmData(); var crmmodel = crmdata.GetB2bCrmByPhone(manageruser.Com_id, Tel); if (crmmodel != null) { if (crmmodel.Weixin != "") { zaixianzhuangtai = "我在线上"; guwenweixin = crmmodel.Weixin; } else { zaixianzhuangtai = "未在线"; } } var commodel = B2bCompanyData.GetCompany(comid); if (commodel != null) { title = commodel.Com_name; } B2b_company_saleset pro = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (pro != null) { if (pro.Smalllogo != null && pro.Smalllogo != "") { comlogo = FileSerivce.GetImgUrl(pro.Smalllogo.ConvertTo <int>(0)); } } ChannelCompanyId = manageruser.Channelcompanyid; ChannelCompany = new MemberChannelcompanyData().GetCompanyById(manageruser.Channelcompanyid.ToString().ConvertTo <int>(0)); if (ChannelCompany != null) { ChannelCompanyName = ChannelCompany.Companyname; } //获取渠道ID MemberChannelData channeldata = new MemberChannelData(); var channelmodel = channeldata.GetPhoneComIdChannelDetail(Tel, comid); if (channelmodel != null) { channelid = channelmodel.Id; } Channelsource = manageruser.Channelsource; CreateUserId = manageruser.Createuserid; EmployeState = manageruser.Employeestate; Job = manageruser.Job; Selfbrief = manageruser.Selfbrief; if (Selfbrief != "" && Selfbrief != null) { if (Selfbrief.Length > 21) { Selfbrief = Selfbrief.Substring(0, 21) + "..."; } } //Headimg=manageruser.Headimg; Headimgurl = FileSerivce.GetImgUrl(manageruser.Headimg); Workingyears = manageruser.Workingyears; Workdays = manageruser.Workdays; WorkdaysView = crmdata.WorkDay(Workdays);//判断是否在工作日内,1为在,0为不在 Workdaystime = manageruser.Workdaystime; Workendtime = manageruser.Workendtime; Fixphone = manageruser.Fixphone; Email = manageruser.Email; Homepage = manageruser.Homepage; Weibopage = manageruser.Weibopage; QQ = manageruser.QQ; Weixin = manageruser.Weixin; Selfhomepage_qrcordurl = manageruser.Selfhomepage_qrcordurl; //获取公司信息(微信连接地址) cominfo = B2bCompanyData.GetAllComMsg(comid); if (cominfo != null) { linkguanzhu = cominfo.B2bcompanyinfo.Wxfocus_url; author = cominfo.B2bcompanyinfo.Wxfocus_author; } //导航 var imagedata = new B2bCompanyMenuData(); int totalcount = 0; List <B2b_company_menu> list = imagedata.GetconsultantList(manageruser.Com_id, 1, 10, out totalcount); if (list != null) { for (int i = 0; i < list.Count; i++) { var imageurl = FileSerivce.GetImgUrl(list[i].Imgurl); if (firstmenuid == 0) { firstdaohang = list[i].Linktype; firstmenuid = list[i].Id; isoutpro = list[i].Outdata; } if (daohang_html == "") { daohang_html += "<li class=\"curr\" menu-id=\"" + list[i].Id + "\" data-id=\"" + list[i].Linktype + "\" data-isoutpro=\"" + list[i].Outdata + "\"><!--<img src=\"" + imageurl + "\" height=\"60px\">--><span>" + list[i].Name + "</span></li>"; } else { daohang_html += "<li class=\"\" menu-id=\"" + list[i].Id + "\" data-id=\"" + list[i].Linktype + "\" data-isoutpro=\"" + list[i].Outdata + "\"><!--<img src=\"" + imageurl + "\" height=\"60px\">--><span>" + list[i].Name + "</span></li>"; } //daohang_Imgurl_address = FileSerivce.GetImgUrl(list.Imgurl); //daohang_Imgurl = list.Imgurl; ///daohang_Linkurl = list.Linkurl; //daohang_Name = list.Name; //daohang_Fonticon = list.Fonticon; } } } ; //获取微信平台端code string weixincode = Request["code"].ConvertTo <string>(""); if (weixincode != "") { int questtype = 2;//1=微信授权验证 DealUserinfo1("", weixincode, comid, questtype); } else { string openid = Request["openid"].ConvertTo <string>(""); string weixinpass = Request["weixinpass"].ConvertTo <string>(""); int questtype = 1; //1=一次性密码验证 DealUserinfo1(openid, weixinpass, comid, questtype); //判断用户微信号(1,点击的转发链接进来的2,点击微信菜单进来的);使用户处于登录状态(不包括点击转发链接的) } //创建新的微信一次性密码 new_weixinpass = new B2bCrmData().WeixinGetPass(weixinopenid, comid); #region 微信语音播放接口会用到 string url = Request.Url.ToString(); //根据传入参数openid、comid 得到 access_token、jsapi_ticket、noncestr、timestamp、 url(当前网页的URL,不包含#及其后面部分) WeiXinBasic basic = new WeiXinBasicData().GetWxBasicByComId(comid); if (basic != null) { appId = basic.AppId; timestamp = new WeixinVoiceUtil().CreatenTimestamp(); nonceStr = new WeixinVoiceUtil().CreatenNonce_str(); WXAccessToken maccesstoken = new WeixinVoiceUtil().GetAccessToken(comid, basic.AppId, basic.AppSecret); if (maccesstoken != null) { string jsapi_ticket = new WeixinVoiceUtil().GetTickect(maccesstoken.ACCESS_TOKEN, comid); if (jsapi_ticket == "") { isrightwxset = 0; } else { string beforesha1_signature = ""; signature = new WeixinVoiceUtil().GetSignature(jsapi_ticket, nonceStr, timestamp, url, out beforesha1_signature); } } else { isrightwxset = 0; } } else { isrightwxset = 0; } #endregion }
public int isrightwxset = 1; //微信接口设置信息是否正确 protected void Page_Load(object sender, EventArgs e) { openid = Request["openid"].ConvertTo <string>(""); //uid = Request["uid"].ConvertTo<int>(0); //weixinpass = Request["weixinpass"].ConvertTo<string>(""); comid = Request["comid"].ConvertTo <int>(0); clientuptypemark = Request["clientuptypemark"].ConvertTo <int>(0); materialid = Request["materialid"].ConvertTo <int>(0); //根据openid得到员工信息 if (openid != "") { B2b_company_manageuser muser = new B2bCompanyManagerUserData().GetCompanyUserByOpenid(openid); if (muser != null) { username = muser.Employeename; } } //根据materialid 得到文章信息 if (materialid > 0) { WxMaterial msucai = new WxMaterialData().GetWxMaterial(materialid); if (msucai != null) { materialname = msucai.Title; } } #region 微信语音播放接口会用到 string url = Request.Url.ToString(); //根据传入参数openid、comid 得到 access_token、jsapi_ticket、noncestr、timestamp、 url(当前网页的URL,不包含#及其后面部分) WeiXinBasic basic = new WeiXinBasicData().GetWxBasicByComId(comid); if (basic != null) { appId = basic.AppId; timestamp = new WeixinVoiceUtil().CreatenTimestamp(); nonceStr = new WeixinVoiceUtil().CreatenNonce_str(); WXAccessToken maccesstoken = new WeixinVoiceUtil().GetAccessToken(comid, basic.AppId, basic.AppSecret); if (maccesstoken != null) { string jsapi_ticket = new WeixinVoiceUtil().GetTickect(maccesstoken.ACCESS_TOKEN, comid); if (jsapi_ticket == "") { isrightwxset = 0; } else { string beforesha1_signature = ""; signature = new WeixinVoiceUtil().GetSignature(jsapi_ticket, nonceStr, timestamp, url, out beforesha1_signature); } } else { isrightwxset = 0; } } else { isrightwxset = 0; } #endregion }
//给顾问,客户,绑定人发送通知, sentype=1 给绑定顾问,=2给客户 =3给教练 public static void SendWxkefumsg(int orderid, int sentype, string msg, int comid) { WeiXinBasic basic = new WeiXinBasicData().GetWxBasicByComId(comid); string openid = ""; WxMessageLogData messagelogdata = new WxMessageLogData(); B2bOrderData orderdate = new B2bOrderData(); var orderinfo = orderdate.GetOrderById(orderid); if (orderinfo == null) { return; } //会员 MemberCardData carddata = new MemberCardData(); var userdata = new B2bCrmData(); if (sentype == 2) { var userinfo = userdata.Readuser(orderinfo.U_id, orderinfo.Comid); if (userinfo == null) { return; } openid = userinfo.Weixin; if (openid != "") { //微信客服 文本消息 string data = SendWxMsg(comid, openid, 1, "", msg, "", basic.Weixinno); } } if (sentype == 1) { var b2bprodata = new B2bComProData(); var proinfo = b2bprodata.GetProById(orderinfo.Pro_id.ToString(), orderinfo.Speciid, orderinfo.channelcoachid); if (proinfo == null) { return; } if (proinfo.bookpro_bindphone != "") { //var channeldata = new MemberChannelData(); //var channelinfo = channeldata.GetPhoneComIdChannelDetail(proinfo.bookpro_bindphone,comid); //直接通过 手机查询用户 var userinfo_binding = userdata.GetSjKeHu(proinfo.bookpro_bindphone, orderinfo.Comid); if (userinfo_binding == null) { return; } openid = userinfo_binding.Weixin; if (openid != "") { //微信 文本消息 string data_binding = SendWxMsg(comid, openid, 1, "", msg, "", basic.Weixinno); } } } //给教练 if (sentype == 3) { var b2bprodata = new B2bComProData(); var proinfo = b2bprodata.GetProById(orderinfo.Pro_id.ToString(), orderinfo.Speciid, orderinfo.channelcoachid); if (proinfo == null) { return; } if (orderinfo.channelcoachid != 0) { var channeldata = new MemberChannelData(); var channelinfo = MemberChannelData.GetChannelinfo(orderinfo.channelcoachid); if (channelinfo != null) { //直接通过 手机查询用户 var userinfo_binding = userdata.GetSjKeHu(channelinfo.Mobile, orderinfo.Comid); if (userinfo_binding == null) { return; } openid = userinfo_binding.Weixin; if (openid != "") { //微信 文本消息 string data_binding = SendWxMsg(comid, openid, 1, "", msg, "", basic.Weixinno); } } } } }
public void Page_Load(object sender, EventArgs e) { string u = Request.ServerVariables["HTTP_USER_AGENT"]; bool bo = detectmobilebrowser.HttpUserAgent(u); uid = Request["uid"].ConvertTo <int>(0); MasterId = Request["MasterId"].ConvertTo <int>(0); //获取IP地址 uip = CommonFunc.GetRealIP(); id = Request["id"].ConvertTo <int>(0); nowdate = DateTime.Now.ToString("yyyy-MM-dd"); nowtoday = DateTime.Now; buyuid = Request["buyuid"].ConvertTo <int>(0); tocomid = Request["tocomid"].ConvertTo <int>(0); //获取随机用户ID if (Request.Cookies["temp_userid"] != null) { userid = Request.Cookies["temp_userid"].Value; } else { userid = Domain_def.HuoQu_Temp_UserId(); //Response.Cookies("userid").val(); HttpCookie cookie = new HttpCookie("temp_userid"); //实例化HttpCookie类并添加值 cookie.Value = userid; cookie.Expires = DateTime.Now.AddDays(365); Response.Cookies.Add(cookie); } if (id != 0) { B2b_com_pro pro = new B2bComProData().GetProById(id.ToString()); if (pro != null) { channelcoachid = new MemberChannelData().GetChannelidbymanageuserid(MasterId, pro.Com_id); if (pro.Server_type == 13) { //如果 产品为教练产品 if (channelcoachid == 0) { //当未选择教练 则 跳转到教练页面 Response.Redirect("/h5/coachList.aspx?come=" + id); } } Ispanicbuy = pro.Ispanicbuy; //是否抢购或限购 Limitbuytotalnum = pro.Limitbuytotalnum; //限购数量 bindname = pro.bookpro_bindname; bindphone = pro.bookpro_bindphone; manyspeci = pro.Manyspeci; Wrentserver = pro.Wrentserver; //如果多规格读取规格 if (manyspeci == 1) { gglist = new B2b_com_pro_SpeciData().Getgglist(pro.Id); } //对默认只显示预约电话进行 if (pro.Server_type == 12 || pro.Server_type == 13) { //当时预约产品就先设定显示预约电话 view_phone = 1; //先判断渠道来路,如果没有渠道则安默认,如果有来路渠道,则显示来路渠道 if (MasterId != 0) { B2b_company_manageuser manageruser = B2bCompanyManagerUserData.GetUser(MasterId); if (manageruser != null) { bindname = manageruser.Employeename; bindphone = manageruser.Tel; } } //判断 绑定渠道电话 与 访问来的渠道电话相同 则 显示电话,并显示预订 if (bindphone == pro.bookpro_bindphone) { view_phone = 2; } //如果为教练产品,显示订购和 和图像 不显示电话 if (pro.Server_type == 13) { view_phone = 3; } } //通过 显示渠道的电话 来查找头像 B2b_company_manageuser manageruser_temp = new B2bCompanyManagerUserData().GetCompanyUserByPhone(bindphone, pro.Com_id); if (manageruser_temp != null) { channleimg = FileSerivce.GetImgUrl(manageruser_temp.Headimg); if (channleimg == "/Images/defaultThumb.png") { channleimg = ""; } } //查询相关项目名称 var proprojectdata = new B2b_com_projectData(); var proprejectinfo = proprojectdata.GetProject(pro.Projectid, pro.Com_id); if (proprejectinfo != null) { projectname = proprejectinfo.Projectname; Coordinate = proprejectinfo.Coordinate; Address = proprejectinfo.Address; } projectname = proprojectdata.GetProjectNameByid(pro.Projectid); //根据产品判断商家是否含有自己的微信支付:a.含有的话支付到商家;b.没有的话支付到平台的微信公众号账户中 B2b_finance_paytype model = new B2b_finance_paytypeData().GetFinancePayTypeByComid(pro.Com_id); //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "b"); if (model != null) { //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "c"); //商家微信支付的所有参数都存在 if (model.Wx_appid != "" && model.Wx_appkey != "" && model.Wx_partnerid != "" && model.Wx_paysignkey != "") { //appId = model.Wx_appid; //appsecret = model.Wx_appkey; //appkey = model.Wx_paysignkey; //mchid = model.Wx_partnerid; //TxtHelper.WriteFile("D:\\site\\b2betown\\ETS2.WebApp\\Log.txt", "d"); issetfinancepaytype = true; } } //票务产品,判断 是否抢购/限购,是的话 作废超时未支付订单,完成回滚操作 if (pro_servertype == 1) { if (pro.Ispanicbuy == 1 || pro.Ispanicbuy == 2) { int rs = new B2bComProData().CancelOvertimeOrder(pro); } } iscanbook = new B2bComProData().IsYouxiao(pro.Id, pro.Server_type, pro.Pro_start, pro.Pro_end, pro.Pro_state);//判断产品是否有效:1.票务,直接判断有效期 和产品上线状态2.酒店,跟团游,当地游 则判断是否含有有效的房态/团期 以及产品上下线状态 pro_servertype = pro.Server_type; pickuppoint = pro.pickuppoint; dropoffpoint = pro.dropoffpoint; childreduce = pro.Childreduce; if (pro.Ispanicbuy == 1) { panic_begintime = pro.Panic_begintime; panicbuy_endtime = pro.Panicbuy_endtime; TimeSpan tss = pro.Panic_begintime - nowtoday; var day = tss.Days * 24 * 3600;; //这是相差的天数 var h = tss.Hours * 3600; //这是相差的小时数, var m = tss.Minutes * 60; var s = tss.Seconds; shijiacha = day + h + m + s; } projectid = pro.Projectid; comid = pro.Com_id; pro_name = pro.Pro_name; price = pro.Advise_price; face_price = pro.Face_price; limitbuytotalnum = pro.Limitbuytotalnum; imgurl = FileSerivce.GetImgUrl(pro.Imgurl); //如果含有规格读取规格价格中最低价 if (manyspeci == 1) { if (gglist != null) { price = 0; face_price = 0; for (int i = 0; i < gglist.Count(); i++) { if (gglist[i].speci_advise_price != 0) { if (price == 0 || price > gglist[i].speci_advise_price) { price = gglist[i].speci_advise_price; face_price = gglist[i].speci_face_price; } } } } } if (price == 0) { price = 0; } else { CommonFunc.OperTwoDecimal(price.ToString()); //price = price.IndexOf(".") != -1 ? price.Substring(0, price.IndexOf(".")) : price; } if (face_price != 0) { CommonFunc.OperTwoDecimal(face_price.ToString()); } nowdate = DateTime.Now.ToString("yyyy-MM-dd"); if (pro.Service_Contain != "") { sumaryend = pro.Service_Contain; } if (pro.Service_NotContain != "") { sumaryend = sumaryend + "</br> " + pro.Service_NotContain; } if (pro.Precautions != "") { sumaryend = sumaryend + "</br> " + pro.Precautions; } Server_type = pro.Server_type; bookpro_ispay = pro.bookpro_ispay; //如果服务类型是 票务; 则备注信息中 显示 电子码使用限制 if (pro.Server_type == 1) { if (pro.Iscanuseonsameday == 0)//电子码当天不可用 { youxianshiduan = "此产品当天预订不可用"; } if (pro.Iscanuseonsameday == 1)//电子码当天可用 { youxianshiduan = "此产品当天预订可用"; } if (pro.Iscanuseonsameday == 2)//电子码出票2小时内不可用 { youxianshiduan = "此产品出票2小时内不可用"; } } remark = pro.Pro_Remark; pro_num = pro.Pro_number; if (pro_num == 0) { pro_max = 100; pro_min = 1; } else { pro_min = 1; pro_max = pro_num; } pro_explain = pro.Pro_explain; #region 产品有效期判定(微信模板--门票订单预订成功通知 中也有用到) provalidatemethod = pro.ProValidateMethod; //判断 1按产品有效期,2指定有效期 appointdate = pro.Appointdata; //1=一星期,,2=1个月,3=3个月,4=6个月,5=一年 iscanuseonsameday = pro.Iscanuseonsameday; //1当天可用,0当天不可用 pro_end = pro.Pro_end; pro_end_str = pro.Pro_end.AddMonths(-1).ToString("yyyy,MM,dd"); //返回有效期 pro_youxiaoqi = new B2bComProData().GetPro_Youxiaoqi(pro.Pro_start, pro.Pro_end, provalidatemethod, appointdate, iscanuseonsameday); #endregion //如果是 教练产品 根据教练信息 获取教练 上班时间 if (pro.Server_type == 13 || pro.Server_type == 12) { //必须是教练产品 if (MasterId != 0) //必须有教练参数 { B2b_company_manageuser manageruser = B2bCompanyManagerUserData.GetUser(MasterId); if (manageruser != null) { if (manageruser.Workdays != "") { if (manageruser.worktimestar != 0) { if (manageruser.worktimestar < manageruser.worktimeend) { for (var i = manageruser.worktimestar; i < manageruser.worktimeend; i++) { workh += "<option value=\"" + i + "\">" + i + "点</option>"; } } else { var day1 = 24 - manageruser.worktimestar; var day2 = manageruser.worktimeend; var day3 = day1 + day2; for (var i = 0; i > day3; i++) { if (i > day1) { workh += "<option value=\"" + (manageruser.worktimestar + i) + "\">" + (manageruser.worktimestar + i) + "点</option>"; } else { workh += "<option value=\"" + (manageruser.worktimestar - i) + "\">" + (manageruser.worktimestar - i) + "点</option>"; } } } } if (!manageruser.Workdays.Contains("2")) //检验不含周一 { DateTime dt = DateTime.Now; //当前时间 DateTime startWeek = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d"))); //本周周一 //初始日期为今天,到产品有效期结束 增加一周(7天)方式 for (var i = startWeek; i < pro_end; i.AddDays(7)) { nowork += "[" + i.Month + "," + i.Day + "," + i.Year + "],"; i = i.AddDays(7); } } if (!manageruser.Workdays.Contains("3")) //检验不含周二 { DateTime dt = DateTime.Now; //当前时间 DateTime startWeek = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d"))).AddDays(1); //本周周二 //初始日期为今天,到产品有效期结束 增加一周(7天)方式 for (var i = startWeek; i < pro_end; i.AddDays(7)) { nowork += "[" + i.Month + "," + i.Day + "," + i.Year + "],"; i = i.AddDays(7); } } if (!manageruser.Workdays.Contains("4")) //检验不含周3 { DateTime dt = DateTime.Now; //当前时间 DateTime startWeek = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d"))).AddDays(2); //本周周3 //初始日期为今天,到产品有效期结束 增加一周(7天)方式 for (var i = startWeek; i < pro_end; i.AddDays(7)) { nowork += "[" + i.Month + "," + i.Day + "," + i.Year + "],"; i = i.AddDays(7); } } if (!manageruser.Workdays.Contains("5")) //检验不含周4 { DateTime dt = DateTime.Now; //当前时间 DateTime startWeek = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d"))).AddDays(3); //本周周4 //初始日期为今天,到产品有效期结束 增加一周(7天)方式 for (var i = startWeek; i < pro_end; i.AddDays(7)) { nowork += "[" + i.Month + "," + i.Day + "," + i.Year + "],"; i = i.AddDays(7); } } if (!manageruser.Workdays.Contains("6")) //检验不含周5 { DateTime dt = DateTime.Now; //当前时间 DateTime startWeek = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d"))).AddDays(4); //本周周5 //初始日期为今天,到产品有效期结束 增加一周(7天)方式 for (var i = startWeek; i < pro_end; i.AddDays(7)) { nowork += "[" + i.Month + "," + i.Day + "," + i.Year + "],"; i = i.AddDays(7); } } if (!manageruser.Workdays.Contains("7")) //检验不含周6 { DateTime dt = DateTime.Now; //当前时间 DateTime startWeek = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d"))).AddDays(5); //本周周6 //初始日期为今天,到产品有效期结束 增加一周(7天)方式 for (var i = startWeek; i < pro_end; i.AddDays(7)) { nowork += "[" + i.Month + "," + i.Day + "," + i.Year + "],"; i = i.AddDays(7); } } if (!manageruser.Workdays.Contains("1")) //检验不含周日 { DateTime dt = DateTime.Now; //当前时间 DateTime startWeek = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d"))).AddDays(6); //本周周日 //初始日期为今天,到产品有效期结束 增加一周(7天)方式 for (var i = startWeek; i < pro_end; i.AddDays(7)) { nowork += "[" + i.Month + "," + i.Day + "," + i.Year + "],"; i = i.AddDays(7); } } } } } } } var commodel = B2bCompanyData.GetCompany(comid); if (commodel != null) { if (commodel.B2bcompanyinfo != null) { Wxfocus_url = commodel.B2bcompanyinfo.Wxfocus_url; Wxfocus_author = commodel.B2bcompanyinfo.Wxfocus_author;; } } var saleset = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (saleset != null) { phone = saleset.Service_Phone; } //查询项目电话,如果有项目电话调取项目电话 var projectdata = new B2b_com_projectData(); var projectmodel = projectdata.GetProject(projectid, comid); if (projectmodel != null) { if (projectmodel.Mobile != "") { phone = projectmodel.Mobile; } } //从cookie中得到微信号 if (Request.Cookies["openid"] != null) { openid = Request.Cookies["openid"].Value; } B2bCrmData b2b_crm = new B2bCrmData(); if (openid != "") { B2b_crm b2bmodle = b2b_crm.b2b_crmH5(openid, comid); if (b2bmodle != null) { Imprest = b2bmodle.Imprest; Integral = b2bmodle.Integral; } } } if (Domain_def.Domain_yanzheng(RequestUrl))//如果符合shop101.etown.cn的格式,则从多微信商户基本信息表中获取comid { //先通过正则表达式获取COMid comid = Int32.Parse(Domain_def.Domain_Huoqu(RequestUrl).ToString()); } if (comid == 0)//如果非标准格式,查询 是否有绑定的域名 { var wxdomain = new WeiXinBasicData().GetWeiXinBasicByDomain(RequestUrl); if (wxdomain != null) { comid = wxdomain.Comid; } } if (comid != 0) { var commodel = B2bCompanyData.GetCompany(comid); if (commodel != null) { if (commodel.B2bcompanyinfo != null) { Wxfocus_url = commodel.B2bcompanyinfo.Wxfocus_url; Wxfocus_author = commodel.B2bcompanyinfo.Wxfocus_author; weixinname = commodel.B2bcompanyinfo.Weixinname; Scenic_intro = commodel.B2bcompanyinfo.Scenic_intro; } title = commodel.Com_name; } B2b_company_saleset pro = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (pro != null) { if (pro.Smalllogo != null && pro.Smalllogo != "") { comlogo = FileSerivce.GetImgUrl(pro.Smalllogo.ConvertTo <int>(0)); } } //获取微信平台端code string weixincode = Request["code"].ConvertTo <string>(""); //获取微信号和一次性密码 openid = Request["openid"].ConvertTo <string>(""); string weixinpass = Request["weixinpass"].ConvertTo <string>(""); //获得会员信息 GetCrmInfo(weixincode, openid, weixinpass); } //获取BANNER,及logo if (comid != 0) { //根据公司id得到 直销设置 B2b_company_saleset saleset = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (saleset != null) { logoimg = FileSerivce.GetImgUrl(saleset.Smalllogo.ConvertTo <int>(0)); } } //微信转发访问归属渠道 if (uid != 0)//必须记录转发用户信息才能继续统计 { //判断有转发人的渠道 var crmdata = new B2bCrmData(); var pro = crmdata.Readuser(uid, comid);//读取转发人用户信息 string zhuanfa_phone = ""; if (pro != null) { zhuanfa_phone = pro.Phone; } if (zhuanfa_phone != "") { //转发人手机存在 MemberChannelData channeldata = new MemberChannelData(); var channeinfo = channeldata.GetPhoneComIdChannelDetail(zhuanfa_phone, comid); //查询渠道 if (channeinfo != null) { //转发人渠道记录COOKI HttpCookie cookie = new HttpCookie("ZF_ChanneId"); //实例化HttpCookie类并添加值 cookie.Value = channeinfo.Id.ToString(); cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); } } } }
//给客户发送顾问的信息 public static void Sendweixinchient(string openid, int comid) { WeiXinBasic basic = new WeiXinBasicData().GetWxBasicByComId(comid); string company = ""; string channelname = ""; string name = ""; WxMessageLogData messagelogdata = new WxMessageLogData(); //var messageinfo = messagelogdata.GetWxMessageLogSendTime(comid, openid);//查询2小时内是否给渠道发送过消息 //if (messageinfo == 0) //{ //会员 MemberCardData carddata = new MemberCardData(); var userdata = new B2bCrmData(); var userinfo = userdata.GetB2bCrm(openid, comid); if (userinfo != null) { name = userinfo.Name; } var cardinfo = carddata.GetMemberCardByOpenId(openid); if (cardinfo != null) { //获取渠道 var channeldata = new MemberChannelData(); var channelinfo = channeldata.GetChannelDetail(int.Parse(cardinfo.IssueCard.ToString())); if (channelinfo != null) { channelname = channelinfo.Name; //渠道名称 if (channelinfo.Companyid == 0) //内部渠道 { B2bCompanyData comdata = new B2bCompanyData(); var cominfo = comdata.GetCompanyBasicById(comid); if (cominfo != null) { company = cominfo.Com_name; } } else { //外部合作单位,调取合作单位名称 var channelcompanydata = new MemberChannelcompanyData(); var channelcominfo = channelcompanydata.GetChannelCompany(channelinfo.Companyid.ToString()); if (channelcominfo != null) { company = channelcominfo.Companyname; } } } } if (channelname != "" && channelname != "默认渠道" && channelname != "微信注册" && channelname != "网站注册") { //微信客服 文本消息 string data = SendWxMsg(comid, openid, 1, "", name + "你好,我是您的服务顾问" + company + "的 " + channelname + " ,\n请直接在微信上给我语音或文字留言,我会在手机微信上看到留言并很快回复。您不信? 现在就试试…", "", basic.Weixinno); //微信模板消息 new Weixin_tmplmsgManage().WxTmplMsg_SubscribeActReward(comid, openid, name + "你好,我是您的服务顾问" + company + "的 " + channelname + " , \\n请直接在微信上给我语音或文字留言,我会在手机微信上看到留言并很快回复。您不信? 现在就试试…\\n", "向《我的服务顾问:" + channelname + "》微信咨询", DateTime.Now.ToString(), ""); WxMessageLog messagelog = new WxMessageLog(); messagelog.Comid = comid; messagelog.Weixin = openid; var messageedit = messagelogdata.EditWxMessageLog(messagelog);//插入日志 //顾问录入的 问候语音 int isreplymediasuc = 0;//发送语音消息状态:0失败;1成功 WXAccessToken m_accesstoken = WeiXinManage.GetAccessToken(basic.Comid, basic.AppId, basic.AppSecret); //根据用户微信得到其顾问微信,然后根据微信和标记得到最新的一条保存路径(注:已经上传过语音的即mediaid!="") Wxmedia_updownlog udlog = new Wxmedia_updownlogData().GetWxmedia_updownlog(openid, (int)Clientuptypemark.DownGreetVoice, basic.Comid); if (udlog == null) { isreplymediasuc = 0; } else { string media_id = new WxUploadDownManage().UploadMultimedia(m_accesstoken.ACCESS_TOKEN, "voice", udlog.savepath); if (media_id != "") { Wxmedia_updownlog uplog = new Wxmedia_updownlog { id = 0, mediaid = media_id, mediatype = "voice", savepath = udlog.savepath, created_at = ConvertDateTimeInt(DateTime.Now).ToString(), createtime = DateTime.Now, opertype = "up", operweixin = openid, clientuptypemark = (int)Clientuptypemark.DownGreetVoice,//上传多媒体信息 comid = basic.Comid, relativepath = udlog.relativepath, txtcontent = "", isfinish = 1 }; int uplogresult = new Wxmedia_updownlogData().Edituploadlog(uplog); if (uplogresult == 0) { isreplymediasuc = 0; } else { //resxml = "<xml><ToUserName><![CDATA[" + requestXML.FromUserName + "]]></ToUserName><FromUserName><![CDATA[" + requestXML.ToUserName + "]]></FromUserName><CreateTime>" + ConvertDateTimeInt(DateTime.Now) + "</CreateTime><MsgType><![CDATA[voice]]></MsgType><Voice><MediaId><![CDATA[" + media_id + "]]></MediaId></Voice></xml>"; isreplymediasuc = 1; SendWxMsg(comid, openid, 2, "", "", media_id, basic.Weixinno); } } else { isreplymediasuc = 0; } } ////如果发送语音失败,则发送客服消息 //if (isreplymediasuc == 0) //{ //} } //} }
public int isrightwxset = 1; //微信接口设置信息是否正确 #endregion protected void Page_Load(object sender, EventArgs e) { materialid = Request["materialid"].ConvertTo <int>(0); uid = Request["uid"].ConvertTo <int>(0); //获取IP地址 uip = CommonFunc.GetRealIP(); WxMaterial wxmaterial = new WxMaterialData().GetWxMaterial(materialid); string weixincode = Request["code"].ConvertTo <string>(""); openid = Request["openid"].ConvertTo <string>(""); #region 材信息 if (wxmaterial != null) { authorpayurl = wxmaterial.Authorpayurl; Author = wxmaterial.Author; datetime = wxmaterial.Operatime.ToString("yyyy-MM-dd"); comid = wxmaterial.Comid; id = wxmaterial.MaterialId; title = wxmaterial.Title; thisday = DateTime.Now.ToString("yyyy-MM-dd"); article = wxmaterial.Article; phone_tel = wxmaterial.Phone; Articleurl = wxmaterial.Articleurl; phone = "客服电话:"; price = wxmaterial.Price.ToString(); if (price == "0.00" || price == "0") { price = ""; } else { price = price.IndexOf(".") != -1 ? price.Substring(0, price.IndexOf(".")) : price; price = "¥" + price + "元-"; } summary = wxmaterial.Summary; var identityFileUpload = new FileUploadData().GetFileById(wxmaterial.Imgpath.ToString().ConvertTo <int>(0)); if (identityFileUpload != null) { if (identityFileUpload.Relativepath != "") { headPortraitImgSrc = fileUrl + identityFileUpload.Relativepath; } else { headPortraitImgSrc = ""; } } } #endregion #region 微信转发访问统计 if (uid != 0)//必须记录转发用户信息才能继续统计 { //查询是否有此cookies,有此cooki则证明已经访问过的用户 if (Request.Cookies["wxact" + materialid.ToString()] == null) { var forward = new MemberForwardingData().Forwardingcount(uid, materialid, uip, comid); if (forward > 0) { HttpCookie cookie = new HttpCookie("wxact" + materialid.ToString()); //实例化HttpCookie类并添加值 cookie.Value = "yes"; cookie.Expires = DateTime.Now.AddDays(365); Response.Cookies.Add(cookie); } } //判断有转发人的渠道 var crmdata = new B2bCrmData(); var pro = crmdata.Readuser(uid, comid);//读取转发人用户信息 string zhuanfa_phone = ""; if (pro != null) { zhuanfa_phone = pro.Phone; } if (zhuanfa_phone != "") { //转发人手机存在 MemberChannelData channeldata = new MemberChannelData(); var channeinfo = channeldata.GetPhoneComIdChannelDetail(zhuanfa_phone, comid); //查询渠道 if (channeinfo != null) { //转发人渠道记录COOKI HttpCookie cookie = new HttpCookie("ZF_ChanneId"); //实例化HttpCookie类并添加值 cookie.Value = channeinfo.Id.ToString(); cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); cookie = new HttpCookie("ZF_WxmaterialId"); //实例化HttpCookie类并添加值 cookie.Value = materialid.ToString(); cookie.Expires = DateTime.Now.AddDays(120); Response.Cookies.Add(cookie); } } } #endregion if (comid != 0) { #region 微信语音播放接口会用到 string url = Request.Url.ToString(); //根据传入参数openid、comid 得到 access_token、jsapi_ticket、noncestr、timestamp、 url(当前网页的URL,不包含#及其后面部分) WeiXinBasic basic = new WeiXinBasicData().GetWxBasicByComId(comid); if (basic != null) { appId = basic.AppId; timestamp = new WeixinVoiceUtil().CreatenTimestamp(); nonceStr = new WeixinVoiceUtil().CreatenNonce_str(); WXAccessToken maccesstoken = new WeixinVoiceUtil().GetAccessToken(comid, basic.AppId, basic.AppSecret); if (maccesstoken != null) { string jsapi_ticket = new WeixinVoiceUtil().GetTickect(maccesstoken.ACCESS_TOKEN, comid); if (jsapi_ticket == "") { isrightwxset = 0; } else { string beforesha1_signature = ""; signature = new WeixinVoiceUtil().GetSignature(jsapi_ticket, nonceStr, timestamp, url, out beforesha1_signature); } } else { isrightwxset = 0; } } else { isrightwxset = 0; } #endregion var commodel = B2bCompanyData.GetCompany(comid); if (commodel != null) { if (commodel.B2bcompanyinfo != null) { Wxfocus_url = commodel.B2bcompanyinfo.Wxfocus_url; Wxfocus_author = commodel.B2bcompanyinfo.Wxfocus_author; weixinname = commodel.B2bcompanyinfo.Weixinname; Scenic_intro = commodel.B2bcompanyinfo.Scenic_intro; } Com_name = commodel.Com_name; } B2b_company_saleset pro = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (pro != null) { if (pro.Smalllogo != null && pro.Smalllogo != "") { comlogo = FileSerivce.GetImgUrl(pro.Smalllogo.ConvertTo <int>(0)); } } if (weixincode != "") { int questtype = 2;//1=微信授权验证 DealUserinfo1("", weixincode, comid, questtype); } else if (openid != "") { string weixinpass = Request["weixinpass"].ConvertTo <string>(""); int questtype = 1; //1=一次性密码验证 DealUserinfo1(openid, weixinpass, comid, questtype); //判断用户微信号(1,点击的转发链接进来的2,点击微信菜单进来的);使用户处于登录状态(不包括点击转发链接的) } } }
public string nextperiodcaurl = "#"; //下一期地址 protected void Page_Load(object sender, EventArgs e) { var totalcount = 0; id = Request["id"].ConvertTo <int>(0); type = Request["type"].ConvertTo <int>(0); //获取访问的域名 string RequestDomin = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToLower(); //根据访问的域名获得公司信息 WeiXinBasic basicc = new WeiXinBasicData().GetWeiXinBasicByDomain(RequestDomin); if (basicc != null) { comid = basicc.Comid; //根据公司id得到公司logo地址和公司名称 comname = B2bCompanyData.GetCompany(comid).Com_name; B2b_company_saleset pro = B2bCompanySaleSetData.GetDirectSellByComid(comid.ToString()); if (pro != null) { if (pro.Smalllogo != null && pro.Smalllogo != "") { comlogo = FileSerivce.GetImgUrl(pro.Smalllogo.ConvertTo <int>(0)); } } if (id == 0)//如果没有期号传过来,默认显示最新期 { id = new WxMaterialData().GetNewestPerical(type, comid); } } int periodid = id; int salepromotetypeid = type; if (id != 0 && type != 0) { List <WxMaterial> list = new WxMaterialData().periodicaltypelist(1, 20, 10, periodid, salepromotetypeid, out totalcount); //Repeater1.DataSource = list; //Repeater1.DataBind(); periodical per = new WxMaterialData().selectperiodical(id); if (per != null) { periodca = per.Percal; if (periodca > 1) { int lastperiodca = periodca - 1; periodical lastper = new WxMaterialData().Selperiod(lastperiodca, type); lastperiodcaurl = "/M/period.aspx?id=" + lastper.Id + "&type=" + type; } time = per.Uptime.ToString("yyyy-MM-dd"); peryear = per.Peryear; } wxtype = new WxSalePromoteTypeData().GetWxMenu(salepromotetypeid).Typename; over = new WxMaterialData().selectWxsaletype(salepromotetypeid, comid).Percal; if (periodca < over) { int nextperiodca = periodca + 1; periodical nextper = new WxMaterialData().Selperiod(nextperiodca, type); nextperiodcaurl = "/M/period.aspx?id=" + nextper.Id + "&type=" + type; } } }