예제 #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>
        /// <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 }));
            }
        }
예제 #4
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 = "提交支付失败" }));
            }
        }