Example #1
0
        string GetPic(string imagepath)
        {
            string imagedata = "";

            if (System.IO.File.Exists(imagepath))
            {
                Stream s = System.IO.File.Open(imagepath, FileMode.Open);
                try
                {
                    byte[] bt = new byte[s.Length];
                    s.Read(bt, 0, (int)s.Length);
                    imagedata = Convert.ToBase64String(bt);
                }
                catch (Exception ex)
                {
                    Common.Services.TxtLogServices.WriteTxtLog("获取图片异常 图片路径:{0} 异常信息:{1}", imagepath, ex.Message);
                }
                finally
                {
                    s.Close();
                }
            }
            else
            {
                TxtLogServices.WriteTxtLog("图片文件路径不存在", imagepath);
            }
            return(imagedata);
        }
Example #2
0
        private string CalculateNewEndDate(DateTime?beginDate, DateTime?endDate, int month)
        {
            TxtLogServices.WriteTxtLog(Convert.ToString(beginDate));
            TxtLogServices.WriteTxtLog(Convert.ToString(endDate));
            //TxtLogServices.WriteTxtLog(beginDate);
            DateTime start = beginDate.HasValue ? (beginDate.Value == DateTime.MaxValue ? DateTime.Now : beginDate.Value) : DateTime.Now;

            TxtLogServices.WriteTxtLog(Convert.ToString(beginDate));
            TxtLogServices.WriteTxtLog(Convert.ToString(endDate));
            return(BaseCardServices.CalculateNewEndDate(start, endDate, month).ToString("yyyy-MM-dd"));
        }
Example #3
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");
        }
Example #4
0
 /// <summary>
 /// 获得进场图片
 /// </summary>
 /// <param name="imgpath">进场图片路径</param>
 /// <returns></returns>
 public JsonResult GetEntranceImages(string ImagePathEntrance)
 {
     try
     {
         if (string.IsNullOrEmpty(ImagePathEntrance))
         {
             throw new Exception("图片为空");
         }
         ImgModel img  = new ImgModel();
         string   path = System.IO.Path.Combine(ImagePath, ImagePathEntrance);
         img.ImgBig   = GetPic(path);
         path         = path.Replace("Big", "Small");
         img.ImgSmall = GetPic(path);
         if (img.ImgSmall.Length == 0)
         {
             img.ImgSmall = LoadingPic(false);
         }
         if (img.ImgBig.Length == 0)
         {
             img.ImgBig = LoadingPic(true);
         }
         object entranceimg = new
         {
             Base64ImageEntrance      = img.ImgBig,
             Base64ImageEntranceSmall = img.ImgSmall
         };
         return(Json(entranceimg, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         object entranceimg = new
         {
             Base64ImageEntrance      = LoadingPic(true),
             Base64ImageEntranceSmall = LoadingPic(false)
         };
         TxtLogServices.WriteTxtLog("获取进场图片异常 异常信息:{0}", ex.Message);
         return(Json(entranceimg, JsonRequestBehavior.AllowGet));
     }
 }
Example #5
0
        /// <summary>
        /// 当班统计
        /// </summary>
        public void Statistics_OnDuty(string ParkingID)
        {
            try
            {
                IParking                iparking               = ParkingFactory.GetFactory();
                IParkIORecord           iorecordfactory        = ParkIORecordFactory.GetFactory();
                IStatistics_Gather      gatherfactory          = Statistics_GatherFactory.GetFactory();
                IParkChangeshiftrecord  ichangeshift           = ParkChangeshiftrecordFactory.GetFactory();
                IParkOrder              iorder                 = ParkOrderFactory.GetFactory();
                IParkBox                iparkbox               = ParkBoxFactory.GetFactory();
                IStatistics_ChangeShift istatisticschangeshift = Statistics_ChangeShiftFactory.GetFactory();
                BaseParkinfo            parking                = iparking.QueryParkingByParkingID(ParkingID);
                List <ParkBox>          boxlist                = iparkbox.QueryByParkingID(parking.PKID);
                if (boxlist != null && boxlist.Count > 0)
                {
                    foreach (ParkBox box in boxlist)
                    {
                        List <ParkChangeshiftrecord> ondutys = ichangeshift.GetChangeShiftRecord(box.BoxID);
                        if (ondutys == null || ondutys.Count == 0)
                        {
                            continue;
                        }
                        foreach (ParkChangeshiftrecord onduty in ondutys)
                        {
                            Statistics_ChangeShift changeshift = new Statistics_ChangeShift
                            {
                                BoxID         = onduty.BoxID,
                                ParkingName   = parking.PKName,
                                StartWorkTime = onduty.StartWorkTime,
                                EndWorkTime   = onduty.EndWorkTime,
                                ParkingID     = parking.PKID,
                                AdminID       = onduty.UserID,
                                ChangeShiftID = onduty.RecordID
                            };
                            DateTime starttime = onduty.StartWorkTime;
                            DateTime endtime   = DateTime.Now;
                            if (onduty.EndWorkTime > DateTime.MinValue)
                            {
                                endtime = onduty.EndWorkTime;
                            }
                            //统计相关信息
                            //查询进场数
                            changeshift.Entrance_Count = iorecordfactory.EntranceCountByBox(box.BoxID, starttime, endtime);
                            //查询出场数
                            changeshift.Exit_Count = iorecordfactory.ExitCountByBox(box.BoxID, starttime, endtime);
                            #region 进场卡片类型
                            List <KeyValue> _InCardType = iorecordfactory.GetInCardTypeByBoxID(box.BoxID, starttime, endtime);
                            if (_InCardType != null && _InCardType.Count > 0)
                            {
                                foreach (var k in _InCardType)
                                {
                                    switch (k.KeyName)
                                    {
                                    case "0":
                                        changeshift.VIPCard = k.Key_Value;
                                        break;

                                    case "1":
                                        changeshift.StordCard = k.Key_Value;
                                        break;

                                    case "2":
                                        changeshift.MonthCard = k.Key_Value;
                                        break;

                                    case "3":
                                        changeshift.TempCard = k.Key_Value;
                                        break;

                                    case "4":
                                        changeshift.JobCard = k.Key_Value;
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }
                            #endregion

                            #region 统计放行类型
                            List <KeyValue> _ReleaseType = iorecordfactory.GetReleaseTypeByBox(box.BoxID, starttime, endtime);
                            if (_ReleaseType != null && _ReleaseType.Count > 0)
                            {
                                foreach (KeyValue k in _ReleaseType)
                                {
                                    switch (k.KeyName)
                                    {
                                    case "0":
                                        changeshift.ReleaseType_Normal = k.Key_Value;
                                        break;

                                    case "1":
                                        changeshift.ReleaseType_Charge = k.Key_Value;
                                        break;

                                    case "2":
                                        changeshift.ReleaseType_Free = k.Key_Value;
                                        break;

                                    case "3":
                                        changeshift.ReleaseType_Catch = k.Key_Value;
                                        break;
                                    }
                                }
                            }
                            #endregion

                            #region 统计费用相关
                            List <ParkOrder> _orderfee = iorder.GetOrdersByBoxID(parking.PKID, onduty.BoxID, starttime, endtime);
                            if (_orderfee != null && _orderfee.Count > 0)
                            {
                                foreach (ParkOrder o in _orderfee)
                                {
                                    changeshift.Receivable_Amount += o.Amount;
                                    changeshift.Diff_Amount       += o.UnPayAmount;
                                    changeshift.Real_Amount        = (changeshift.Receivable_Amount - changeshift.Diff_Amount);
                                    //支付方式(1.现金、2.微信、3.支付宝、4.网银、5.电子钱包、6.优免卷7.余额
                                    switch (o.PayWay)
                                    {
                                    case OrderPayWay.Cash:
                                        changeshift.Cash_Amount += o.PayAmount;
                                        changeshift.Cash_Count++;

                                        if (o.DiscountAmount > 0)
                                        {
                                            changeshift.CashDiscount_Amount += o.DiscountAmount;
                                            changeshift.CashDiscount_Count++;

                                            changeshift.Discount_Amount += o.DiscountAmount;
                                            changeshift.Discount_Count++;
                                        }
                                        break;

                                    case OrderPayWay.WeiXin:
                                    case OrderPayWay.Alipay:
                                    case OrderPayWay.OnlineBanking:
                                    case OrderPayWay.Wallet:
                                        changeshift.OnLine_Amount += o.PayAmount;
                                        changeshift.OnLine_Count++;

                                        if (o.DiscountAmount > 0)
                                        {
                                            changeshift.OnLineDiscount_Amount += o.DiscountAmount;
                                            changeshift.OnLineDiscount_Count++;

                                            changeshift.Discount_Amount += o.DiscountAmount;
                                            changeshift.Discount_Count++;
                                        }
                                        break;

                                    case OrderPayWay.PreferentialTicket:
                                        changeshift.Discount_Amount += o.DiscountAmount;
                                        changeshift.Discount_Count++;
                                        break;

                                    case OrderPayWay.ValueCard:
                                        changeshift.StordCard_Amount += o.PayAmount;
                                        changeshift.StordCard_Count++;
                                        break;
                                    }
                                    switch (o.OrderType)
                                    {
                                    //临时卡缴费
                                    case OrderType.TempCardPayment:
                                    case OrderType.AreaTempCardPayment:
                                        switch (o.PayWay)
                                        {
                                        case OrderPayWay.WeiXin:
                                        case OrderPayWay.Alipay:
                                        case OrderPayWay.OnlineBanking:
                                        case OrderPayWay.Wallet:
                                            changeshift.OnLineTemp_Amount += o.PayAmount;
                                            changeshift.OnLineTemp_Count++;
                                            break;

                                        default:
                                            changeshift.Temp_Amount += o.PayAmount;
                                            changeshift.Temp_Count++;
                                            break;
                                        }
                                        break;

                                    //月卡续期
                                    case OrderType.MonthCardPayment:
                                        switch (o.PayWay)
                                        {
                                        case OrderPayWay.WeiXin:
                                        case OrderPayWay.Alipay:
                                        case OrderPayWay.OnlineBanking:
                                        case OrderPayWay.Wallet:
                                            changeshift.OnLineMonthCardExtend_Amount += o.PayAmount;
                                            changeshift.OnLineMonthCardExtend_Count++;
                                            break;

                                        default:
                                            changeshift.MonthCardExtend_Amount += o.PayAmount;
                                            changeshift.MonthCardExtend_Count++;
                                            break;
                                        }
                                        break;

                                    //VIP卡续期
                                    case OrderType.VIPCardRenewal:
                                        changeshift.VIPExtend_Count++;
                                        break;

                                    //储值卡充值
                                    case OrderType.ValueCardRecharge:
                                        switch (o.PayWay)
                                        {
                                        case OrderPayWay.WeiXin:
                                        case OrderPayWay.Alipay:
                                        case OrderPayWay.OnlineBanking:
                                        case OrderPayWay.Wallet:
                                            changeshift.OnLineStordCard_Amount += o.PayAmount;
                                            changeshift.OnLineStordCard_Count++;
                                            break;

                                        default:
                                            changeshift.StordCardRecharge_Amount += o.PayAmount;
                                            changeshift.StordCardRecharge_Count++;
                                            break;
                                        }
                                        break;
                                    }
                                }
                            }
                            #endregion
                            using (DbOperator dboperator = ConnectionManager.CreateReadConnection())
                            {
                                try
                                {
                                    dboperator.BeginTransaction();
                                    istatisticschangeshift.Delete(onduty.RecordID, dboperator);
                                    istatisticschangeshift.Insert(changeshift, dboperator);
                                    dboperator.CommitTransaction();
                                }
                                catch (Exception ex)
                                {
                                    TxtLogServices.WriteTxtLog("添加当班信息异常 异常信息:{0}", ex.Message);
                                    dboperator.RollbackTransaction();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TxtLogServices.WriteTxtLog("当班统计异常 异常信息:{0}", ex.Message);
            }
        }
Example #6
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 = "提交支付失败" }));
            }
        }
Example #7
0
 public JsonResult GetImages(string ImagePathEntrance, string ImagePathExit)
 {
     try
     {
         ImgModel imgentrance = new ImgModel();
         ImgModel imgexit     = new ImgModel();
         if (!string.IsNullOrEmpty(ImagePathEntrance))
         {
             string path = System.IO.Path.Combine(ImagePath, ImagePathEntrance);
             imgentrance.ImgBig = GetPic(path);
             path = path.Replace("Big", "Small");
             imgentrance.ImgSmall = GetPic(path);
         }
         if (!string.IsNullOrEmpty(ImagePathExit))
         {
             string path = System.IO.Path.Combine(ImagePath, ImagePathExit);
             imgexit.ImgBig   = GetPic(path);
             path             = path.Replace("Big", "Small");
             imgexit.ImgSmall = GetPic(path);
         }
         if (imgentrance.ImgSmall.Length == 0 || imgexit.ImgSmall.Length == 0)
         {
             var v = LoadingPic(false);
             if (imgentrance.ImgSmall.Length == 0)
             {
                 imgentrance.ImgSmall = v;
             }
             if (imgexit.ImgSmall.Length == 0)
             {
                 imgexit.ImgSmall = v;
             }
         }
         if (imgentrance.ImgBig.Length == 0 || imgexit.ImgBig.Length == 0)
         {
             var v = LoadingPic(true);
             if (imgentrance.ImgBig.Length == 0)
             {
                 imgentrance.ImgBig = v;
             }
             if (imgexit.ImgBig.Length == 0)
             {
                 imgexit.ImgBig = v;
             }
         }
         object entranceimg = new
         {
             Base64ImageEntrance      = imgentrance.ImgBig,
             Base64ImageExit          = imgexit.ImgBig,
             Base64ImageEntranceSmall = imgentrance.ImgSmall,
             Base64ImageExitSmall     = imgexit.ImgSmall
         };
         return(Json(entranceimg, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         TxtLogServices.WriteTxtLog("获取进出场图片异常 异常信息:{0}", ex.Message);
         string bigimg      = LoadingPic(true);
         string smallimg    = LoadingPic(false);
         object entranceimg = new
         {
             Base64ImageEntrance      = bigimg,
             Base64ImageExit          = bigimg,
             Base64ImageEntranceSmall = smallimg,
             Base64ImageExitSmall     = smallimg
         };
         return(Json(entranceimg, JsonRequestBehavior.AllowGet));
     }
 }
Example #8
0
        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" }));
            }
        }
Example #9
0
        /// <summary>
        /// 停车时长统计
        /// </summary>
        public void Statistics_LongTime(DateTime start, DateTime end)
        {
            try
            {
                IParking      iparking        = ParkingFactory.GetFactory();
                IParkIORecord iorecordfactory = ParkIORecordFactory.GetFactory();
                IStatistics_GatherLongTime gatherlongtimefactory = Statistics_GatherLongTimeFactory.GetFactory();
                string strerror           = string.Empty;
                List <BaseParkinfo> parks = iparking.QueryParkingAll();
                //取得所有有效车场
                if (parks != null && parks.Count > 0)
                {
                    foreach (BaseParkinfo park in parks)
                    {
                        if (park.IsOnLineGathe == YesOrNo.Yes)
                        {
                            continue;
                        }

                        //近7天的统计数据. 如果没有则补上.
                        int loop = (end - start).Days;
                        while (loop >= 0)
                        {
                            #region 变量
                            DateTime dtNow      = end;
                            DateTime GatherTime = DateTime.Parse(dtNow.AddDays(-1 - loop).ToString("yyyy-MM-dd 00:00:00"));
                            DateTime EndTime    = DateTime.Parse(dtNow.AddDays(-1 - loop).ToString("yyyy-MM-dd 23:59:59"));
                            int      longtime1  = 0;
                            int      longtime2  = 0;
                            int      longtime3  = 0;
                            int      longtime4  = 0;
                            int      longtime5  = 0;
                            int      longtime6  = 0;
                            int      longtime7  = 0;
                            int      longtime8  = 0;
                            int      longtime9  = 0;
                            int      longtime10 = 0;
                            int      longtime11 = 0;
                            int      longtime12 = 0;
                            int      longtime13 = 0;
                            int      longtime14 = 0;
                            int      longtime15 = 0;
                            int      longtime16 = 0;
                            int      longtime17 = 0;
                            int      longtime18 = 0;
                            int      longtime19 = 0;
                            int      longtime20 = 0;
                            int      longtime21 = 0;
                            int      longtime22 = 0;
                            int      longtime23 = 0;
                            int      longtime24 = 0;
                            #endregion

                            #region 判断是否已统计过
                            //判断统计数据是否存在.
                            if (gatherlongtimefactory.IsExists(park.PKID, GatherTime))
                            {
                                loop--;
                                continue;
                            }
                            #endregion

                            #region 获取记录并生成统计数据
                            List <ParkIORecord> iorecordlist = iorecordfactory.GetCarEntranceTimeAndExitTime(park.PKID, GatherTime, EndTime);
                            if (iorecordlist != null && iorecordlist.Count > 0)
                            {
                                foreach (ParkIORecord record in iorecordlist)
                                {
                                    int CarInHour = 0;
                                    if (record.EntranceTime == DateTime.MinValue)
                                    {
                                        CarInHour = 24;
                                    }
                                    else
                                    {
                                        if (record.ExitTime == DateTime.MinValue)
                                        {
                                            record.ExitTime = EndTime;
                                        }
                                        TimeSpan ts = EndTime - record.EntranceTime;
                                        CarInHour = System.Convert.ToInt32(Math.Ceiling(ts.Seconds / 3600.0));
                                    }
                                    switch (CarInHour)
                                    {
                                    case 1:
                                        longtime1++;
                                        break;

                                    case 2:
                                        longtime2++;
                                        break;

                                    case 3:
                                        longtime3++;
                                        break;

                                    case 4:
                                        longtime4++;
                                        break;

                                    case 5:
                                        longtime5++;
                                        break;

                                    case 6:
                                        longtime6++;
                                        break;

                                    case 7:
                                        longtime7++;
                                        break;

                                    case 8:
                                        longtime8++;
                                        break;

                                    case 9:
                                        longtime9++;
                                        break;

                                    case 10:
                                        longtime10++;
                                        break;

                                    case 11:
                                        longtime11++;
                                        break;

                                    case 12:
                                        longtime12++;
                                        break;

                                    case 13:
                                        longtime13++;
                                        break;

                                    case 14:
                                        longtime14++;
                                        break;

                                    case 15:
                                        longtime15++;
                                        break;

                                    case 16:
                                        longtime16++;
                                        break;

                                    case 17:
                                        longtime17++;
                                        break;

                                    case 18:
                                        longtime18++;
                                        break;

                                    case 19:
                                        longtime19++;
                                        break;

                                    case 20:
                                        longtime20++;
                                        break;

                                    case 21:
                                        longtime21++;
                                        break;

                                    case 22:
                                        longtime22++;
                                        break;

                                    case 23:
                                        longtime23++;
                                        break;

                                    case 24:
                                        longtime24++;
                                        break;
                                    }
                                }

                                #region 插入统计数据
                                string strSql = "insert into statistics_gatherlongtime(ParkingID,RecordID,GatherTime,LTime,Times,HaveUpdate,LastUpdateTime)"
                                                + " select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',1," + longtime1 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',2," + longtime2 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',3," + longtime3 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',4," + longtime4 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',5," + longtime5 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',6," + longtime6 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',7," + longtime7 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',8," + longtime8 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',9," + longtime9 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',10," + longtime10 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',11," + longtime11 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',12," + longtime12 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',13," + longtime13 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',14," + longtime14 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',15," + longtime15 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',16," + longtime16 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',17," + longtime17 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',18," + longtime18 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',19," + longtime19 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',20," + longtime20 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',21," + longtime21 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',22," + longtime22 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',23," + longtime23 + ",1,getdate()"
                                                + " union select '" + park.PKID + "','" + System.Guid.NewGuid().ToString() + "','" + GatherTime + "',24," + longtime24 + ",1,getdate()";
                                if (!gatherlongtimefactory.Insert(strSql))
                                {
                                    TxtLogServices.WriteTxtLog("插入停车时长统计信息异常 Sql:" + strSql);
                                }
                                #endregion
                            }
                            #endregion
                            loop--;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TxtLogServices.WriteTxtLog("统计停车时长信息异常 异常信息:" + ex.Message);
            }
        }