/// <summary> /// 发送商家充值失败 退款失败提醒 /// </summary> /// <param name="orderId">订单编号</param> /// <param name="reason">原因</param> /// <param name="money">金额</param> /// <param name="openId">接受者openid</param> /// <returns></returns> public static bool SendSellerRechargeRefundFail(string companyId, string orderId, string reason, decimal money, string openId) { try { string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.ParkingRefundFailTemplateId); if (string.IsNullOrWhiteSpace(value)) { return(false); } string firstDes = "您好,商家充值失败了,同时退款失败了。"; string topColor = "#FF0000"; WX_ApiConfig config = GetWX_ApiConfig(companyId); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); var data = new { first = new { value = firstDes, color = "#173177" }, keyword1 = new { value = orderId, color = "#173177" }, keyword2 = new { value = string.Format("{0}元", money), color = "#173177" }, keyword3 = new { value = reason, color = "#173177" }, remark = new { value = "请尽快联系我们,我们将进行人工退款。", color = "#173177" } }; return(WxAdvApi.SendTemplateMessage(companyId, accessToken, openId, value, topColor, data)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送发送商家充值失败通知失败", ex, LogFrom.WeiXin); return(false); } }
/// <summary> /// 发送预约车位支付同步支付结果失败的 退款成功提醒 /// </summary> /// <param name="orderId">订单编号</param> /// <param name="reason">原因</param> /// <param name="money">金额</param> /// <param name="openId">接受者openid</param> /// <returns></returns> public static bool SendBookingBitNoRefundSuccess(string companyId, string orderId, string reason, decimal money, string openId) { try { string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.ParkingRefundSuccessTemplateId); if (string.IsNullOrWhiteSpace(value)) { return(false); } string firstDes = "您好,由于车场网络原因,您预约车位失败了,我们将您支付的钱返还到您的账号了,请查收。"; string topColor = "#FF0000"; WX_ApiConfig config = GetWX_ApiConfig(companyId); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); var data = new { first = new { value = firstDes, color = "#173177" }, keyword1 = new { value = orderId, color = "#173177" }, keyword2 = new { value = reason, color = "#173177" }, keyword3 = new { value = string.Format("{0}元", money), color = "#173177" }, remark = new { value = "如有疑问,请尽快联系我们。", color = "#173177" } }; return(WxAdvApi.SendTemplateMessage(companyId, accessToken, openId, value, topColor, data)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送车位预订退款成功提醒失败", ex, LogFrom.WeiXin); return(false); } }
/// <summary> /// 账号充值成功提醒 /// </summary> /// <param name="orderId">订单编号</param> /// <param name="money">充值金额(元)</param> /// <param name="openId">接收者编号</param> /// <param name="balance">账号余额</param> /// <param name="payTime">充值时间</param> /// <returns></returns> //public static bool SendAccountRechargeSuccess(string orderId, decimal money, decimal balance, string openId, DateTime payTime) //{ // try // { // string value = WXOtherConfigServices.GetConfigValue(ConfigType.AccountRechargeSuccessTemplateId); // if (string.IsNullOrWhiteSpace(value)) return false; // string payTimeDes = string.Format("{0}月{1}日 {2}时{3}分", payTime.Month.ToString().PadLeft(2, '0'), payTime.Day.ToString().PadLeft(2, '0'), payTime.Hour.ToString().PadLeft(2, '0'), payTime.Minute.ToString().PadLeft(2, '0')); // string topColor = "#FF0000"; // WX_ApiConfig config = GetWX_ApiConfig(); // var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); // var data = new // { // first = new { value = "您好,您的账号已充值成功!", color = "#173177" }, // keyword1 = new { value = string.Format("{0}元", money), color = "#173177" }, // keyword2 = new { value = string.Format("{0}元", balance), color = "#173177" }, // keyword3 = new { value = orderId, color = "#173177" }, // keyword4 = new { value = payTimeDes, color = "#173177" }, // remark = new { value = "如有疑问,请尽快联系我们", color = "#173177" } // }; // return WxAdvApi.SendTemplateMessage(accessToken, openId, value, topColor, data); // } // catch (Exception ex) // { // ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送账号充值成功提醒失败", ex, LogFrom.WeiXin); // return false; // } //} /// <summary> /// 月卡充值成功提醒 /// </summary> /// <param name="plateNumber">车牌号</param> /// <param name="parkingName">停车场名称</param> /// <param name="money">支付金额(分)</param> /// <param name="lastEffectiveTime">最后有效期</param> /// <param name="openId">微信openid</param> /// <returns></returns> public static bool SendMonthCardRechargeSuccess(string companyId, string plateNumber, string parkingName, decimal money, DateTime lastEffectiveTime, string openId) { try { string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.MonthCardRechargeSuccessTemplateId); if (string.IsNullOrWhiteSpace(value)) { return(false); } string topColor = "#FF0000"; string effectiveTime = string.Format("{0}年{1}月{2}日", lastEffectiveTime.Year, lastEffectiveTime.Month, lastEffectiveTime.Day); WX_ApiConfig config = GetWX_ApiConfig(companyId); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); var data = new { first = new { value = "您好,您的月卡已续期成功!", color = "#173177" }, keyword1 = new { value = plateNumber, color = "#173177" }, keyword2 = new { value = parkingName, color = "#173177" }, keyword3 = new { value = string.Format("{0}元", money), color = "#173177" }, keyword4 = new { value = string.Format("{0}元", money), color = "#173177" }, keyword5 = new { value = effectiveTime, color = "#173177" }, remark = new { value = "感谢您的使用。", color = "#173177" } }; return(WxAdvApi.SendTemplateMessage(companyId, accessToken, openId, value, topColor, data)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送月卡充值成功提醒失败", ex, LogFrom.WeiXin); return(false); } }
/// <summary> /// 发送停车场入场通知 /// </summary> /// <param name="plateNumber">车牌号</param> /// <param name="parkingName">停车场名称</param> /// <param name="entranceTime">进场时间</param> /// <param name="openId">接受消息的openid</param> public static bool SendParkIn(string companyId, string plateNumber, string parkingName, string entranceTime, string openId) { try { string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.ParkInTemplateId); if (string.IsNullOrWhiteSpace(value)) { return(false); } string topColor = "#FF0000"; string remark = "谢谢您的支持!"; WX_ApiConfig config = GetWX_ApiConfig(companyId); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); var data = new { first = new { value = "欢迎您再次进入停车场\r\n", color = "#173177" }, keyword1 = new { value = plateNumber, color = "#173177" }, keyword2 = new { value = parkingName, color = "#173177" }, keyword3 = new { value = entranceTime.ToString(), color = "#173177" }, remark = new { value = remark, color = "#173177" } }; return(WxAdvApi.SendTemplateMessage(companyId, accessToken, openId, value, topColor, data)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送停车场入场通知失败", ex, LogFrom.WeiXin); return(false); } }
/// <summary> /// 发送商家充值成功通知 /// </summary> /// <param name="companyId">单位编号</param> /// <param name="money">充值金额(元)</param> /// <param name="balance">账号预额(元)</param> /// <param name="realPayTime">支付时间</param> /// <param name="openId">接受消息的openid</param> public static bool SendSellerRechargeSuccess(string companyId, decimal money, decimal balance, DateTime realPayTime, string openId) { try { string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.SellerRechargeTemplateId); if (string.IsNullOrWhiteSpace(value)) { return(false); } string topColor = "#FF0000"; string payTimeDes = string.Format("{0}月{1}日 {2}时{3}分", realPayTime.Month.ToString().PadLeft(2, '0'), realPayTime.Day.ToString().PadLeft(2, '0'), realPayTime.Hour.ToString().PadLeft(2, '0'), realPayTime.Minute.ToString().PadLeft(2, '0')); WX_ApiConfig config = GetWX_ApiConfig(companyId); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); var data = new { first = new { value = "您好,您已充值成功!", color = "#173177" }, keyword1 = new { value = payTimeDes, color = "#173177" }, keyword2 = new { value = money, color = "#173177" }, keyword3 = new { value = balance, color = "#173177" }, remark = new { value = "您的充值已成功,可在充值记录查看明细", color = "#173177" } }; return(WxAdvApi.SendTemplateMessage(companyId, accessToken, openId, value, topColor, data)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送停车场缴费成功通知失败", ex, LogFrom.WeiXin); return(false); } }
public ActionResult GetMobileCode(string mobile) { try { var companyCookie = Request.Cookies["SmartSystem_H5_CompanyID"]; if (companyCookie == null || string.IsNullOrWhiteSpace(companyCookie.Value)) { throw new MyException("获取单位信息失败,请重新进入页面"); } if (string.IsNullOrWhiteSpace(mobile) || !Regex.Match(mobile, @"^1[0-9]{10}$").Success) { throw new MyException("手机号码格式不正确"); } var code_cookie = Request.Cookies["SmartSystem_BindTradePassword_Code"]; var code_time_cookie = Request.Cookies["SmartSystem_BindTradePassword_Code_GetTime"]; var code_moblie_cookie = Request.Cookies["SmartSystem_BindTradePassword_Mobile"]; if (code_cookie != null && code_time_cookie != null && code_moblie_cookie != null && code_moblie_cookie.Value == mobile && DateTime.Parse(code_time_cookie.Value).AddMinutes(1) > DateTime.Now) { return(Json(MyResult.Error("两次获取验证码的时间不能小于60秒"))); } string code = new Random().Next(100000, 999999).ToString(); string appkey = WXOtherConfigServices.GetConfigValue(companyCookie.Value, ConfigType.JuHeAppKey); string modeId = WXOtherConfigServices.GetConfigValue(companyCookie.Value, ConfigType.JuHeSmsTemplateId); JuHeSmsResult result = JuHeCodeSmsService.SendCodeSms(appkey, modeId, code, mobile); if (result.SendResult) { //验证码30分钟内有效 var cookie_code = new HttpCookie("SmartSystem_BindTradePassword_Code", code); cookie_code.Expires = DateTime.Now.AddMinutes(30); Response.Cookies.Add(cookie_code); Response.Cookies.Add(new HttpCookie("SmartSystem_BindTradePassword_Mobile", mobile)); Response.Cookies.Add(new HttpCookie("SmartSystem_BindTradePassword_Code_GetTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); return(Json(MyResult.Success("获取成功"))); } return(Json(MyResult.Error("获取失败"))); } catch (MyException ex) { ExceptionsServices.AddExceptionToDbAndTxt("H5BindMobileError", ex.Message, ex, LogFrom.WeiXin); return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("H5BindMobileError", "获取验证码失败", ex, LogFrom.WeiXin); return(Json(MyResult.Error("获取验证码失败"))); } }
/// <summary> /// 重定向关注页面 /// </summary> /// <param name="msg">提醒消息</param> /// <returns></returns> public ContentResult RedirectAttentionPage(string companyId, string msg) { string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.PromptAttentionPage); if (!string.IsNullOrWhiteSpace(msg) && !string.IsNullOrWhiteSpace(value)) { string script = Alert(msg, value); return(Content(script, "text/html")); } if (!string.IsNullOrWhiteSpace(value)) { string script = "<script>location.href='" + value + "'</script>"; return(Content(script, "text/html")); } return(Alert("请先关注微信公众账号", "Index", "ErrorPrompt")); }
/// <summary> /// 发送停车场入场通知 /// </summary> /// <param name="plateNumber">车牌号</param> /// <param name="parkingName">停车场名称</param> /// <param name="entranceTime">进场时间</param> /// <param name="openId">接受消息的openid</param> public static bool SendParkOut(string companyId, string plateNumber, string parkingName, string entranceTime, string exitTime, string duringTime, string sPayType, string amount, string openId, bool isApp) { try { string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.ParkOutTemplateId); if (string.IsNullOrWhiteSpace(value)) { return(false); } string topColor = "#FF0000"; string remark = ""; if (isApp) { remark = "感谢使用SPS智慧停车,无感支付,优感生活!祝您一路顺风~"; } else { remark = "您已成功提前支付成功,15分钟内免费自动抬杆离场,超过15分钟需补缴相应停车费用,具体费用见停车场收费标准!感谢使用SPS智慧停车,无感支付,优感生活!祝您一路顺风~"; } string first = "尊敬的SPS车主:\r\n您的车辆" + plateNumber + "已驶出" + parkingName; WX_ApiConfig config = GetWX_ApiConfig(companyId); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); var data = new { first = new { value = first, color = "#173177" }, keyword1 = new { value = entranceTime, color = "#173177" }, keyword2 = new { value = exitTime, color = "#173177" }, keyword3 = new { value = duringTime.ToString(), color = "#173177" }, keyword4 = new { value = sPayType.ToString(), color = "#173177" }, keyword5 = new { value = amount.ToString(), color = "#173177" }, remark = new { value = remark, color = "#173177" } }; return(WxAdvApi.SendTemplateMessage(companyId, accessToken, openId, value, topColor, data)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送停车场出场通知失败", ex, LogFrom.WeiXin); return(false); } }
/// <summary> /// 发送停车场缴费成功通知 /// </summary> /// <param name="plateNumber">车牌号</param> /// <param name="parkingName">停车场名称</param> /// <param name="money">支付金额(元)</param> /// <param name="entranceTime">进场时间</param> /// <param name="payTime">支付时间</param> /// <param name="lastExitTime">最后出场时间</param> /// <param name="openId">接受消息的openid</param> public static bool SendParkCarPaymentSuccess(string companyId, string plateNumber, string parkingName, decimal money, DateTime entranceTime, DateTime payTime, DateTime realPayTime, DateTime lastExitTime, string openId) { try { string value = WXOtherConfigServices.GetConfigValue(companyId, ConfigType.ParkCarPaymentSuccessTemplateId); if (string.IsNullOrWhiteSpace(value)) { return(false); } string topColor = "#FF0000"; string payTimeDes = string.Format("{0}月{1}日 {2}时{3}分", realPayTime.Month.ToString().PadLeft(2, '0'), realPayTime.Day.ToString().PadLeft(2, '0'), realPayTime.Hour.ToString().PadLeft(2, '0'), realPayTime.Minute.ToString().PadLeft(2, '0')); int minute = (int)(lastExitTime - payTime).TotalMinutes; string remark = string.Format("请您于支付时间后{0}分钟内开车驶离停车场,否则还需再进行超时部分的停车费补缴。", minute); if (minute < 1) { remark = "请您马上驶离停车场,否则还需再进行超时部分的停车费补缴。"; } int totalTime = (int)(payTime - entranceTime).TotalMinutes; WX_ApiConfig config = GetWX_ApiConfig(companyId); var accessToken = AccessTokenContainer.TryGetToken(config.AppId, config.AppSecret); var data = new { first = new { value = "您好,您已缴费成功!", color = "#173177" }, keynote1 = new { value = plateNumber, color = "#173177" }, keynote2 = new { value = parkingName, color = "#173177" }, keynote3 = new { value = totalTime.GetParkingDuration(), color = "#173177" }, keynote4 = new { value = string.Format("{0}元", money), color = "#173177" }, keynote5 = new { value = payTimeDes, color = "#173177" }, remark = new { value = remark, color = "#173177" } }; return(WxAdvApi.SendTemplateMessage(companyId, accessToken, openId, value, topColor, data)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("SendTemplateMessage", "发送停车场缴费成功通知失败", ex, LogFrom.WeiXin); return(false); } }
//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; } }