예제 #1
0
 /// <summary>
 /// 临停缴费
 /// </summary>
 /// <param name="orderId"></param>
 /// <returns></returns>
 public ActionResult ParkCarPayment(decimal orderId)
 {
     try
     {
         OnlineOrder order = CheckOrder(orderId);
         if (order.OrderType != OnlineOrderType.ParkFee)
         {
             throw new MyException("支付方法不正确");
         }
         if (string.IsNullOrWhiteSpace(order.MWebUrl))
         {
             UnifiedPayModel model = GetUnifiedPayModel(order, string.Format("临停缴费-{0}-{1}", order.PKName, order.PlateNo));
         }
         ViewBag.MaxWaitTime = DateTime.Now.AddMinutes(WXOtherConfigServices.GetTempParkingWeiXinPayTimeOut(order.CompanyID)).ToString("yyyy-MM-dd HH:mm:ss");
         ViewBag.MWeb_Url    = order.MWebUrl;
         return(View(order));
     }
     catch (MyException ex) {
         return(RedirectToAction("Index", "ErrorPrompt", new { message = ex.Message, returnUrl = "/H5ParkingPayment/Index" }));
     }
     catch (Exception ex)
     {
         TxtLogServices.WriteTxtLogEx("H5WeiXinPayment_Error", string.Format("Message:{0},StackTrace:{1}", ex.Message, ex.StackTrace), LogFrom.WeiXin);
         return(RedirectToAction("Index", "ErrorPrompt", new { message = "支付失败,请重新支付", returnUrl = "/H5ParkingPayment/Index" }));
     }
 }
예제 #2
0
        /// <summary>
        /// 临停缴费
        /// </summary>
        /// <returns></returns>
        public ActionResult ParkCarPayment(decimal orderId, int source = 0)
        {
            if (string.IsNullOrWhiteSpace(AliPayUserId))
            {
                return(RedirectToAction("Index", "ErrorPrompt", new { message = "获取用户信息失败" }));
            }
            try
            {
                OnlineOrder order = CheckOrder(orderId);
                if (order.OrderType != OnlineOrderType.ParkFee)
                {
                    throw new MyException("支付方法不正确");
                }

                string tradeNo = MakeAlipayTradeOrder(order);

                OnlineOrderServices.UpdatePrepayIdById(tradeNo, order.OrderID);
                order.PrepayId      = tradeNo;
                ViewBag.MaxWaitTime = DateTime.Now.AddMinutes(WXOtherConfigServices.GetTempParkingWeiXinPayTimeOut(order.CompanyID)).ToString("yyyy-MM-dd HH:mm:ss");
                return(View(order));
            }
            catch (MyException ex)
            {
                return(RedirectToAction("Index", "ErrorPrompt", new { message = ex.Message, returnUrl = "/QRCodeParkPayment/Index" }));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptionToDbAndTxt("AliPay_Error", string.Format("支付失败 orderId:{0};AliUserId:{1}", orderId, AliPayUserId), ex, LogFrom.AliPay);
                return(RedirectToAction("Index", "ErrorPrompt", new { message = "支付失败,请重新支付", returnUrl = "/QRCodeParkPayment/Index" }));
            }
        }
예제 #3
0
        /// <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);
            }
        }
예제 #4
0
        /// <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);
            }
        }
예제 #5
0
        /// <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);
            }
        }
예제 #6
0
        /// <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);
            }
        }
예제 #7
0
        /// <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);
            }
        }
예제 #8
0
        public JsonResult GetWxOtherConfigData(string companyId)
        {
            JsonResult json = new JsonResult();

            try
            {
                List <WX_OtherConfig> configs = WXOtherConfigServices.QueryAll(companyId);
                List <WX_OtherConfig> models  = new List <WX_OtherConfig>();
                foreach (object o in Enum.GetValues(typeof(ConfigType)))
                {
                    ConfigType     type  = (ConfigType)o;
                    WX_OtherConfig model = new WX_OtherConfig();
                    model.ConfigType = type;
                    WX_OtherConfig config = configs.FirstOrDefault(p => p.ConfigType == type);
                    if (config != null)
                    {
                        model.ConfigValue = config.ConfigValue;
                    }
                    model.CompanyID          = companyId;
                    model.Description        = type.GetDescription();
                    model.DefaultDescription = type.GetEnumDefaultValue();
                    models.Add(model);
                }
                json.Data = models;
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "获取微信其他配置信息失败");
            }
            return(json);
        }
예제 #9
0
        /// <summary>
        /// 临停缴费
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public ActionResult ParkCarPayment(decimal orderId, int source = 0)
        {
            string returnUrl = source == 0 ? "/ParkingPayment/Index" : "/QRCodeParkPayment/QRCodePaySuccess?orderId=" + orderId;

            try
            {
                OnlineOrder order = CheckOrder(orderId);
                if (order.OrderType != OnlineOrderType.ParkFee)
                {
                    throw new MyException("支付方法不正确");
                }
                if (!OnlineOrderServices.UpdateSFMCode(order))
                {
                    throw new MyException("处理订单信息异常【SFM】");
                }

                string             sAttach  = Convert.ToString(Session["SmartSystem_WeiXinTg_personid"]);
                UnifiedPayModel    model    = GetUnifiedPayModel(order, string.Format("临停缴费-{0}", order.PlateNo), sAttach);
                WeiXinPaySignModel payModel = GetWeiXinPaySign(order, model);
                ViewBag.MaxWaitTime = DateTime.Now.AddMinutes(WXOtherConfigServices.GetTempParkingWeiXinPayTimeOut(order.CompanyID)).ToString("yyyy-MM-dd HH:mm:ss");
                ViewBag.PayModel    = payModel;
                ViewBag.ReturnUrl   = returnUrl;
                ViewBag.Source      = source;
                Session["SmartSystem_WeiXinTg_personid"] = null;
                return(View(order));
            }
            catch (MyException ex) {
                return(RedirectToAction("Index", "ErrorPrompt", new { message = ex.Message, returnUrl = returnUrl }));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPayment_Error", string.Format("支付失败 orderId:{0};openId:{1}", orderId, WeiXinOpenId), ex, LogFrom.WeiXin);
                return(RedirectToAction("Index", "ErrorPrompt", new { message = "支付失败,请重新支付", returnUrl = returnUrl }));
            }
        }
예제 #10
0
        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("获取验证码失败")));
            }
        }
예제 #11
0
        /// <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"));
        }
예제 #12
0
        /// <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);
            }
        }
예제 #13
0
        /// <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);
            }
        }
예제 #14
0
 public JsonResult AddOrUpdate(WX_OtherConfig config)
 {
     try
     {
         bool result = WXOtherConfigServices.AddOrUpdate(config);
         if (!result)
         {
             throw new MyException("保存失败");
         }
         return(Json(MyResult.Success()));
     }
     catch (MyException ex)
     {
         return(Json(MyResult.Error(ex.Message)));
     }
     catch (Exception ex)
     {
         ExceptionsServices.AddExceptions(ex, "修改微信其他配置信息失败");
         return(Json(MyResult.Error("保存失败")));
     }
 }
예제 #15
0
        //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;
            }
        }
예제 #16
0
        public ActionResult SubmitParkingPaymentRequest(OnlineOrder model)
        {
            try
            {
                int time = WXOtherConfigServices.GetTempParkingWeiXinPayTimeOut(model.CompanyID);
                if (model.OrderTime.AddMinutes(time - 1) < DateTime.Now)
                {
                    throw new MyException("页面等待超时,请重新点击“立即结算”按钮");
                }
                if (model.OrderSource == PayOrderSource.Platform)
                {
                    //int interfaceOrderState = InterfaceOrderServices.OrderWhetherEffective(model.PayDetailID);
                    int interfaceOrderState = InterfaceOrderServices.OrderWhetherEffective(model.PayDetailID, model.PKID, model.InOutID);
                    if (interfaceOrderState != 1)
                    {
                        string msg = interfaceOrderState == 2 ? "重复支付" : "订单已失效";
                        return(PageAlert("LicensePlatePayment", "ParkingPayment", new { RemindUserContent = msg }));
                    }
                }

                BaseCompany company = CompanyServices.QueryByParkingId(model.PKID);
                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 (model.OrderSource == PayOrderSource.Platform && (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);
                    if (CurrLoginWeiXinApiConfig == null)
                    {
                        return(RedirectToAction("Index", "ErrorPrompt", new { message = "获取微信授权信息失败,请重试!" }));
                    }
                    return(RedirectToAction("Index", "ErrorPrompt", new { message = "车场所属公众号和当前公众号不匹配,不能支付!" }));
                }

                model.OrderID      = IdGenerator.Instance.GetId();
                model.Status       = OnlineOrderStatus.WaitPay;
                model.PayAccount   = WeiXinUser.OpenID;
                model.Payer        = WeiXinUser.OpenID;
                model.PayeeUser    = config.SystemName;
                model.PayeeAccount = config.PartnerId;
                model.OrderType    = OnlineOrderType.ParkFee;
                model.AccountID    = WeiXinUser.AccountID;
                model.Amount       = model.Amount;
                model.CardId       = WeiXinUser.AccountID;
                model.CompanyID    = config.CompanyID;
                bool result = OnlineOrderServices.Create(model);
                if (!result)
                {
                    throw new MyException("生成待缴费订单失败");
                }
                DateTime maxWaitTime = model.OrderTime.AddMinutes(time);
                switch (model.PaymentChannel)
                {
                case PaymentChannel.WeiXinPay:
                {
                    return(RedirectToAction("ParkCarPayment", "WeiXinPayment", new { orderId = model.OrderID, maxWaitTime = maxWaitTime }));
                }

                default: throw new MyException("支付方式错误");
                }
            }
            catch (MyException ex)
            {
                return(PageAlert("ComputeParkingFee", "ParkingPayment", new { licensePlate = model.PlateNo, RemindUserContent = ex.Message }));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptionToDbAndTxt("WeiXinPageError", "保存临停缴费订单失败", ex, LogFrom.WeiXin);
                return(PageAlert("ComputeParkingFee", "ParkingPayment", new { licensePlate = model.PlateNo, RemindUserContent = "提交支付失败" }));
            }
        }