Exemple #1
0
        /// <summary>
        /// 月卡续期
        /// </summary>
        /// <returns></returns>
        public ActionResult MonthCardRenewal(string cardId, string plateNo = "", int source = 0)
        {
            try
            {
                string selectMonth   = string.Empty;
                string selectPayType = string.Empty;
                var    selectParam   = HttpContext.Request.Cookies["SmartSystem_MonthCardPayment_Month"];
                if (selectParam != null && !string.IsNullOrWhiteSpace(selectParam.Value))
                {
                    if (selectParam.Value.Contains(","))
                    {
                        string[] strs = selectParam.Value.Split(',');
                        selectMonth   = strs[0];
                        selectPayType = strs[1];
                    }
                }
                ViewBag.SelectMonth   = selectMonth;
                ViewBag.SelectPayType = selectPayType;
                ViewBag.SystemDate    = DateTime.Now.Date;

                List <ParkUserCarInfo> carInfos = new List <ParkUserCarInfo>();
                if (source == 1)
                {
                    carInfos = RechargeService.GetMonthCarInfoByPlateNumber(plateNo);
                }
                else
                {
                    if (UserAccount != null)
                    {
                        carInfos = RechargeService.GetMonthCarInfoByAccountID(UserAccount.AccountID);
                    }
                }
                ParkUserCarInfo card = carInfos.FirstOrDefault(p => p.CardID == cardId);
                if (card == null)
                {
                    throw new MyException("获月卡信息失败");
                }
                ViewBag.Source = source;

                bool canConnection = CarService.WXTestClientProxyConnectionByVID(card.VID);
                if (!canConnection)
                {
                    return(PageAlert("Index", "H5CardRenewal", new { RemindUserContent = "车场网络异常,暂无法续期,请稍后再试!" }));
                }
                ViewBag.CardRenewalMonthDic = GetCardRenewalMonth(card.OnlineUnit);
                return(View(card));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptionToDbAndTxt("H5CardRenewalError", string.Format("获取续费信息失败,编号:" + cardId), ex, LogFrom.WeiXin);
                return(PageAlert("Index", "H5CardRenewal", new { RemindUserContent = "获取卡信息失败" }));
            }
        }
Exemple #2
0
        private void CheckMonthCardOrder(ParkUserCarInfo card, int month, double paymoney, PaymentChannel paytype, DateTime afterdate)
        {
            TxtLogServices.WriteTxtLog("31");
            if (card == null)
            {
                throw new MyException("获月卡信息失败");
            }

            if (!card.IsAllowOnlIne)
            {
                throw new MyException("该车场不支持手机续期");
            }

            if (month < 1)
            {
                throw new MyException("请选择续期月数");
            }

            if (card.MaxMonth != 0 && card.MaxMonth < month)
            {
                throw new MyException(string.Format("续期月数必须小于等于{0}个月", card.MaxMonth));
            }
            if (card.Amount * month != (decimal)paymoney)
            {
                throw new MyException("支付金额不正确");
            }

            TxtLogServices.WriteTxtLog("32");
            DateTime start = DateTime.Now;

            if (card.BeginDate != DateTime.MinValue)
            {
                start = card.BeginDate;
            }

            TxtLogServices.WriteTxtLog("M:" + Convert.ToString(month));
            TxtLogServices.WriteTxtLog(Convert.ToString(start));
            TxtLogServices.WriteTxtLog(Convert.ToString(card.EndDate));

            DateTime dtCal = BaseCardServices.CalculateNewEndDate(start, card.EndDate, month);

            TxtLogServices.WriteTxtLog(Convert.ToString(dtCal));
            TxtLogServices.WriteTxtLog(Convert.ToString(afterdate));

            if (BaseCardServices.CalculateNewEndDate(start, card.EndDate, month) != afterdate.Date)
            {
                throw new MyException("计算月卡结束时间错误");
            }
            TxtLogServices.WriteTxtLog("34");
        }
Exemple #3
0
        public ActionResult SubmitMonthRenewals(string cardId, int month, double paymoney, PaymentChannel paytype, DateTime afterdate, string plateno, int source)
        {
            try
            {
                TxtLogServices.WriteTxtLog("1");

                TxtLogServices.WriteTxtLog(plateno);
                TxtLogServices.WriteTxtLog(cardId);
                TxtLogServices.WriteTxtLog(source.ToString());
                //TxtLogServices.WriteTxtLog(carInfos.Count().ToString());

                List <ParkUserCarInfo> carInfos = source == 1
                    ?RechargeService.GetMonthCarInfoByPlateNumber(plateno)
                    : RechargeService.GetMonthCarInfoByAccountID(WeiXinUser.AccountID);

                ParkUserCarInfo card = carInfos.FirstOrDefault(p => p.CardID == cardId);

                if (card == null)
                {
                    TxtLogServices.WriteTxtLog(carInfos.Count().ToString());
                    TxtLogServices.WriteTxtLog("2");
                }
                TxtLogServices.WriteTxtLog("3");

                CheckMonthCardOrder(card, month, paymoney, paytype, afterdate);
                TxtLogServices.WriteTxtLog("4");
                BaseCompany company = CompanyServices.QueryByParkingId(card.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 (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 = "车场所属公众号和当前公众号不匹配,不能支付!" }));
                }

                OnlineOrder model = new OnlineOrder();
                model.OrderID        = IdGenerator.Instance.GetId();
                model.CardId         = card.CardID;
                model.PKID           = card.PKID;
                model.PKName         = card.PKName;
                model.EntranceTime   = card.EndDate;
                model.ExitTime       = afterdate;
                model.MonthNum       = month;
                model.Amount         = (decimal)paymoney;
                model.Status         = OnlineOrderStatus.WaitPay;
                model.PaymentChannel = PaymentChannel.WeiXinPay;
                model.Payer          = WeiXinUser.OpenID;
                model.PayAccount     = WeiXinUser.OpenID;
                model.OrderTime      = DateTime.Now;
                model.PayeeChannel   = paytype;
                model.AccountID      = WeiXinUser.AccountID;
                model.OrderType      = OnlineOrderType.MonthCardRecharge;
                model.PlateNo        = card.PlateNumber;
                model.PayeeUser      = config.SystemName;
                model.PayeeAccount   = config.PartnerId;
                model.CompanyID      = config.CompanyID;
                bool result = OnlineOrderServices.Create(model);
                if (!result)
                {
                    throw new MyException("续期失败[保存订单失败]");
                }

                Response.Cookies.Add(new HttpCookie("SmartSystem_MonthCardPayment_Month", string.Format("{0},{1}", month, (int)paytype)));

                switch (model.PaymentChannel)
                {
                case PaymentChannel.WeiXinPay:
                {
                    return(RedirectToAction("MonthCardPayment", "WeiXinPayment", new { orderId = model.OrderID }));
                }

                default: throw new MyException("支付方式错误");
                }
            }
            catch (MyException ex)
            {
                return(PageAlert("MonthCardRenewal", "CardRenewal", new { cardId = cardId, RemindUserContent = ex.Message }));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptionToDbAndTxt("WeiXinWeb", string.Format("获取续费信息失败,编号:" + cardId), ex, LogFrom.WeiXin);
                return(PageAlert("MonthCardRenewal", "CardRenewal", new { cardId = cardId, RemindUserContent = "提交支付失败" }));
            }
        }
Exemple #4
0
        public ActionResult SubmitMonthRenewals(string cardId, int month, double paymoney, PaymentChannel paytype, DateTime afterdate, string plateno, int source)
        {
            try
            {
                List <ParkUserCarInfo> carInfos = new List <ParkUserCarInfo>();
                if (source == 1)
                {
                    carInfos = RechargeService.GetMonthCarInfoByPlateNumber(plateno);
                }
                else
                {
                    if (UserAccount != null)
                    {
                        carInfos = RechargeService.GetMonthCarInfoByAccountID(UserAccount.AccountID);
                    }
                }
                ParkUserCarInfo card = carInfos.FirstOrDefault(p => p.CardID == cardId);
                if (card == null)
                {
                    throw new MyException("获月卡信息失败");
                }
                CheckMonthCardOrder(card, month, paymoney, paytype, afterdate);

                BaseCompany company = CompanyServices.QueryByParkingId(card.PKID);
                if (company == null)
                {
                    throw new MyException("获取单位信息失败");
                }

                OnlineOrder model = new OnlineOrder();
                if (paytype == PaymentChannel.AliPay)
                {
                    AliPayApiConfig config = AliPayApiConfigServices.QueryAliPayConfig(company.CPID);
                    if (config == null)
                    {
                        ExceptionsServices.AddExceptionToDbAndTxt("H5CardRenewalError", "获取支付宝配置信息失败[0001]", "单位编号:" + company.CPID, LogFrom.WeiXin);
                        return(RedirectToAction("Index", "ErrorPrompt", new { message = "获取支付宝配置信息失败!" }));
                    }
                    if (!config.Status)
                    {
                        ExceptionsServices.AddExceptionToDbAndTxt("H5CardRenewalError", "该支付宝暂停使用", "单位编号:" + config.CompanyID, LogFrom.WeiXin);
                        return(RedirectToAction("Index", "ErrorPrompt", new { message = "该车场暂停使用支付宝支付!" }));
                    }
                    AliPayApiConfig requestConfig = AliPayApiConfigServices.QueryAliPayConfig(GetRequestCompanyId);
                    if (requestConfig == null)
                    {
                        throw new MyException("获取请求单位微信配置失败");
                    }

                    if (config.CompanyID != requestConfig.CompanyID)
                    {
                        ExceptionsServices.AddExceptionToDbAndTxt("H5CardRenewalError", "支付的支付宝配置和请求的支付配置不匹配,不能支付", string.Format("支付单位:{0},请求单位:{1}", config.CompanyID, requestConfig.CompanyID), LogFrom.WeiXin);
                        return(RedirectToAction("Index", "ErrorPrompt", new { message = "支付的支付宝配置和请求的支付配置不匹配,不能支付!" }));
                    }
                    model.PayeeUser      = config.SystemName;
                    model.PayeeAccount   = config.PayeeAccount;
                    model.PayeeChannel   = PaymentChannel.AliPay;
                    model.PaymentChannel = PaymentChannel.AliPay;
                    model.CompanyID      = config.CompanyID;
                }
                else
                {
                    WX_ApiConfig config = WXApiConfigServices.QueryWXApiConfig(company.CPID);
                    if (config == null)
                    {
                        ExceptionsServices.AddExceptionToDbAndTxt("H5CardRenewalError", "获取微信配置信息失败", "单位编号:" + company.CPID, LogFrom.WeiXin);
                        return(RedirectToAction("Index", "ErrorPrompt", new { message = "获取微信配置信息失败!" }));
                    }
                    if (!config.Status)
                    {
                        ExceptionsServices.AddExceptionToDbAndTxt("H5CardRenewalError", "该车场暂停使用微信支付", "单位编号:" + company.CPID, LogFrom.WeiXin);
                        return(RedirectToAction("Index", "ErrorPrompt", new { message = "该车场暂停使用微信支付!" }));
                    }
                    WX_ApiConfig requestConfig = WXApiConfigServices.QueryWXApiConfig(GetRequestCompanyId);
                    if (requestConfig == null)
                    {
                        throw new MyException("获取请求单位微信配置失败");
                    }

                    if (config.CompanyID != requestConfig.CompanyID)
                    {
                        ExceptionsServices.AddExceptionToDbAndTxt("H5CardRenewalError", "微信支付配置和当前请求微信支付配置不匹配,不能支付", string.Format("支付单位:{0},请求单位:{1}", config.CompanyID, requestConfig.CompanyID), LogFrom.WeiXin);
                        return(RedirectToAction("Index", "ErrorPrompt", new { message = "微信支付配置和当前请求微信支付配置不匹配,不能支付!" }));
                    }
                    model.PayeeUser      = config.SystemName;
                    model.PayeeAccount   = config.PartnerId;
                    model.PayeeChannel   = PaymentChannel.WeiXinPay;
                    model.PaymentChannel = PaymentChannel.WeiXinPay;
                    model.CompanyID      = config.CompanyID;
                }

                model.OrderID      = IdGenerator.Instance.GetId();
                model.CardId       = card.CardID;
                model.PKID         = card.PKID;
                model.PKName       = card.PKName;
                model.EntranceTime = card.EndDate;
                model.ExitTime     = afterdate;
                model.MonthNum     = month;
                model.Amount       = (decimal)paymoney;
                model.Status       = OnlineOrderStatus.WaitPay;

                model.OrderTime = DateTime.Now;
                model.AccountID = LoginAccountID;
                model.OrderType = OnlineOrderType.MonthCardRecharge;
                model.PlateNo   = card.PlateNumber;

                bool result = OnlineOrderServices.Create(model);
                if (!result)
                {
                    throw new MyException("续期失败[保存订单失败]");
                }

                Response.Cookies.Add(new HttpCookie("SmartSystem_MonthCardPayment_Month", string.Format("{0},{1}", month, (int)paytype)));

                switch (model.PaymentChannel)
                {
                case PaymentChannel.WeiXinPay:
                {
                    return(RedirectToAction("MonthCardPayment", "H5WeiXinPayment", new { orderId = model.OrderID }));
                }

                case PaymentChannel.AliPay:
                {
                    return(RedirectToAction("AliPayRequest", "H5Order", new { orderId = model.OrderID, requestSource = 2 }));
                }

                default: throw new MyException("支付方式错误");
                }
            }
            catch (MyException ex)
            {
                return(PageAlert("MonthCardRenewal", "H5CardRenewal", new { cardId = cardId, RemindUserContent = ex.Message }));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptionToDbAndTxt("H5CardRenewalError", string.Format("获取续费信息失败,编号:" + cardId), ex, LogFrom.WeiXin);
                return(PageAlert("MonthCardRenewal", "CardRenewal", new { cardId = cardId, RemindUserContent = "提交支付失败" }));
            }
        }