Пример #1
0
        ///// <summary>
        ///// 获取卡片开始时间当天的计算停车费用的收费费率
        ///// </summary>
        ///// <param name="cardType">卡片类型</param>
        ///// <param name="carType">车型</param>
        ///// <param name="parkingStatus">停车状态</param>
        ///// <param name="beginning">开始时间</param>
        ///// <returns></returns>
        //public TariffBase GetCalculateTariff(Byte? cardType, Byte carType, ParkingStatus parkingStatus, DateTime beginning,DateTime ending)
        //{
        //    TariffType tt = TariffType.Normal;
        //    if ((parkingStatus & ParkingStatus.NestedParkMarked) == ParkingStatus.NestedParkMarked)
        //    {
        //        if (HolidaySetting.Current.IsHoliday(beginning))
        //        {
        //            tt = TariffType.HolidayAndInnerRoom;
        //        }
        //        else
        //        {
        //            tt = TariffType.InnerRoom;
        //        }
        //    }
        //    else
        //    {
        //        if (HolidaySetting.Current.IsHoliday(beginning))
        //        {
        //            tt = TariffType.Holiday;
        //        }
        //    }

        //    TariffBase tb = GetTariff(cardType, carType, tt);//tt为null时免费
        //    return tb;
        //}


        ///// <summary>
        ///// 获取卡片某段时间的计算停车费用的收费费率
        ///// </summary>
        ///// <param name="carType">卡片类型</param>
        ///// <param name="isNested">是否内套车场</param>
        ///// <param name="beginning">入场时间</param>
        ///// <param name="ending">出场时间</param>
        ///// <returns></returns>
        //public TariffBase GetCalculateTariff(Byte carType, bool isNested, DateTime beginning, DateTime ending)
        //{
        //    TariffType tt = TariffType.Normal;
        //    if (isNested)
        //    {
        //        if (HolidaySetting.Current.IsInHoliday(beginning, ending))
        //        {
        //            tt = TariffType.HolidayAndInnerRoom;
        //        }
        //        else
        //        {
        //            tt = TariffType.InnerRoom;
        //        }
        //    }
        //    else
        //    {
        //        if (HolidaySetting.Current.IsInHoliday(beginning, ending))
        //        {
        //            tt = TariffType.Holiday;
        //        }
        //    }

        //    TariffBase tb = GetTariff(carType, tt);
        //    if (tb == null)  //如果没有找到相应的就用默认的收费费率
        //    {
        //        tb = GetTariff(CarTypeSetting.DefaultCarType, TariffType.Normal);
        //    }
        //    return tb;
        //}


        ///// <summary>
        ///// 计算卡片目前应收停车费用(包括外车场和内车场),如果之前已经多次收费,则费用会扣除相应的收费金额
        ///// </summary>
        ///// <param name="card">卡片</param>
        ///// <param name="freeTimeAfterPay">卡片收费后允许免费停留多少分钟</param>
        ///// <param name="carType">卡片收费车型</param>
        ///// <returns>停车收费信息</returns>
        //public ParkAccountsInfo CalculateCardParkFee(CardInfo card, Byte carType, DateTime chargeDateTime)
        //{
        //    ParkAccountsInfo parkAccounts = new ParkAccountsInfo();
        //    TariffBase tariff = null;
        //    if (card.CardType.IsPrimaryCardType && (card.CardType.IsTempCard || card.CardType.IsPrepayCard))
        //    {
        //        tariff = TariffSetting.Current.GetCalculateTariff(carType, false, card.LastDateTime, chargeDateTime);
        //    }
        //    else
        //    {
        //        tariff = card.CardType.GetTariff();
        //    }
        //    if (tariff != null)
        //    {
        //        parkAccounts.Accounts = tariff.CalculateFee(GetMyDateTime(card.LastDateTime), GetMyDateTime(chargeDateTime));
        //        parkAccounts.TariffType = tariff.TariffType;
        //        parkAccounts.CarType = carType;
        //        if (card.LastPayment != null)
        //        {
        //            //再重新以上次收费计费时间计算一次费用,如果计算结果比上次累计实收和累计折扣大,则表明之前有收费计算时与当前车型不一致,这部分
        //            //费用要重新补交。(防止下面这种情况出现:中央收费后设置允许15分钟内可以免费出场,则有些车主在入场后每隔15分钟去刷一次卡交费,
        //            //这样出场时就不会产生费用)
        //            decimal lastTotal = tariff.CalculateFee(GetMyDateTime(card.LastDateTime), GetMyDateTime(card.LastPayment.ChargeDateTime));
        //            if (lastTotal > card.LastPayment.TotalDiscount + card.LastPayment.TotalPaid) //之前还没有把费用全部收齐
        //            {
        //                parkAccounts.Accounts -= (card.LastPayment.TotalPaid + card.LastPayment.TotalDiscount);
        //            }
        //            else
        //            {
        //                TimeSpan ts = new TimeSpan(GetMyDateTime(chargeDateTime).Ticks - GetMyDateTime(card.LastPayment.ChargeDateTime).Ticks);
        //                if (ts.TotalMinutes <= TariffOption.FreeTimeAfterPay)
        //                {
        //                    parkAccounts.Accounts = 0;
        //                }
        //                else
        //                {
        //                    parkAccounts.Accounts -= (card.LastPayment.TotalPaid + card.LastPayment.TotalDiscount);
        //                    if (parkAccounts.Accounts < 0) parkAccounts.Accounts = 0;
        //                }
        //            }
        //        }
        //    }
        //    return parkAccounts;
        //}

        ///// <summary>
        ///// 计算卡片的应收停车费用,如果之前已经多次收费,则费用会扣除相应的收费金额
        ///// </summary>
        ///// <param name="card">卡片</param>
        ///// <param name="freeTimeAfterPay">卡片收费后允许免费停留多少分钟</param>
        ///// <param name="carType">卡片收费车型</param>
        ///// <returns>停车收费信息</returns>
        //public ParkAccountsInfo CalculateCardParkFee(CardInfo card, Byte carType, DateTime chargeDateTime)
        //{
        //    ParkAccountsInfo parkAccounts = new ParkAccountsInfo();
        //    TariffBase tariff = null;
        //    if (GlobalVariables.IsNETParkAndOffLie)
        //    {
        //        //网络型写卡模式获取费用
        //        tariff = TariffSetting.Current.GetCalculateTariff(card.CardType.ID, carType, card.ParkingStatus, card.LastDateTime, chargeDateTime);
        //    }
        //    else
        //    {
        //        //其他模式获取费率
        //        if (card.CardType.IsPrimaryCardType && (card.CardType.IsTempCard || card.CardType.IsPrepayCard))
        //        {
        //            tariff = TariffSetting.Current.GetCalculateTariff(null, carType, card.ParkingStatus, card.LastDateTime, chargeDateTime);
        //        }
        //        else
        //        {
        //            tariff = card.CardType.GetTariff();
        //        }
        //    }
        //    if (tariff != null)
        //    {
        //        //先计算车场费用
        //        decimal ParkFee = tariff.CalculateFee(GetMyDateTime(card.LastDateTime), GetMyDateTime(chargeDateTime));
        //        parkAccounts.ParkFee = ParkFee;
        //        parkAccounts.TariffType = tariff.TariffType;
        //        parkAccounts.CarType = carType;

        //        decimal accounts = ParkFee - card.TotalPaidFee;//已缴费用=停车费用-已收费用

        //        ////是否外车场已缴费
        //        //if (card.IsPaid)
        //        //{
        //        //    //判断上次缴费是否已收取全部费用,累计停车费用为0
        //        //    if (card.TotalFee > 0)
        //        //    {
        //        //        //上次收费有费用未收取
        //        //        if (ParkFee > card.ParkFee)
        //        //        {
        //        //            //费用为多出的费用
        //        //            accounts = ParkFee - card.ParkFee;
        //        //        }
        //        //    }
        //        //    else
        //        //    {
        //        //        //已完成收费,判断是否已过收费后免费时间
        //        //        if (!TariffSetting.Current.IsInFreeTime(card.PaidDateTime.Value, chargeDateTime))
        //        //        {
        //        //            //已过免费时间
        //        //            if (ParkFee > card.ParkFee)
        //        //            {
        //        //                //费用为多出的费用
        //        //                accounts = ParkFee - card.ParkFee;
        //        //            }
        //        //        }
        //        //        else
        //        //        {
        //        //            //还处于免费时间,车场费用为卡片中的停车费用
        //        //            parkAccounts.ParkFee = card.ParkFee;
        //        //        }
        //        //    }

        //        //}
        //        //else
        //        //{
        //        //    //未缴费,费用为外车场费用
        //        //    accounts = ParkFee;
        //        //}

        //        //parkAccounts.Accounts = accounts + card.TotalFee;

        //        if (card.IsCompletedPaid)
        //        {
        //            //已完成缴费,判断是否已过收费后免费时间
        //            if (TariffSetting.Current.IsInFreeTime(card.PaidDateTime.Value, chargeDateTime))
        //            {

        //                accounts = 0;
        //                //还处于免费时间,车场费用为卡片中的停车费用
        //                parkAccounts.ParkFee = card.ParkFee;
        //            }
        //        }
        //        parkAccounts.Accounts = accounts > 0 ? accounts : 0;
        //    }
        //    return parkAccounts;
        //}

        /// <summary>
        /// 计算卡片的应收停车费用,如果之前已经多次收费,则费用会扣除相应的收费金额
        /// </summary>
        /// <param name="card">卡片</param>
        /// <param name="freeTimeAfterPay">卡片收费后允许免费停留多少分钟</param>
        /// <param name="carType">卡片收费车型</param>
        /// <returns>停车收费信息</returns>
        public ParkAccountsInfo CalculateCardParkFee(CardInfo card, Byte carType, DateTime chargeDateTime)
        {
            ParkAccountsInfo parkAccounts = new ParkAccountsInfo();
            TariffBase       tariff       = null;
            DateTime         begin        = GetMyDateTime(card.LastDateTime);
            DateTime         end          = GetMyDateTime(chargeDateTime);

            do
            {
                tariff = GetIntradayTariff(card, carType, begin);
                if (tariff == null)
                {
                    //获取费率为空时,可认为当天的费用为0,开始时间修改为下一天的0:00
                    begin = begin.AddDays(1);
                    begin = new DateTime(begin.Year, begin.Month, begin.Day, 0, 0, 0);
                    if (begin > end)
                    {
                        break;
                    }
                }
            }while (tariff == null);

            if (tariff != null)
            {
                tariff.Card = card;
                //先计算车场费用
                decimal ParkFee = tariff.CalculateFee(begin, end);
                parkAccounts.ParkFee    = ParkFee;
                parkAccounts.TariffType = tariff.TariffType;
                parkAccounts.CarType    = carType;

                decimal accounts = ParkFee - card.TotalPaidFee;//已缴费用=停车费用-已收费用

                if (card.IsCompletedPaid)
                {
                    //已完成缴费,判断是否已过收费后免费时间
                    if (TariffSetting.Current.IsInFreeTime(card.PaidDateTime.Value, end))
                    {
                        accounts = 0;
                        //还处于免费时间,车场费用为卡片中的停车费用
                        parkAccounts.ParkFee = card.ParkFee;
                    }
                }
                parkAccounts.Accounts = accounts > 0 ? accounts : 0;

                tariff.Card = null;
            }
            return(parkAccounts);
        }
Пример #2
0
        public ParkAccountsInfo CalculateCardParkFee(int?parkID, CardInfo card, Byte carType, DateTime chargeDateTime)
        {
            ParkAccountsInfo parkAccounts = new ParkAccountsInfo();

            parkAccounts.CarType = carType;

            decimal fee = 0;

            //以卡片的入场时间计算
            DateTime beginning = GetMyDateTime(card.LastDateTime);

            //如果启用了酒店应用
            if (card.EnableHotelApp)
            {
                if (card.IsInFreeTime(chargeDateTime))
                {
                    //处于免费时间点内,费用为0
                    return(parkAccounts);
                }
                else if (card.FreeDateTime.HasValue && card.FreeDateTime.Value > beginning)
                {
                    //过了免费时间点的,如果免费时间点大于开始时间,以免费时间点为开始时间计算费用
                    beginning = GetMyDateTime(card.FreeDateTime.Value);
                }
            }
            DateTime ending    = GetMyDateTime(chargeDateTime);
            TimeSpan ts        = new TimeSpan(ending.Ticks - beginning.Ticks);
            double   totalMins = Math.Ceiling(ts.TotalMinutes);

            if (totalMins < 0)
            {
                return(parkAccounts);                //入场时间大于出场时间
            }
            DateTime   begin  = beginning;
            DateTime   end    = beginning;
            TariffBase tariff = null;

            while (begin < ending)
            {
                tariff = GetCalculateTariff(parkID, card.CardType.ID, carType, card.ParkingStatus, begin);
                while (end.Date < ending.Date)
                {
                    end = end.AddDays(1);
                    TariffBase tb = GetCalculateTariff(parkID, card.CardType.ID, carType, card.ParkingStatus, end);
                    if (
                        (tariff == null && tb == null) ||
                        (tariff != null && tariff.Equals(tb))
                        )
                    {
                        //donothing
                    }
                    else
                    {
                        end = end.Date;
                        if (tariff != null)
                        {
                            decimal temp = tariff.CalculateFee(begin, end);
                            fee += tariff.FeeOfMax > 0 && tariff.FeeOfMax < temp ? tariff.FeeOfMax : temp;
                            parkAccounts.TariffType = tariff.TariffType;
                        }
                        tariff = tb;
                        begin  = end <= ending ? end : ending;
                        end    = begin;
                        break;
                    }
                }
                if (end.Date == ending.Date)
                {
                    break;
                }
            }
            //if (tariff is TariffOfGuanZhou) //2015-4-29 修改为计算费用时,判断该日夜差异收费费率是否允许一次收费多次进出
            //{
            //    TariffOfGuanZhou tariffguangzhou = tariff as TariffOfGuanZhou;
            //    if (tariffguangzhou != null)
            //    {
            //        if (tariffguangzhou.DayTimezone.ZSLH1 == true) //白天时段一次交费多次进出
            //        {
            //            if (tariffguangzhou.DayTimezone.IsIn(chargeDateTime)) //出场时间是否在免费时间之内
            //            {
            //                parkAccounts.FeeEndDateTime = Convert.ToDateTime(DateTime.Now.ToLongDateString() + tariffguangzhou.DayTimezone.Ending.Hour.ToString() + ":" + tariffguangzhou.DayTimezone.Ending.Minute.ToString());
            //            }
            //        }
            //        if (tariffguangzhou.NightTimezone.ZSLH2 == true) //夜晚时段一次交费多次进出
            //        {
            //            if (tariffguangzhou.NightTimezone.IsIn(chargeDateTime)) //出场时间是否在免费时间之内
            //            {
            //                parkAccounts.FeeEndDateTime = Convert.ToDateTime(DateTime.Now.ToLongDateString() + tariffguangzhou.NightTimezone.Ending.Hour.ToString() + ":" + tariffguangzhou.DayTimezone.Ending.Minute.ToString());
            //            }
            //        }
            //    }
            //}
            if (tariff != null && begin < ending)
            {
                decimal temp = tariff.CalculateFee(begin, ending);
                fee += tariff.FeeOfMax > 0 && tariff.FeeOfMax < temp ? tariff.FeeOfMax : temp;
            }
            parkAccounts.ParkFee = fee;
            decimal accounts = fee - card.TotalPaidFee;//已缴费用=停车费用-已收费用

            if (card.IsCompletedPaid)
            {
                //已完成缴费,判断是否已过收费后免费时间
                if (IsInFreeTime(card.PaidDateTime.Value, chargeDateTime))
                {
                    accounts = 0;
                    //还处于免费时间,车场费用为卡片中的停车费用
                    parkAccounts.ParkFee = card.ParkFee;
                }
            }
            parkAccounts.Accounts = accounts > 0 ? accounts : 0;
            return(parkAccounts);
        }
Пример #3
0
        /// <summary>
        /// 计算卡片的应收停车费用,如果之前已经多次收费,则费用会扣除相应的收费金额
        /// </summary>
        /// <param name="card">卡片</param>
        /// <param name="carType">卡片收费车型</param>
        /// <returns>停车收费信息</returns>
        public ParkAccountsInfo CalculateCardParkFee(CardInfo card, Byte carType, DateTime chargeDateTime)
        {
            ParkAccountsInfo parkAccounts = new ParkAccountsInfo();

            parkAccounts.CarType = carType;

            decimal fee = 0;

            //以卡片的入场时间计算
            DateTime beginning = GetMyDateTime(card.LastDateTime);

            //如果启用了酒店应用
            if (card.EnableHotelApp)
            {
                if (card.IsInFreeTime(chargeDateTime))
                {
                    //处于免费时间点内,费用为0
                    return(parkAccounts);
                }
                else if (card.FreeDateTime.HasValue && card.FreeDateTime.Value > beginning)
                {
                    //过了免费时间点的,如果免费时间点大于开始时间,以免费时间点为开始时间计算费用
                    beginning = GetMyDateTime(card.FreeDateTime.Value);
                }
            }

            DateTime ending    = GetMyDateTime(chargeDateTime);
            TimeSpan ts        = new TimeSpan(ending.Ticks - beginning.Ticks);
            double   totalMins = Math.Ceiling(ts.TotalMinutes);

            if (totalMins < 0)
            {
                return(parkAccounts);                //入场时间大于出场时间
            }
            DateTime   begin  = beginning;
            DateTime   end    = beginning;
            TariffBase tariff = null;

            while (begin < ending)
            {
                tariff = GetCalculateTariff(card.CardType.ID, carType, card.ParkingStatus, begin);
                while (end.Date < ending.Date)
                {
                    end = end.AddDays(1);
                    TariffBase tb = GetCalculateTariff(card.CardType.ID, carType, card.ParkingStatus, end);
                    if (
                        (tariff == null && tb == null) ||
                        (tariff != null && tariff.Equals(tb))
                        )
                    {
                        //donothing
                    }
                    else
                    {
                        end = end.Date;
                        if (tariff != null)
                        {
                            decimal temp = tariff.CalculateFee(begin, end);
                            fee += tariff.FeeOfMax > 0 && tariff.FeeOfMax < temp ? tariff.FeeOfMax : temp;
                            parkAccounts.TariffType = tariff.TariffType;
                        }
                        tariff = tb;
                        begin  = end <= ending ? end : ending;
                        end    = begin;
                        break;
                    }
                }
                if (end.Date == ending.Date)
                {
                    break;
                }
            }
            if (tariff != null && begin < ending)
            {
                decimal temp = tariff.CalculateFee(begin, ending);
                fee += tariff.FeeOfMax > 0 && tariff.FeeOfMax < temp ? tariff.FeeOfMax : temp;
            }
            parkAccounts.ParkFee = fee;
            decimal accounts = fee - card.TotalPaidFee;//已缴费用=停车费用-已收费用

            if (card.IsCompletedPaid)
            {
                //已完成缴费,判断是否已过收费后免费时间
                if (TariffSetting.Current.IsInFreeTime(card.PaidDateTime.Value, chargeDateTime))
                {
                    accounts = 0;
                    //还处于免费时间,车场费用为卡片中的停车费用
                    parkAccounts.ParkFee = card.ParkFee;
                }
            }
            parkAccounts.Accounts = accounts > 0 ? accounts : 0;
            return(parkAccounts);
        }