/// <summary> /// 跟微信同 /// </summary> /// <returns></returns> public ActionResult WeChatCode() { string code = QueryString.SafeQ("wechatcode"); VWMemberEntity mem = new VWMemberEntity(); mem = MemberBLL.Instance.GetVWMember(memid); if (!string.IsNullOrEmpty(code) && string.IsNullOrEmpty(mem.WeChat)) { MemWeChatMsgEntity shortmsg = WeiXinJsSdk.Instance.GetWeChatShortInfo(code); if (!string.IsNullOrEmpty(shortmsg.OpenId) && !string.IsNullOrEmpty(shortmsg.UnionId)) { MemWeChatMsgEntity entity = new MemWeChatMsgEntity(); entity.AppId = WeiXinConfig.GetAppId(); entity.Status = (int)WeChatStatus.ShortInfo; entity.UnionId = shortmsg.UnionId; entity.OpenId = shortmsg.OpenId; MemWeChatMsgBLL.Instance.WeChatLogin(entity); MemberBLL.Instance.BindMemWeChat(memid, shortmsg.UnionId, mem.TimeStampTab); mem = MemberBLL.Instance.GetVWMember(memid); } } ViewBag.VWMember = mem; return(View()); }
/// <summary> /// 通知供应商查看询价订单网址 微信入口自动封装后的网址 /// </summary> /// <param name="ordercode"></param> /// <returns></returns> public static string InquiryOrderSendWeChat(string ordercode) { string redirecturl = InquiryOrderUrl(ordercode); //int navid = WeChatNavigationBLL.Instance.GetIdByUrl(redirecturl); //string resulturl = string.Format(WeiXinConfig.URL_FORMAT_KHRedirect, WeiXinConfig.GetAppId(), System.Web.HttpContext.Current.Server.UrlEncode(redirecturl), "0"); string resulturl = string.Format(WeiXinConfig.URL_WeiXin_Redirect, WeiXinConfig.GetAppId(), System.Web.HttpContext.Current.Server.UrlEncode(redirecturl), "0"); return(resulturl); }
public int WeChatUrlAdd() { string _redirecturl = StringUtils.SafeCodeSmall(FormString.SafeQNo("_url", 200)); int _urltype = FormString.IntSafeQ("_urltype"); string _remark = FormString.SafeQ("_remark", 200); WeChatNavigationEntity _entity = WeChatNavigationBLL.Instance.GetNavigationByUrl(_redirecturl); if (_entity == null || _entity.Id == 0) { _entity.RedirectUrl = _redirecturl; _entity.Id = WeChatNavigationBLL.Instance.AddWeChatNavigation(_entity); } _entity.WeChatUrlType = _urltype; _entity.Remark = _remark; //_entity.WeChatUrl = string.Format(WeiXinConfig.URL_FORMAT_KHRedirect, WeiXinConfig.GetAppId(), System.Web.HttpContext.Current.Server.UrlEncode(SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.WeChatWebUrl), _entity.Id); _entity.WeChatUrl = string.Format(WeiXinConfig.URL_WeiXin_Redirect, WeiXinConfig.GetAppId(), System.Web.HttpContext.Current.Server.UrlEncode(_redirecturl), _entity.Id); int _result = WeChatNavigationBLL.Instance.UpdateWeChatNavigation(_entity); return(_result); }
public ActionResult WeiXin() { if (Globals.IsWeiXinDevice()) { //是微信客户端走这边 string wechatcode = QueryString.SafeQ("wechatcode"); if (string.IsNullOrEmpty(wechatcode)) { string url = Request.Url.ToString(); string redirecturl = string.Format(WeiXinConfig.URL_WeiXin_Redirect, WeiXinConfig.GetAppId(), System.Web.HttpContext.Current.Server.UrlEncode(url), "0"); return(Redirect(redirecturl)); } else { MemWeChatMsgEntity msg = WeiXinJsSdk.Instance.GetWeChatShortInfo(wechatcode); string _paycode = QueryString.SafeQ("paycode"); VWPayOrderEntity _payen = PayOrderBLL.Instance.GetVWPayOrderByPayCode(_paycode); string redirecturl = string.Format(WeiXinConfig.URL_Pay_InWeiXin, msg.OpenId, _payen.NeedPayPrice); Response.Redirect(redirecturl); } } else { //网站类调出微信端支付通道 string _paycode = QueryString.SafeQ("paycode"); VWPayOrderEntity _payen = PayOrderBLL.Instance.GetVWPayOrderByPayCode(_paycode); DateTime dtnow = DateTime.Now; NativePay nativePay = new NativePay(); WxPayData data = nativePay.GetPayUrl(_payen, "MWEB");//得到调用微信接口的路径 string url = data.GetValue("mweb_url").ToString(); return(Redirect(url)); } return(View()); }
/// <summary> /// 用户登录 /// </summary> /// <returns></returns> public ActionResult Login() { if (Globals.IsMobileDevice() && Request.Url.AbsoluteUri.Contains(ConfigCore.Instance.ConfigCommonEntity.LoginWebUrl)) { return(Redirect(Request.Url.AbsoluteUri.Replace(ConfigCore.Instance.ConfigCommonEntity.LoginWebUrl, ConfigCore.Instance.ConfigCommonEntity.LoginMobileWebUrl))); } string returnurl = StringUtils.GetDbString(Request.QueryString["returnurl"]); string unionid = ""; string code = QueryString.SafeQ("wechatcode"); //微信自动登录 if (!string.IsNullOrEmpty(code)) { MemWeChatMsgEntity shortmsg = WeiXinJsSdk.Instance.GetWeChatShortInfo(code); if (!string.IsNullOrEmpty(shortmsg.OpenId) && !string.IsNullOrEmpty(shortmsg.UnionId)) { unionid = shortmsg.UnionId; System.Web.HttpContext.Current.Session[CommonKey.WeChatUnionId] = unionid; MemWeChatMsgEntity entity = new MemWeChatMsgEntity(); entity.AppId = WeiXinConfig.GetAppId(); entity.Status = (int)WeChatStatus.ShortInfo; entity.UnionId = shortmsg.UnionId; entity.OpenId = shortmsg.OpenId; MemWeChatMsgBLL.Instance.WeChatLogin(entity); ResultObj _result = MemberLoginBLL.Instance.Login(unionid, "", "", (int)ClientTypeEnum.PC, IPAddress.IP); if (_result != null && _result.Obj != null) { if (_result.Status == (int)CommonStatus.Success) { MemberLoginEntity _loginmodel = (MemberLoginEntity)_result.Obj; if (_loginmodel.Status == (int)MemberStatus.Active) { CookieBLL.SetLoginCookie(_loginmodel, false); CookieBLL.ComBineCart(1); CookieBLL.ComBineCartXuQiu(1); if (string.IsNullOrEmpty(returnurl)) { returnurl = SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.MainWebUrl; } return(Redirect(returnurl)); } } } } } string tempcode = StringUtils.SafeCodeSmall(QueryString.SafeQNo("tempcode"));//临时自动登录 if (!string.IsNullOrEmpty(tempcode)) { ResultObj _resulttemp = MemberLoginBLL.Instance.LoginByTempCode(tempcode, unionid, (int)ClientTypeEnum.PC, IPAddress.IP); if (_resulttemp != null && _resulttemp.Obj != null) { if (_resulttemp.Status == (int)CommonStatus.Success) { MemberLoginEntity _loginmodel = (MemberLoginEntity)_resulttemp.Obj; if (_loginmodel.Status == (int)MemberStatus.Active) { CookieBLL.SetLoginCookie(_loginmodel, false); CookieBLL.ComBineCart(1); CookieBLL.ComBineCartXuQiu(1); if (string.IsNullOrEmpty(returnurl)) { returnurl = SuperMarket.Core.ConfigCore.Instance.ConfigCommonEntity.MainWebUrl; } return(Redirect(returnurl)); } } } } ViewBag.ReturnUrl = returnurl; return(View()); }
public ActionResult OrderConfirm() { string paycode = QueryString.SafeQ("code"); int success = QueryString.IntSafeQ("s"); //是否需要订单成功提醒 int freshnum = QueryString.IntSafeQ("fn"); //循环次数,超过10次自动关闭 if (freshnum > 10) { return(null); } VWPayOrderEntity _payen = PayOrderBLL.Instance.GetVWPayOrderByPayCode(paycode); if (_payen.PayMethod == (int)PayType.WeChat)//微信支付 { if (Globals.IsWeiXinDevice()) { string wechatcode = ""; wechatcode = QueryString.SafeQ("wechatcode"); //是微信客户端走这边 if (string.IsNullOrEmpty(wechatcode)) { //没有获取微信授权码 string url = Request.Url.ToString(); string redirecturl = string.Format(WeiXinConfig.URL_WeiXin_Redirect, WeiXinConfig.GetAppId(), System.Web.HttpContext.Current.Server.UrlEncode(url), "0"); return(Redirect(redirecturl)); } else { //有微信授权码 JsApiPay jsApiPay = new JsApiPay(); try { jsApiPay.GetOpenidAndAccessTokenFromCode(wechatcode); } catch (Exception ex) { //授权码过期 string baseurl; Dictionary <string, string> nvc = new Dictionary <string, string>(); string oldurl = Request.Url.ToString(); StringUtils.ParseUrl(oldurl, out baseurl, out nvc); nvc.Remove("wechatcode"); if (nvc.ContainsKey("fn")) { nvc["fn"] = (StringUtils.GetDbInt(nvc["fn"]) + 1).ToString(); } else { nvc.Add("fn", "1"); } string url = baseurl + "?"; foreach (string key in nvc.Keys) { url += "&" + key + "=" + nvc[key]; } string redirecturl = string.Format(WeiXinConfig.URL_WeiXin_Redirect, WeiXinConfig.GetAppId(), System.Web.HttpContext.Current.Server.UrlEncode(url), "0"); return(Redirect(redirecturl)); } WxPayData paydata = jsApiPay.GetUnifiedOrderResult(_payen); string wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数 ViewBag.WeiXinJsApiParam = wxJsApiParam; } } else { //网站类调出微信端支付通道 DateTime dtnow = DateTime.Now; NativePay nativePay = new NativePay(); WxPayData data = nativePay.GetPayUrl(_payen, "MWEB");//得到调用微信接口的路径 string url = data.GetValue("mweb_url").ToString(); return(Redirect(url)); } } ViewBag.PayOrderEntity = _payen; ViewBag.Success = success; return(View()); }
/// <summary> /// 询价订单供应商发送微信提醒 /// </summary> /// <returns></returns> public string WeChatInquiryOrderSend() { ResultObj result = new ResultObj(); string ordercode = FormString.SafeQ("ordercode"); string memids = FormString.SafeQ("memids"); memids = memids.Trim(','); string[] memidattr = memids.Split(','); InquiryOrderEntity orderentity = InquiryOrderBLL.Instance.GetInquiryOrderByCode(ordercode); if (orderentity != null && orderentity.Status == (int)OrderInquiryStatusEnum.Quoting) { string url = string.Format(WeiXinConfig.URL_FORMAT_SendMsg, WeiXinJsSdk.Instance.GetAccessToken()); string resulturl = SuperMarketWebUrl.InquiryOrderSendWeChat(ordercode); string redirecturl = SuperMarketWebUrl.InquiryOrderUrl(ordercode); result.Obj = resulturl; ////获取链接导航Id //int navid = WeChatNavigationBLL.Instance.GetIdByUrl(redirecturl); foreach (string memidstr in memidattr) { int memid = StringUtils.GetDbInt(memidstr); MemberEntity memen = MemberBLL.Instance.GetMember(memid); if (!string.IsNullOrEmpty(memen.WeChat)) { MemWeChatMsgEntity wecharmsg = MemWeChatMsgBLL.Instance.GetMsgByAppUnionId(WeiXinConfig.GetAppId(), memen.WeChat); if (wecharmsg != null && !string.IsNullOrEmpty(wecharmsg.OpenId)) { WeiXinSendMsgEntity send = new WeiXinSendMsgEntity(); send.touser = wecharmsg.OpenId; send.template_id = WeiXinTemplet.InquiryQuoteSend; send.url = resulturl; WeiXinInquiryEntity inq = new WeiXinInquiryEntity(); inq.first = new WeiXinUnitEntity() { value = "您有订单需要报价啦,赶紧抢单,订单编号:" + orderentity.Code }; inq.tradeDateTime = new WeiXinUnitEntity() { value = orderentity.CreateTime.ToString("yyyy-MM-dd HH:mm:ss") }; inq.orderType = new WeiXinUnitEntity() { value = "询价订单" }; inq.customerInfo = new WeiXinUnitEntity() { value = "易店心" }; //inq.orderItemName = new WeiXinUnitEntity() { value = "随机名称" }; //inq.orderItemData = new WeiXinUnitEntity() { value = "随机数据" }; inq.remark = new WeiXinUnitEntity() { value = orderentity.Remark }; send.data = inq; string json = JsonJC.ObjectToJson(send); WeChatMsgEntity msg = new WeChatMsgEntity(); msg.ParamStr = json; msg.WeChatOpenId = wecharmsg.OpenId; msg.RedirectUrl = redirecturl; msg.WeChatUrl = url; msg.TemplateIid = WeiXinTemplet.InquiryQuoteSend; msg.Id = WeChatMsgBLL.Instance.AddWeChatMsg(msg); string resultrowi = WebServiceClient.QueryPostWebServiceJson(url, json); WeiXinFailEntity resulten = JsonJC.JsonToObject <WeiXinFailEntity>(resultrowi); if (resulten.errmsg.ToLower() == "ok") { CGMemQuotedBLL.Instance.CGQuotedSend(memid, ordercode); } msg.Result = resultrowi; WeChatMsgBLL.Instance.UpdateWeChatMsg(msg); } } } } else { CGMemQuotedBLL.Instance.QuotedCloseByCode(ordercode); } result.Status = (int)CommonStatus.Success; return(JsonJC.ObjectToJson(result)); }