public ActionResult CheckBindMobile() { try { WX_Account account = WeiXinAccountService.GetAccountByID(WeiXinUser.AccountID); if (account != null && !string.IsNullOrWhiteSpace(account.MobilePhone)) { return(Json(MyResult.Success(account.MobilePhone))); } return(Json(MyResult.Error("未绑定"))); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "检查是否绑了手机好失败", ex, LogFrom.WeiXin); return(Json(MyResult.Error(""))); } }
public JsonResult DeleteAccount(int id) { int Id = Request["Id"].ToInt32(); Notify <bool> notify = new Notify <bool>(); WX_Account entity = new WX_Account { Id = Id }; if (_wxaccountService.DeleteEntity(entity)) { notify.Data = true; } else { notify.Data = false; notify.Status = StatusCode.Error; notify.Message = "删除失败"; } return(Json(notify, JsonRequestBehavior.AllowGet)); }
public JsonResult AddAccount(WX_Account entity) { string enable = Request["Enable"]; string isDefault = Request["IsDefault"]; entity.CreateTime = DateTime.Now; entity.Enable = enable.ToInt32() == 0 ? true : false; entity.IsDefault = isDefault.ToInt32() == 0 ? true : false; Notify <bool> notify = new Notify <bool>(); if (null != _wxaccountService.AddEntity(entity)) { notify.Data = true; } else { notify.Data = false; notify.Status = StatusCode.Error; notify.Message = "删除失败"; } return(Json(notify, JsonRequestBehavior.AllowGet)); }
//public string AppUserToken //{ // get // { // var cookie = HttpContext.Current.Request.Cookies["SmartSystem_APP_UserToken"]; // if (cookie != null && !string.IsNullOrWhiteSpace(cookie.Value)) // { // return cookie.Value; // } // return string.Empty; // } // set // { // var cookie = HttpContext.Current.Request.Cookies["SmartSystem_APP_UserToken"]; // if (cookie == null) // { // cookie = new HttpCookie("SmartSystem_APP_UserToken"); // cookie.Expires = DateTime.Now.AddYears(1); // cookie.Value = value; // HttpContext.Current.Request.Cookies.Add(cookie); // } // else // { // cookie.Value = value; // HttpContext.Current.Request.Cookies.Set(cookie); // } // } //} public override void OnAuthorization(AuthorizationContext filterContext) { try { var openId = string.Empty; WX_Info user = null; var cookie = filterContext.RequestContext.HttpContext.Request.Cookies["SmartSystem_WeiXinOpenId"]; if (cookie != null && !string.IsNullOrWhiteSpace(cookie.Value)) { openId = cookie.Value; } var permission = Roles.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (permission.Contains("Login")) { if (string.IsNullOrWhiteSpace(openId)) { #if DEBUG //odvkywUwtjaKnj7yGN-df7XV6ru4,odvkywSnlKr8anm3ddoIcredwvN0,oaC2Qt5oZsvPH_hlz0MoEw0sK2yg openId = "ohqkK00bNhbFKWniuJyMsSXivoXc";//"o-Xw8wzQE2QmB-x5zehYlVdxcs5M"; #endif } if (string.IsNullOrWhiteSpace(openId)) { //如果获取不到cookie中的微信uid则跳转至appRedir TxtLogServices.WriteTxtLogEx("CheckWeiXinPurview", "Request.Url.PathAndQuery:{0}", filterContext.RequestContext.HttpContext.Request.Url.PathAndQuery); var queryString = filterContext.RequestContext.HttpContext.Request.Url.PathAndQuery.TrimStart('/').Replace('/', '_').Replace('?', '_').Replace('&', '^'); TxtLogServices.WriteTxtLogEx("CheckWeiXinPurview", "请求获取微信信息 queryString:{0}", queryString); filterContext.HttpContext.Response.Redirect(string.Format("~/L/Index?id={0}", queryString)); filterContext.HttpContext.Response.End(); filterContext.Result = new EmptyResult(); return; } } if (filterContext.HttpContext.Session["SmartSystem_WX_Info"] != null) { user = (WX_Info)filterContext.HttpContext.Session["SmartSystem_WX_Info"]; } if (user == null) { user = WXotherServices.GetWXInfo(openId); //user = WeiXinAccountService.QueryWXByOpenId(openId); } if (user == null || (WxUserState)user.FollowState == WxUserState.UnAttention) { string companyId = user == null ? string.Empty : user.CompanyID; string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.PromptAttentionPage); if (string.IsNullOrWhiteSpace(value)) { value = "~/ErrorPrompt/Index?message=请关注SPS停车服务微信公众号"; } //返回错误页面 (请求关注页面) filterContext.HttpContext.Response.Redirect(value); filterContext.HttpContext.Response.End(); filterContext.Result = new EmptyResult(); return; } HttpContext.Current.Session["SmartSystem_LogFrom"] = LogFrom.WeiXin; HttpContext.Current.Session["SmartSystem_OperatorUserAccount"] = user.OpenID; filterContext.HttpContext.Session["SmartSystem_WX_Info"] = user; if (user == null) { TxtLogServices.WriteTxtLogEx("CheckWeiXinPurview", "微信用户不存在,OPENID:{0}", openId); } //RegisterAccount if (permission.Contains("REGISTERACCOUNT")) { WX_Account account = WeiXinAccountService.GetAccountByID(user.AccountID); if (account == null || string.IsNullOrWhiteSpace(account.MobilePhone)) { var queryString = filterContext.RequestContext.HttpContext.Request.Url.PathAndQuery; if (filterContext.RequestContext.HttpContext.Request["returnUrl"] != null) { queryString = filterContext.RequestContext.HttpContext.Request["returnUrl"]; } filterContext.HttpContext.Response.Redirect(string.Format("~/BindMobile/Index?returnUrl={0}", queryString)); filterContext.HttpContext.Response.End(); filterContext.Result = new EmptyResult(); return; } } //if (permission.Contains("APP")) //{ // //TradePassword // string sToken = AppUserToken; // if (string.IsNullOrEmpty(sToken)) // { // TxtLogServices.WriteTxtLogEx("ParkingPayment", "TOKEN = {0} ", "null or ''"); // } // else // { // TxtLogServices.WriteTxtLogEx("ParkingPayment", "TOKEN,id:{0},Status:{1} ", openId, sToken); // } // do // { // //APP // if (sToken.IsEmpty()) // { // VerifyCode verify = wxApi.getThirdLogin(openId, openId); //第三方登录 // TxtLogServices.WriteTxtLogEx("ParkingPayment", "用户自动登录,id:{0},Status:{1} ", openId, verify.Status); // if (verify.Status == 1) // { // sToken = verify.Result; // AppUserToken = sToken; // return; // } // else if (verify.Status == 2) // { // //未绑定 // AppUserToken = ""; // sToken = ""; // filterContext.HttpContext.Response.Redirect("~/ParkingPayment/LicensePlatePayment"); // filterContext.HttpContext.Response.End(); // filterContext.Result = new EmptyResult(); // return; // } // else // { // //其他都是失败 // AppUserToken = ""; // sToken = ""; // filterContext.HttpContext.Response.Redirect("~/ErrorPrompt/Index?message=用户自动登录失败"); // filterContext.HttpContext.Response.End(); // filterContext.Result = new EmptyResult(); // return; // } // } // CarManage carMessage = wxApi.getCarManage(sToken); // if (carMessage == null || carMessage.Status == 40001) // { // // // AppUserToken = ""; // sToken = ""; // continue; // } // } while (sToken.IsEmpty()); //} } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "验证微信登陆信息失败", LogFrom.WeiXin); TxtLogServices.WriteTxtLogEx("CheckWeiXinPurview", ex); return; } }
public ActionResult Czmx(decimal paymoney) { string auth = AppUserToken; if (auth.IsEmpty()) { //没有登录 // return(RedirectToAction("Index", "ErrorPrompt", new { message = "用户登录失败" })); } else if (auth == "-1") { return(RedirectToAction("Register", "ParkingPayment")); } //生成一个订单 try { TxtLogServices.WriteTxtLog("4"); BaseCompany company = CompanyServices.QueryCompanyByRecordId(CurrLoginWeiXinApiConfig.CompanyID); if (company == null) { throw new MyException("获取单位信息失败"); } WX_ApiConfig config = WXApiConfigServices.QueryWXApiConfig(company.CPID); if (config == null) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "获取微信配置信息失败", "单位编号:" + company.CPID, LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = "获取微信配置信息失败!" })); } if (!config.Status) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "该车场暂停使用微信支付", "单位编号:" + company.CPID, LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = "该车场暂停使用微信支付!" })); } if (config.CompanyID != WeiXinUser.CompanyID) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "微信用户所属公众号和当前公众号不匹配,不能支付", string.Format("支付单位:{0},微信用户单位:{1}", config.CompanyID, WeiXinUser.CompanyID), LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = "微信用户所属公众号和当前公众号不匹配,不能支付!" })); } if (CurrLoginWeiXinApiConfig == null || config.CompanyID != CurrLoginWeiXinApiConfig.CompanyID) { string loginCompanyId = CurrLoginWeiXinApiConfig != null ? CurrLoginWeiXinApiConfig.CompanyID : string.Empty; ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "车场所属公众号和当前公众号不匹配,不能支付", string.Format("支付单位:{0},微信用户单位:{1}", config.CompanyID, loginCompanyId), LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = "车场所属公众号和当前公众号不匹配,不能支付!" })); } string sPhone = ""; //获取绑定的手机 WX_Account account = WeiXinAccountService.GetAccountByID(WeiXinUser.AccountID); if (account != null && !account.MobilePhone.IsEmpty()) { sPhone = account.MobilePhone; } if (sPhone.IsEmpty()) { return(RedirectToAction("Index", "ErrorPrompt", new { message = "您没有绑定APP账号,不能支付!" })); } OnlineOrder model = new OnlineOrder(); model.OrderID = IdGenerator.Instance.GetId(); model.CardId = ""; model.PKID = ""; model.PKName = ""; model.EntranceTime = DateTime.MinValue; model.ExitTime = DateTime.MinValue; model.MonthNum = 0; model.Amount = paymoney; model.Status = OnlineOrderStatus.WaitPay; model.PaymentChannel = PaymentChannel.WeiXinPay; model.Payer = WeiXinUser.OpenID; model.PayAccount = WeiXinUser.OpenID; model.OrderTime = DateTime.Now; model.PayeeChannel = PaymentChannel.WeiXinPay; model.AccountID = WeiXinUser.AccountID; model.OrderType = OnlineOrderType.APPRecharge; model.PlateNo = sPhone; model.PayeeUser = config.SystemName; model.PayeeAccount = config.PartnerId; model.CompanyID = config.CompanyID; model.Remark = "APP余额充值"; bool result = OnlineOrderServices.Create(model); if (!result) { throw new MyException("余额失败[保存订单失败]"); } switch (model.PaymentChannel) { case PaymentChannel.WeiXinPay: { return(RedirectToAction("BalancePayment", "WeiXinPayment", new { orderId = model.OrderID })); } default: throw new MyException("支付方式错误"); } } catch (MyException ex) { return(RedirectToAction("Index", "ErrorPrompt", new { message = ex.Message, returnUrl = "/PurseData/Index" }));; } catch (Exception ex) { return(RedirectToAction("Index", "ErrorPrompt", new { message = ex.Message, returnUrl = "/PurseData/Index" })); } }