//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { int sucCount = 0; int errorCount = 0; BLL.wx_userweixin bll = new BLL.wx_userweixin(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.DeleteWeixin(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(MXEnums.ActionEnum.Delete.ToString(), "删除微信号信息" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("wxcodemgr.aspx", "keywords={0}", this.keywords), "Success"); }
protected void Page_Load(object sender, EventArgs e) { int wid = MyCommFun.RequestWid(); int actid = MyCommFun.RequestInt("aid"); string thisUrl = MyCommFun.getWebSite() + "/weixin/cashred/index.aspx?wid=" + wid + "&aid=" + actid; //授权 BLL.wx_userweixin bll = new BLL.wx_userweixin(); Model.wx_userweixin uWeiXinModel = bll.GetModel(wid); OAuth2BaseProc(uWeiXinModel, "index", thisUrl); //授权 end BLL.wx_xjhongbao_action actBll = new BLL.wx_xjhongbao_action(); act = actBll.GetPageHongBaoModel(actid, wid); if (act == null) { litActionRemark.Text = "该时间段没有该活动"; return; } //jssdk this.Title = act.act_name; fxModel.fxImg = MyCommFun.getWebSite() + "" + act.share_imgurl; fxModel.fxTitle = act.act_name; fxModel.fxContent = act.share_content; jssdkInit(uWeiXinModel); //jssdk end ActionBaseInfo(wid); }
/// <summary> /// 注册支付脚本 /// <param name="weixinId"></param> /// <param name="errorMessage"></param> /// </summary> public bool RegisterJWeiXin(int weixinId, out string errorMessage) { try { errorMessage = string.Empty; var ticket = WeiXinCRMComm.getJsApiTicket(weixinId, out errorMessage); if (!string.IsNullOrEmpty(errorMessage)) { return(false); } var wxModel = new BLL.wx_userweixin().GetModel(weixinId); if (wxModel == null) { errorMessage = "不合法的参数wid"; return(false); } appId = wxModel.AppId; nonceStr = JSSDKHelper.GetNoncestr(); timestamp = JSSDKHelper.GetTimestamp(); signature = new JSSDKHelper().GetSignature(ticket, nonceStr, timestamp, Request.Url.ToString()); IsRegister = 1; return(true); } catch (Exception exception) { errorMessage = exception.Message; return(false); } }
public void GetOpenId(string code, int wid, string url) { string openid = string.Empty; try { if (Session["openid"] == null) { BLL.wx_userweixin bll = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = bll.GetModel(wid); openid = OAuth2BaseProc(wxModel, "OpenId", code, url); if (!string.IsNullOrEmpty(openid)) { Session["openid"] = openid; } } Context.Response.Write(AjaxResult.Success(openid).ToCamelString()); } catch (UnAuthException oEx) { Context.Response.Write(AjaxResult.Error(oEx.RedirectUrl, oEx.Code).ToCamelString()); } catch (Exception ex) { Context.Response.Write(AjaxResult.Error("获取OpenID失败。").ToCamelString()); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int wid = 40; BLL.wx_userweixin wx = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = wx.GetModel(wid); string url = Common.MyCommFun.getWebSite(); string redirect_uri = url + "/api/oauth/weixin/index.aspx"; string reurl = XCWeiXin.Common.MyCommFun.RequestParam("reurl"); string appid = wxModel.AppId; WebClient client = new WebClient(); // client.Encoding = Encoding.UTF8; // var address = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + redirect_uri + "?reurl=" + reurl + "&response_type=code&scope=snsapi_base&state=1#wechat_redirect"; // string content = client.DownloadString(address); // string aa=""; //弹出授权页面(如在不弹出授权页面基础下未获得openid,弹出授权页面,提示用户授权) if (Request.QueryString["auth"] != null && Request.QueryString["auth"] != "" && Request.QueryString["auth"] == "1") { Response.Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + redirect_uri + "?reurl=" + reurl + "&response_type=code&scope=snsapi_userinfo&state=" + wid + "#wechat_redirect"); } else { //不弹出授权页面 Response.Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + redirect_uri + "?reurl=" + reurl + "&response_type=code&scope=snsapi_base&state=" + wid + "#wechat_redirect"); } } }
override protected void OnInit(EventArgs e) { base.OnInit(e); if (errInitTemplates != "") { Response.Write(errInitTemplates); return; } //1获得模版基本信息 BLL.wx_module_templates tBll = new BLL.wx_module_templates(); templateFileName = tBll.GetTemplatesFileNameByWid("shop", wid); if (templateFileName == null || templateFileName.Trim() == "") { errInitTemplates = "不存在该帐号或者该帐号尚未设置模版!"; Response.Write(errInitTemplates); Response.End(); return; } BLL.wx_userweixin bll = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = bll.GetModel(wid); string thisUrl = MyCommFun.getTotalUrl(); OAuth2BaseProc(wxModel, "cart", thisUrl); serverPath = MyCommFun.GetRootPath() + "/shop/templates/" + templateFileName + "/category.html"; ShopTemplateMgr template = new ShopTemplateMgr("/shop/templates/" + templateFileName, serverPath, wid); template.tType = TemplateType.Index; template.openid = MyCommFun.RequestOpenid(); template.OutPutHtml(wid); }
protected void Page_Load(object sender, EventArgs e) { //OAuth2 string thisUrl = MyCommFun.getWebSite() + "/weixin/restaurant/index.aspx" + Request.Url.Query; var bll = new BLL.wx_userweixin(); int widInt = MyCommFun.RequestWid(); Model.wx_userweixin uWeiXinModel = bll.GetModel(widInt); OAuth2BaseProc(uWeiXinModel, "index", thisUrl); this.shopid = string.IsNullOrEmpty(WebHelper.GetQueryString("shopid")) ? 0 : int.Parse(WebHelper.GetQueryString("shopid")); this.openid = string.IsNullOrEmpty(WebHelper.GetQueryString("openid")) ? "loseopenid" : WebHelper.GetQueryString("openid"); this.wid = string.IsNullOrEmpty(WebHelper.GetQueryString("wid")) ? "1" : WebHelper.GetQueryString("wid"); this.title = this.GetTitle(); if (!Page.IsPostBack) { if (this.shopid == 0) { this.hotelName = "无选定商铺"; } else { var shopinfo = new BLL.wx_diancai_shopinfo().GetModel(this.shopid); if (shopinfo == null) { return; } this.hotelName = shopinfo.hotelName; } } }
//关闭 protected void btnDelete_Click(object sender, EventArgs e) { // ChkAdminLevel("channel_" + this.channel_name + "_list", MXEnums.ActionEnum.Delete.ToString()); //检查权限 string btnText = btnDelete.Text; BLL.wx_userweixin uwBll = new BLL.wx_userweixin(); Model.wx_userweixin weixin = GetWeiXinCode(); if (btnText == "关闭自动回复") { //关闭 uwBll.UpdateField(weixin.id, "closeKW=1"); weixin.closeKW = true; AddAdminLog(MXEnums.ActionEnum.Delete.ToString(), weixin.id + "关闭了自动回复"); //记录日志 JscriptMsg("成功关闭了自动回复!", Utils.CombUrlTxt("reqrespData.aspx", "keywords={0}", txtKeywords.Text), "Success"); } else { //开启 uwBll.UpdateField(weixin.id, "closeKW=0"); weixin.closeKW = false; AddAdminLog(MXEnums.ActionEnum.Delete.ToString(), weixin.id + "开启了自动回复"); //记录日志 JscriptMsg("成功开启了自动回复!", Utils.CombUrlTxt("reqrespData.aspx", "keywords={0}", txtKeywords.Text), "Success"); } Session["nowweixin"] = weixin; }
protected void Page_Load(object sender, EventArgs e) { wid = MyCommFun.RequestInt("wid"); //授权 BLL.wx_userweixin bll = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = bll.GetModel(wid); string code = MyCommFun.QueryString("code"); if (code == null || code.Trim() == "") { string thisUrl = MyCommFun.getTotalUrl(); string newUrl = OAuthApi.GetAuthorizeUrl(wxModel.AppId, thisUrl, "fukuan", OAuthScope.snsapi_base); Response.Redirect(newUrl); } else { var result = OAuthApi.GetAccessToken(wxModel.AppId, wxModel.AppSecret, code); openid = result.openid; } //授权结束 // logBll.AddLog("【微支付】微信预定", "paypage.aspx Page_Load", " 授权结束openid= " + openid, 1); try { int otid = MyCommFun.RequestInt("orderid"); otid_str = otid.ToString(); rpage = "/api/payment/paypage.aspx?showwxpaytitle=1&paytype=shop&wid=" + wid + "&openid=" + openid + "&orderid=" + otid_str; if (code == null || code.Trim() == "" || openid == "" || otid == 0 || wid == 0) { return; } //expireMinute = MyCommFun.RequestInt("expireminute"); //if (expireMinute == 0) //{ // expireMinute = 30; //} //else if (expireMinute == -1) //{ //如果为-1,则有限期间为1年 // expireMinute = 60 * 12 * 365; //} BLL.orders otBll = new BLL.orders(); Model.orders orderEntity = otBll.GetModel(otid, wid); WXLogs.AddLog("【微支付】微信预定", "paypage.aspx Page_Load", "orderEntity.order_no: " + orderEntity.order_no + "|orderEntity.order_amount:" + orderEntity.order_amount, 1); litout_trade_no.Text = orderEntity.order_no; litMoney.Text = orderEntity.order_amount.ToString(); litDate.Text = orderEntity.add_time.ToString(); //WxPayData(orderEntity.order_amount, orderEntity.id.ToString(), orderEntity.order_no, code);//老的接口 WxPayDataV3(orderEntity.order_amount, orderEntity.id.ToString(), orderEntity.order_no, code); } catch (Exception ex) { WXLogs.AddLog("【微支付】微信预定", "paypage.aspx Page_Load", "ex: " + ex.Message, 1); //MessageBox.ShowAndRedirect(this, "支付有问题:" + ex.Message, "/shop/index.aspx?wid=" + wid); } }
/// <summary> /// 关注时候处理 /// </summary> public string weipaiSubscribe(string openid, int wid) { BLL.wx_userweixin uwbll = new BLL.wx_userweixin(); string wxId = uwbll.GetwxId(wid);//原始Id if (wxId == null || wxId.Trim() == "") { return("wid参数错误"); } try { WeiXinPF.BLL.wx_paizhao_setting setBll = new WeiXinPF.BLL.wx_paizhao_setting(); WeiXinPF.Model.wx_paizhao_setting model = setBll.GetModelByWid(wid); if (model == null || model.isOpen == false) { return("未开启"); } Dictionary <string, string> parameters = new Dictionary <string, string>(); string url = model.initApiUrl;// "http://wphoto.betterwood.com:8080/Server/wechat/userinit.action"; string userid = openid; string sourceid = wxId;// "gh_e2d7eb82cb50"; 该用户的来源,即关注的哪一个微信公众账号)、(微信号)原始ID string timestamp = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString(); string v = "2000"; string signature = ""; parameters.Add("userid", openid); parameters.Add("sourceid", sourceid); parameters.Add("v", "2000"); parameters.Add("timestamp", timestamp); signature = GetBizSign(parameters); string postParam = "userid=" + userid + "&sourceid=" + sourceid + "×tamp=" + timestamp + "&v=" + v + "&signature=" + signature; string ret = Utils.HttpPost(url, postParam); Dictionary <string, object> dict = MyCommFun.JsonToDictionary(ret); string returnCode = dict["returncode"].ToString(); if (returnCode == "200") { //成功 WXLogs.AddLog(wid, "微拍用户关注时候的接口", "weipaiSubscribe", "奥尔图微拍接口调用成功了", 1); } else { WXLogs.AddLog(wid, "微拍用户关注时候的接口", "weipaiSubscribe", "奥尔图微拍接口调用失败:" + dict["returnmessage"].ToString(), 0); } return(returnCode); } catch (Exception ex) { WXLogs.AddLog(wid, "微拍用户关注时候的接口", "weipaiSubscribe", "报错:" + ex.Message, 0); return(ex.Message); } }
public string OrderQuery() { int orderId = MyCommFun.RequestInt("orderid"); int wid = MyCommFun.RequestInt("wid"); string code = MyCommFun.RequestParam("code"); string state = MyCommFun.RequestParam("state"); BLL.wx_payment_wxpay wxPayBll = new BLL.wx_payment_wxpay(); Model.wx_payment_wxpay paymentInfo = wxPayBll.GetModelByWid(wid); BLL.wx_userweixin wx = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = wx.GetModel(wid); BLL.orders otBll = new BLL.orders(); Model.orders orderEntity = otBll.GetModel(orderId, wid); litout_trade_no = orderEntity.order_no; string nonceStr = TenPayV3Util.GetNoncestr(); RequestHandler packageReqHandler = new RequestHandler(null); //设置package订单参数 packageReqHandler.SetParameter("appid", paymentInfo.appId); //公众账号ID packageReqHandler.SetParameter("mch_id", paymentInfo.partnerId); //商户号 packageReqHandler.SetParameter("transaction_id", ""); //填入微信订单号 packageReqHandler.SetParameter("out_trade_no", litout_trade_no); //填入商家订单号 packageReqHandler.SetParameter("nonce_str", nonceStr); //随机字符串 string sign = packageReqHandler.CreateMd5Sign("key", paymentInfo.paySignKey); packageReqHandler.SetParameter("sign", sign); //签名 string data = packageReqHandler.ParseXML(); var result = TenPayV3.OrderQuery(data); var res = XDocument.Parse(result); openid = res.Element("xml").Element("sign").Value; string transaction_id = res.Element("xml").Element("sign").Value; openids = res.Element("xml").Element("openid").Value; bank_type = res.Element("xml").Element("bank_type").Value; if (bank_type == "CNY") { bank_type = "钱包零钱"; } if (bank_type == "CFT") { bank_type = "银行卡"; } total_fee = res.Element("xml").Element("total_fee").Value; time_end = res.Element("xml").Element("time_end").Value; out_trade_no = res.Element("xml").Element("out_trade_no").Value; transaction_id = res.Element("xml").Element("transaction_id").Value; result_code = res.Element("xml").Element("result_code").Value; return(openid); }
/// <summary> /// 获取用户基本信息 /// </summary> /// <param name="wid"></param> /// <param name="state"></param> /// <returns></returns> protected OAuthUserInfo GetUser(int wid, string state, string code, string targetUrl) { OAuthUserInfo user = null; #if DEBUG string isTest = MyCommFun.getAppSettingValue("isOAuthTest"); if (isTest == "1") { user = new OAuthUserInfo() { openid = "obzTsw4p1nhpl97G1xJwKicDNsiQ", nickname = "谷巍", sex = 1, city = "广州", province = "广东", country = "中国", headimgurl = "http://wx.qlogo.cn/mmopen/PiajxSqBRaEJrWO5PQSm2auIaHPNnTPCZAfAwNyXVsUADnVhInAYbkYo70cpvEujyOXBibwAUEGpULiafevgqQ9dg/0", }; return(user); } #endif string error; var accessToken = WeiXinPF.WeiXinComm.WeiXinCRMComm.getAccessToken(wid, out error); if (string.IsNullOrEmpty(error)) { BLL.wx_userweixin bll = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = bll.GetModel(wid); var openId = OAuth2BaseProc(wxModel, state, code, targetUrl); var userInfo = UserApi.Info(accessToken, openId); if (userInfo != null) { user = new OAuthUserInfo() { openid = userInfo.openid, city = userInfo.city, country = userInfo.country, headimgurl = userInfo.headimgurl, nickname = userInfo.nickname, province = userInfo.province }; } //user = OAuthApi.GetUserInfo(accessToken, openId); } else { throw new Exception(error); } return(user); }
protected void Page_Load(object sender, EventArgs e) { base.OnInit(e); if (errInitTemplates != "") { Response.Write(errInitTemplates); return; } //1获得模版基本信息 BLL.wx_module_templates tBll = new BLL.wx_module_templates(); templateFileName = tBll.GetTemplatesFileNameByWid("shop", wid); if (templateFileName == null || templateFileName.Trim() == "") { errInitTemplates = "不存在该帐号或者该帐号尚未设置模版!"; Response.Write(errInitTemplates); Response.End(); return; } //授权 int orderId = MyCommFun.RequestInt("orderid"); BLL.wx_userweixin bll = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = bll.GetModel(wid); string thisUrl = MyCommFun.getWebSite() + "/shop/order_detail.aspx?wid=" + wid + "&orderid=" + orderId; OAuth2BaseProc(wxModel, "order_detail", thisUrl); //授权结束 BLL.wx_shop_user_addr uAddrBll = new BLL.wx_shop_user_addr(); IList <Model.wx_shop_user_addr> uaddrList = uAddrBll.GetOpenidAddr(openid, wid); if (uaddrList == null || uaddrList.Count <= 0 || uaddrList[0].id <= 0) { //该微信用户没有添加地址 Response.Redirect("/shop/editaddr.aspx?wid=" + wid + "&openid=" + openid + "&frompage=confirmOrder.aspx"); // MessageBox.ResponseScript(this, "window.location.href =/shop/editaddr.aspx?wid=" + wid + "&openid=" + openid + "&frompage=confirmOrder.aspx"); return; } serverPath = MyCommFun.GetRootPath() + "/shop/templates/" + templateFileName + "/order_detail.html"; ShopTemplateMgr template = new ShopTemplateMgr("/shop/templates/" + templateFileName, serverPath, wid); template.tType = TemplateType.orderDetail; template.openid = openid; template.OutPutHtml(wid); }
/// <summary> /// 微信退单 /// </summary> /// <param name="dingdan"></param> /// <param name="dto"></param> /// <param name="returnMsg"></param> /// <returns></returns> private bool WeChatRefund(wx_hotel_dingdan dingdan, TuidanDto dto, int wid, out string returnMsg) { bool result = false; returnMsg = null; var refundResult = dingdanbll.GetWeChatRefundParams(wid, dingdan.hotelid.Value, dingdan.id, dto.refundCode); //使用系统订单号退单 if (refundResult != null && refundResult.Tables.Count > 0 && refundResult.Tables[0].Rows.Count > 0) { var orderNumber = refundResult.Tables[0].Rows[0]["orderNumber"].ToString(); var transaction_id = refundResult.Tables[0].Rows[0]["transaction_id"].ToString(); var refundAmount = Convert.ToInt32(refundResult.Tables[0].Rows[0]["refundAmount"]); var payAmount = Convert.ToInt32(refundResult.Tables[0].Rows[0]["payAmount"]); var wxModel = new BLL.wx_userweixin().GetModel(wid); var payInfo = new BLL.wx_payment_wxpay().GetModelByWid(wid); var requestHandler = new RequestHandler(null); requestHandler.SetParameter("out_trade_no", orderNumber); //requestHandler.SetParameter("transaction_id", transaction_id); requestHandler.SetParameter("out_refund_no", dto.refundCode); requestHandler.SetParameter("appid", wxModel.AppId); requestHandler.SetParameter("mch_id", payInfo.mch_id);//商户号 requestHandler.SetParameter("nonce_str", Guid.NewGuid().ToString().Replace("-", "")); //退款金额 if (PayHelper.IsDebug) { requestHandler.SetParameter("total_fee", (payAmount).ToString()); requestHandler.SetParameter("refund_fee", (refundAmount).ToString()); } else { requestHandler.SetParameter("total_fee", (payAmount * 100).ToString()); requestHandler.SetParameter("refund_fee", (refundAmount * 100).ToString()); } requestHandler.SetParameter("op_user_id", wxModel.AppId); requestHandler.SetParameter("sign", requestHandler.CreateMd5Sign("key", payInfo.paykey)); var refundInfo = TenPayV3Helper.Refund(requestHandler.ParseXML(), string.Format(@"{0}{1}", AppDomain.CurrentDomain.BaseDirectory, payInfo.certInfoPath), payInfo.cerInfoPwd); var refundOrderResponse = new RefundOrderResponse(refundInfo); result = refundOrderResponse.IsSuccess; returnMsg = refundOrderResponse.return_msg; } return(result); }
protected void Page_Load(object sender, EventArgs e) { var thisUrl = MyCommFun.getWebSite() + "/weixin/WeChatPay/getopenId.aspx" + Request.Url.Query; var widInt = MyCommFun.RequestWid(); var bll = new BLL.wx_userweixin(); var uWeiXinModel = bll.GetModel(widInt); if (uWeiXinModel == null) { throw new Exception("不合法的参数wid"); } OAuth2BaseProc(uWeiXinModel, "MyOrderCenter", thisUrl); }
public void GetCouponList(string code, int wid, string url) { string openid = string.Empty; try { var service = new CouponService(); if (Session["openid"] == null) { BLL.wx_userweixin bll = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = bll.GetModel(wid); openid = OAuth2BaseProc(wxModel, "coupon", code, url); if (!string.IsNullOrEmpty(openid)) { Session["openid"] = openid; } } else { openid = Session["openid"] as string; } CouponListDTO dto = service.GetCouponList(wid, openid); if (dto != null) { var data = new { lists = dto, openid = openid }; Context.Response.Write(AjaxResult.Success(data)); } else { throw new Exception("参数异常"); } } catch (UnAuthException jsEx) { Context.Response.Write(AjaxResult.Error(jsEx.RedirectUrl, jsEx.Code)); } catch (Exception ex) { var s = ""; if (ex.InnerException != null) { s = ex.InnerException.Message; } Context.Response.Write(AjaxResult.Error(s)); } }
override protected void OnInit(EventArgs e) { base.OnInit(e); if (errInitTemplates != "") { Response.Write(errInitTemplates); return; } //1获得模版基本信息 BLL.wx_module_templates tBll = new BLL.wx_module_templates(); templateFileName = tBll.GetTemplatesFileNameByWid("shop", wid); if (templateFileName == null || templateFileName.Trim() == "") { errInitTemplates = "不存在该帐号或者该帐号尚未设置模版!"; Response.Write(errInitTemplates); Response.End(); return; } //授权 BLL.wx_userweixin bll = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = bll.GetModel(wid); //string openid = ""; //string code = MyCommFun.QueryString("code"); //if (code == null || code.Trim() == "") //{ // string thisUrl = MyCommFun.getWebSite() + "/shop/cart.aspx?wid=" + wid; // string newUrl = OAuthApi.GetAuthorizeUrl(wxModel.AppId, thisUrl, "reg", OAuthScope.snsapi_base); // Response.Redirect(newUrl); //} //else //{ // var result = OAuthApi.GetAccessToken(wxModel.AppId, wxModel.AppSecret, code); // openid = result.openid; //} string thisUrl = MyCommFun.getWebSite() + "/shop/cart.aspx?wid=" + wid; OAuth2BaseProc(wxModel, "cart", thisUrl); //授权结束 serverPath = MyCommFun.GetRootPath() + "/shop/templates/" + templateFileName + "/cart.html"; ShopTemplateMgr template = new ShopTemplateMgr("/shop/templates/" + templateFileName, serverPath, wid); template.tType = TemplateType.Cart; template.openid = openid; template.OutPutHtml(wid); }
protected void Page_Load(object sender, EventArgs e) { //OAuth2认证 string thisUrl = MyCommFun.getWebSite() + "/weixin/restaurant/diancai_shoppingCart.aspx" + Request.Url.Query; int widInt = MyCommFun.RequestWid(); var bll = new BLL.wx_userweixin(); Model.wx_userweixin uWeiXinModel = bll.GetModel(widInt); OAuth2BaseProc(uWeiXinModel, "index", thisUrl); if (!Page.IsPostBack) { BindFormControl(); } }
protected void Page_Load(object sender, EventArgs e) { #if DEBUG openid = "obzTsw5qxlbwGYYZJC9b-91J-X1Y"; #else var thisUrl = MyCommFun.getWebSite() + "/weixin/WeChatPay/MyOrderCenter.aspx" + Request.Url.Query; var widInt = MyCommFun.RequestWid(); var bll = new BLL.wx_userweixin(); var uWeiXinModel = bll.GetModel(widInt); if (uWeiXinModel == null) { throw new Exception("不合法的参数wid"); } OAuth2BaseProc(uWeiXinModel, "MyOrderCenter", thisUrl); #endif }
protected void Page_Load(object sender, EventArgs e) { int wid = 43; BLL.wx_userweixin wx = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = wx.GetModel(wid); int hc = this.GetHashCode(); var returnUrl = MyCommFun.getWebSite() + "/api/oauth/Weixin_oauth/Info.aspx?wid=" + wid + ""; var state = string.Format("{0}|{1}", "zql", hc); var url = OAuthApi.GetAuthorizeUrl(wxModel.AppId, returnUrl, state, OAuthScope.snsapi_userinfo); Response.Redirect(url); }
private void ShowInfo(int _id) { Model.wx_userweixin weixin = GetWeiXinCode(); BLL.payment bll = new BLL.payment(); model = bll.GetModel(_id); txtTitle.Text = model.title; if (model.is_lock == 0) { cbIsLock.Checked = true; } else { cbIsLock.Checked = false; } txtSortId.Text = model.sort_id.ToString(); rblPoundageType.SelectedValue = model.poundage_type.ToString(); txtPoundageAmount.Text = model.poundage_amount.ToString(); txtImgUrl.Text = model.img_url; txtRemark.Text = model.remark; if (model.pTypeId == 2) { //支付宝 Model.wx_payment_alipay alipay = aliBll.GetModelList("wid=" + weixin.id)[0]; txtAlipaySellerEmail.Text = alipay.ownerName; txtAlipayPartner.Text = alipay.partner; txtAlipayKey.Text = alipay.e_key; txtprivate_key.Text = alipay.private_key; txtpublic_key.Text = alipay.public_key; hidPayId.Value = alipay.id.ToString(); } else if (model.pTypeId == 3) { //微信支付 Model.wx_payment_wxpay wxpay = wxBll.GetModelByWid(weixin.id); txtpaySignKey.Text = wxpay.paySignKey; txtTenpayPartnerId.Text = wxpay.partnerId; txtTenpayKey.Text = wxpay.partnerKey; hidPayId.Value = wxpay.id.ToString(); rblQuicklyFH.SelectedValue = wxpay.quicklyFH.ToString().ToLower() == "true" ? "1" : "0"; BLL.wx_userweixin uwBll = new BLL.wx_userweixin(); Model.wx_userweixin uwEneity = uwBll.GetModel(weixin.id); lblAppId.Text = uwEneity.AppId; } }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("manager_list", MXEnums.ActionEnum.Delete.ToString()); //检查权限 BLL.wx_userweixin wBll = new BLL.wx_userweixin(); int sucCount = 0; int errorCount = 0; BLL.manager bll = new BLL.manager(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { int hasNum = wBll.GetUserWxNumCount(id); if (hasNum > 0) { JscriptMsg("该用户已经添加微信号,无法删除!", "back", "Error"); return; } } } for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { int hasNum = wBll.GetUserWxNumCount(id); if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(MXEnums.ActionEnum.Delete.ToString(), "删除用户" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("manager_list.aspx", "keywords={0}", this.keywords), "Success"); }
void showInfo() { BLL.wx_wq_fuhuiSys fhBll = new BLL.wx_wq_fuhuiSys(); BLL.article aBll = new BLL.article(); BLL.wx_userweixin uw = new BLL.wx_userweixin(); this.Title = uw.GetModel(wid).wxName; //首页幻灯片 this.imgList.DataSource = aBll.GetList(10, " wid=" + wid, "id asc,add_time asc"); this.imgList.DataBind(); this.rptDian.DataSource = aBll.GetList(10, " wid=" + wid, "id asc,add_time asc"); this.rptDian.DataBind(); fhModel = fhBll.GetModelList("wid=" + wid)[0]; StringBuilder sb = new StringBuilder(); string canshu = "?wid=" + wid + "&openid=" + openid; //经销车型 string jxcxUrl = fhModel.jscxurl == "" ? "ppList.aspx" + canshu : fhModel.jscxurl + canshu; sb.Append("<li><a href=\"" + jxcxUrl + "\" style=\"background-image: url(" + fhModel.jscxpic + ");" + "background-size: 100% 100%;\"><label>" + fhModel.jscx + "</label></a></li>"); //销售顾问 string xsgwUrl = fhModel.xsgwurl == "" ? "xiaoshouMgr.aspx" + canshu : fhModel.xsgw + canshu; sb.Append("<li><a href=\"" + xsgwUrl + "\" style=\"background-image: url(" + fhModel.xsgwpic + ");" + "background-size: 100% 100%;\"><label>" + fhModel.xsgw + "</label></a></li>"); //在线预约 string zxyyUrl = fhModel.zxyyurl == "" ? "yyBaoyang.aspx" + canshu + "&type=2" : fhModel.zxyy + canshu + "&type=2"; sb.Append("<li><a href=\"" + zxyyUrl + "\" style=\"background-image: url(" + fhModel.zxyypic + ");" + "background-size: 100% 100%;\"><label>" + fhModel.zxyy + "</label></a></li>"); //车主关怀 string czghUrl = fhModel.czghurl == "" ? "czGuanhuai.aspx" + canshu : fhModel.czgh + canshu; sb.Append("<li><a href=\"" + czghUrl + "\" style=\"background-image: url(" + fhModel.czghpic + ");" + "background-size: 100% 100%;\"><label>" + fhModel.czgh + "</label></a></li>"); //实用工具 string sygjUrl = fhModel.sygjurl == "" ? "syGongju.aspx" + canshu : fhModel.sygj + canshu; sb.Append("<li><a href=\"" + sygjUrl + "\" style=\"background-image: url(" + fhModel.sygjpic + ");" + "background-size: 100% 100%;\"><label>" + fhModel.sygj + "</label></a></li>"); this.litMenu.Text = sb.ToString(); }
override protected void OnInit(EventArgs e) { base.OnInit(e); if (errInitTemplates != "") { Response.Write(errInitTemplates); return; } //1获得模版基本信息04e11d01b9df2865 BLL.wx_module_templates tBll = new BLL.wx_module_templates(); templateFileName = tBll.GetTemplatesFileNameByWid("shop", wid); if (templateFileName == null || templateFileName.Trim() == "") { errInitTemplates = "不存在该帐号或者该帐号尚未设置模版!"; Response.Write(errInitTemplates); Response.End(); return; } //授权 BLL.wx_userweixin bll = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = bll.GetModel(wid); string type = MyCommFun.QueryString("type"); if (type != "") { type = "&type=new"; } string thisUrl = MyCommFun.getWebSite() + "/shop/list.aspx?wid=" + wid + "&cid=" + MyCommFun.RequestInt("cid") + type; OAuth2BaseProc(wxModel, "list", thisUrl); //授权结束 serverPath = MyCommFun.GetRootPath() + "/shop/templates/" + templateFileName + "/list.html"; ShopTemplateMgr template = new ShopTemplateMgr("/shop/templates/" + templateFileName, serverPath, wid); template.tType = TemplateType.Class; template.openid = openid; template.OutPutHtml(wid); DataSet ds = new DataSet(); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { int sucCount = 0; int errorCount = 0; BLL.wx_userweixin bll = new BLL.wx_userweixin(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.DeleteWeixin(id)) { sucCount += 1; } else { errorCount += 1; } } } //bool isAgent = false; //BLL.wx_agent_info aBll = new BLL.wx_agent_info(); //Model.manager adminEntity = GetAdminInfo(); //取得管理员信息 //Model.wx_agent_info agent = new Model.wx_agent_info(); //if (adminEntity.agentLevel > 0) //{ // isAgent = true; // agent = aBll.GetAgentModel(adminEntity.id); //} //if (isAgent && agent != null) //{ // 如果为代理商,则将起微帐号数量减掉 // agent.wcodeNum -= sucCount; // aBll.Update(agent); //} AddAdminLog(MXEnums.ActionEnum.Delete.ToString(), "删除微信号信息" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("wxcodemgr.aspx", "keywords={0}", this.keywords), "Success"); }
protected void Page_Load(object sender, EventArgs e) { int wid = MyCommFun.RequestInt("wid"); BLL.wx_userweixin wx = new BLL.wx_userweixin(); Model.wx_userweixin wxModel = wx.GetModel(wid); if (string.IsNullOrEmpty(code)) { Response.Write("您拒绝了授权!"); return; } if (!state.Contains("|")) { //这里的state其实是会暴露给客户端的,验证能力很弱,这里只是演示一下 //实际上可以存任何想传递的数据,比如用户ID,并且需要结合例如下面的Session["OAuthAccessToken"]进行验证 Response.Write("验证失败!请从正规途径进入!1001"); return; } var openIdResult = OAuthApi.GetAccessToken(wxModel.AppId, wxModel.AppSecret, code); if (openIdResult.errcode != ReturnCode.请求成功) { Response.Write("错误:" + openIdResult.errmsg); return; } else { var result = OAuthApi.GetUserInfo(openIdResult.access_token, openIdResult.openid); name = result.nickname; image = result.headimgurl; Session["name"] = name; Session["imageheader"] = image; HttpCookie cookie = new HttpCookie("open_id1"); cookie.Value = result.openid; cookie.Expires = DateTime.Now.AddDays(3650); HttpContext.Current.Response.Cookies.Add(cookie); Response.Redirect("/hugongll/index.aspx?open_ids=" + result.openid + ""); } }
public ShopBasePage() { serverPath = ""; templateFileName = ""; errInitTemplates = ""; wid = MyCommFun.RequestInt("wid"); if (wid == 0) { errInitTemplates = "链接地址或者参数错误!"; return; } BLL.wx_userweixin wuwBll = new BLL.wx_userweixin(); bool isExist = wuwBll.wxCodeLegal(wid); if (!isExist) { errInitTemplates = "账号已过期或已被禁用!"; return; } }
public void WeChatConfigInit(int wid, string url) { try { string errorString; var ticket = WeiXinCRMComm.getJsApiTicket(wid, out errorString); if (!string.IsNullOrEmpty(errorString)) { HttpContext.Current.Response.Write(AjaxResult.Error(errorString)); } else { var wxModel = new BLL.wx_userweixin().GetModel(wid); if (wxModel == null) { HttpContext.Current.Response.Write(AjaxResult.Error("不合法的参数wid")); return; } var noncestr = JSSDKHelper.GetNoncestr(); var timestamp = JSSDKHelper.GetTimestamp(); var singature = new JSSDKHelper().GetSignature(ticket, noncestr, timestamp, url); var result = new { appId = wxModel.AppId, timestamp = timestamp, nonceStr = noncestr, signature = singature }; HttpContext.Current.Response.Write(AjaxResult.Success(result)); } } catch (Exception exception) { HttpContext.Current.Response.Write(AjaxResult.Error(exception.Message)); } }
public void WeChatConfigInit(int wid, string url) { try { //获取当前对象实体 BLL.wx_userweixin bll = new BLL.wx_userweixin(); Model.wx_userweixin uWeiXinModel = bll.GetModel(wid); //初始话jsskd var signatureDto = jssdkInit(uWeiXinModel, url); Context.Response.Write(AjaxResult.Success(signatureDto)); } catch (Exception ex) { var s = ""; if (ex.InnerException != null) { s = ex.InnerException.Message; } Context.Response.Write(AjaxResult.Error(s)); } }
protected void Page_Load(object sender, EventArgs e) { // hotelid = MyCommFun.RequestInt("hotelid"); openid = MyCommFun.QueryString("openid"); roomid = MyCommFun.RequestInt("roomid"); wid = MyCommFun.RequestInt("wid"); if (!string.IsNullOrEmpty(MyCommFun.QueryString("type"))) { type = MyCommFun.QueryString("type"); } var userbll = new BLL.wx_userweixin(); Model.wx_userweixin uWeiXinModel = userbll.GetModel(wid); OAuth2BaseProc(uWeiXinModel, "hotel_userOrder", Request.Url.AbsoluteUri); if (!Page.IsPostBack) { menuStr = GetMenuStr(openid, wid, type); BLL.wx_hotels_info infobll = new BLL.wx_hotels_info(); Model.wx_hotels_info info = new Model.wx_hotels_info(); BLL.wx_hotel_dingdan dingdanbll = new BLL.wx_hotel_dingdan(); DataSet dr = dingdanbll.GetUserOrderList(openid, wid, type); if (dr.Tables[0].Rows.Count > 0) { numdingdan = dr.Tables[0].Rows.Count; } else { numdingdan = 0; } List(openid, wid); } }
/// <summary> /// 选择某一个微信公众帐号,并且将其保存到session里 /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "toIndex": { int wid = int.Parse(e.CommandArgument.ToString()); Model.wx_userweixin weixin = bll.GetModel(wid); Session["nowweixin"] = weixin; Utils.WriteCookie("nowweixinId", "MxWeiXinPF", e.CommandArgument.ToString()); Response.Write("<script>parent.location.href='/admin/index.aspx'</script>"); } break; case "delete": { int wid = int.Parse(e.CommandArgument.ToString()); BLL.wx_userweixin bll = new BLL.wx_userweixin(); bll.Delete(wid); JscriptMsg("删除公众号成功!", "?", "Success"); } break; } }
public bool IsWeiXinCode() { //如果Session为Null if (Session["nowweixin"] != null) { return true; } else { //检查Cookies string uweixinId = Utils.GetCookie("nowweixinId", "MxWeiXinPF"); if (uweixinId != "") { BLL.wx_userweixin bll = new BLL.wx_userweixin(); Model.wx_userweixin model = bll.GetModel(int.Parse(uweixinId)); if (model != null) { Session["nowweixin"] = model; return true; } } } return false; }
/// <summary> /// 微信退单 /// </summary> /// <param name="dingdan"></param> /// <param name="dto"></param> /// <param name="returnMsg"></param> /// <returns></returns> private bool WeChatRefund(wx_hotel_dingdan dingdan, TuidanDto dto, int wid, out string returnMsg) { bool result = false; returnMsg = null; var refundResult = _hotelOrderService.GetWeChatRefundParams(wid, dingdan.hotelid.Value, dingdan.id, dto.refundCode); //使用系统订单号退单 if (refundResult != null && refundResult.Tables.Count > 0 && refundResult.Tables[0].Rows.Count > 0) { var orderNumber = refundResult.Tables[0].Rows[0]["orderNumber"].ToString(); var transaction_id = refundResult.Tables[0].Rows[0]["transaction_id"].ToString(); var refundAmount = Convert.ToInt32(refundResult.Tables[0].Rows[0]["refundAmount"]); var payAmount = Convert.ToInt32(refundResult.Tables[0].Rows[0]["payAmount"]); var wxModel = new BLL.wx_userweixin().GetModel(wid); var payInfo = new BLL.wx_payment_wxpay().GetModelByWid(wid); var requestHandler = new RequestHandler(null); requestHandler.SetParameter("out_trade_no", orderNumber); //requestHandler.SetParameter("transaction_id", transaction_id); requestHandler.SetParameter("out_refund_no", dto.refundCode); requestHandler.SetParameter("appid", wxModel.AppId); requestHandler.SetParameter("mch_id", payInfo.mch_id);//商户号 requestHandler.SetParameter("nonce_str", Guid.NewGuid().ToString().Replace("-", "")); //退款金额 if (PayHelper.IsDebug) { requestHandler.SetParameter("total_fee", (payAmount).ToString()); requestHandler.SetParameter("refund_fee", (refundAmount).ToString()); } else { requestHandler.SetParameter("total_fee", (payAmount * 100).ToString()); requestHandler.SetParameter("refund_fee", (refundAmount * 100).ToString()); } requestHandler.SetParameter("op_user_id", wxModel.AppId); requestHandler.SetParameter("sign", requestHandler.CreateMd5Sign("key", payInfo.paykey)); var refundInfo = TenPayV3Helper.Refund(requestHandler.ParseXML(), string.Format(@"{0}{1}", AppDomain.CurrentDomain.BaseDirectory, payInfo.certInfoPath), payInfo.cerInfoPwd); var refundOrderResponse = new RefundOrderResponse(refundInfo); result = refundOrderResponse.IsSuccess; returnMsg = refundOrderResponse.return_msg; } return result; }