Exemplo n.º 1
0
        public override decimal GetChargeUnitFee(DateTime beginning)
        {
            decimal  fee   = 0;
            TimeZone other = new TimeZone(LimitationTimezone.Ending, LimitationTimezone.Beginning); //如果有限价时段,那么其它的时间就组成另一个时段

            if (other.IsIn(beginning))
            {
                fee += FirstFee.Fee;
            }
            else if (LimitationTimezone.IsIn(beginning))
            {
                fee += LimitationRegularFee.Fee;
                if (Limitation > 0 && fee > Limitation)
                {
                    fee = Limitation;
                }
            }

            if (FeeOf24Hour > 0 && fee > FeeOf24Hour)
            {
                fee = FeeOf24Hour;
            }

            if (FeeOfMax > 0 && fee > FeeOfMax)
            {
                fee = FeeOfMax;                                //有封顶费用
            }
            return(fee);
        }
Exemplo n.º 2
0
        //public override decimal CalculateFee(DateTime beginning, DateTime ending)
        //{
        //    decimal fee = 0;
        //    decimal daysfee = 0;
        //    TimeSpan ts = new TimeSpan(ending.Ticks - beginning.Ticks);
        //    double totalMins = Math.Floor(ts.TotalMinutes);
        //    double calMins = 0; //已经计费的分钟数
        //    if (totalMins < 0) return 0;  //入场时间大于出场时间
        //    if (FreeMinutes > 0 && ts.TotalMinutes <= FreeMinutes) return 0;//小于免费停车时间
        //    if (FreeMinutes == 0 && ts.TotalMinutes == 0) return GetChargeUnitFee(beginning);//返回收费单元的费用

        //    DateTime begin = beginning;
        //    DateTime end = begin.AddDays(1);

        //    TariffBase tariff = this;

        //    //收费都是按24小时为一周期
        //    while (end <= ending)
        //    {
        //        daysfee += tariff.CalcalateCycleFee(calMins, begin, end);
        //        begin = end;
        //        end = begin.AddDays(1);
        //        calMins += 1440;

        //        while (Card != null && begin < ending)
        //        {
        //            //开始一个收费周期
        //            tariff = TariffSetting.Current.GetIntradayTariff(Card, CarType, begin);//获取下一个收费周期的费率
        //            if (tariff != null || end >= ending) break;
        //            begin = end;
        //            end = begin.AddDays(1);
        //            calMins += 1440;
        //        }
        //    }

        //    if (tariff != null)
        //    {
        //        fee = tariff.CalcalateIntradayFee(calMins, begin, ending);
        //    }
        //    //计算超过3小时部分阶段
        //    fee = fee + daysfee;


        //    if (FeeOfMax > 0 && fee > FeeOfMax) fee = FeeOfMax;//有封顶费用

        //    return fee;
        //}

        public override decimal CalcalateIntradayFee(double calMins, DateTime beginning, DateTime ending)
        {
            decimal fee = 0;

            //把预定时间的费用收完
            double   sliceAll = 0;
            TimeZone other    = new TimeZone(LimitationTimezone.Ending, LimitationTimezone.Beginning); //如果有限价时段,那么其它的时间就组成另一个时段

            while (beginning < ending)
            {
                sliceAll = other.Slice(beginning, ending, FirstFee.Minutes, false);
                if (sliceAll > 0)
                {
                    if (calMins < FirstMinutes) //如果还在入场时间内
                    {
                        double f**k = (FirstMinutes - calMins) > sliceAll ? sliceAll : (FirstMinutes - calMins);
                        fee      += ((decimal)Math.Ceiling(f**k / FirstFee.Minutes)) * FirstFee.Fee;
                        calMins  += f**k;
                        beginning = beginning.AddMinutes(f**k);
                        continue;
                    }
                    else
                    {
                        double f**k = sliceAll;
                        fee      += (decimal)Math.Ceiling(f**k / RegularFee.Minutes) * RegularFee.Fee;
                        calMins  += sliceAll;
                        beginning = beginning.AddMinutes(sliceAll);
                    }
                }
                sliceAll = LimitationTimezone.Slice(beginning, ending, FirstFee.Minutes, false);
                if (sliceAll > 0)
                {
                    decimal tempFee = 0;
                    double  f**k    = sliceAll;
                    tempFee  += (decimal)(Math.Ceiling(f**k / LimitationRegularFee.Minutes)) * LimitationRegularFee.Fee;
                    fee      += Limitation > 0 && tempFee > Limitation ? Limitation : tempFee;
                    calMins  += sliceAll;
                    beginning = beginning.AddMinutes(sliceAll);
                }
            }
            if (FeeOf24Hour > 0 && FeeOf24Hour < fee)
            {
                fee = FeeOf24Hour;
            }

            if (FeeOfMax > 0 && fee > FeeOfMax)
            {
                fee = FeeOfMax;                                //有封顶费用
            }
            return(fee);
        }
Exemplo n.º 3
0
        public override decimal CalcalateIntradayFee(double calMins, DateTime beginning, DateTime ending)
        {
            decimal fee = 0;

            //把预定时间的费用收完
            double   sliceAll = 0;
            TimeZone other    = new TimeZone(LimitationTimezone.Ending, LimitationTimezone.Beginning); //如果有限价时段,那么其它的时间就组成另一个时段

            while (beginning < ending)
            {
                sliceAll = other.Slice(beginning, ending, FirstFee.Minutes, false);
                if (sliceAll > 0)
                {
                    if (sliceAll <= FirstMinutes) //如果还在入场时间内
                    {
                        fee += (decimal)Math.Ceiling(sliceAll / FirstFee.Minutes) * FirstFee.Fee;
                    }
                    else
                    {
                        fee += ((decimal)Math.Ceiling((decimal)FirstMinutes / FirstFee.Minutes)) * FirstFee.Fee;
                        //计算超过3小时部分阶段
                        double f**k = sliceAll - FirstMinutes;
                        fee += ((decimal)Math.Ceiling(f**k / RegularFee.Minutes)) * RegularFee.Fee;
                    }
                    calMins  += sliceAll;
                    beginning = beginning.AddMinutes(sliceAll);
                }
                sliceAll = LimitationTimezone.Slice(beginning, ending, FirstFee.Minutes, false);
                if (sliceAll > 0)
                {
                    decimal tempFee = 0;
                    tempFee  += (decimal)(Math.Ceiling(sliceAll / LimitationRegularFee.Minutes)) * LimitationRegularFee.Fee;
                    fee      += tempFee > Limitation ? Limitation : tempFee;
                    calMins  += sliceAll;
                    beginning = beginning.AddMinutes(sliceAll);
                }
            }
            if (FeeOf24Hour > 0 && FeeOf24Hour < fee)
            {
                fee = FeeOf24Hour;
            }

            return(fee);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 计算出入场时间范围内的限时时段小时数,精确到一位小数
        /// </summary>
        /// <param name="enterDt"></param>
        /// <param name="exitDt"></param>
        /// <returns></returns>
        public decimal CalculateLimitation(DateTime enterDt, DateTime exitDt)
        {
            decimal hour = 0;

            if (LimitationTimezone != null)
            {
                double   mins = 0;
                DateTime dt1  = enterDt;
                DateTime dt2  = dt1.Date.AddDays(1); //第二天0点0分
                while (dt2 <= exitDt)
                {
                    if (this.DisableInHoliday && HolidaySetting.Current != null && HolidaySetting.Current.IsHoliday(dt1)) //如果不计算节假日,则节假日当天就不用计算
                    {
                    }
                    else
                    {
                        mins += LimitationTimezone.Slice(dt1, dt2, 30, false);
                    }
                    dt1 = dt2;
                    dt2 = dt1.Date.AddDays(1);
                }
                if (dt1 < exitDt)                                                                                         //最后不足一天的部分
                {
                    if (this.DisableInHoliday && HolidaySetting.Current != null && HolidaySetting.Current.IsHoliday(dt1)) //如果不计算节假日,则节假日当天就不用计算
                    {
                    }
                    else
                    {
                        mins += LimitationTimezone.Slice(dt1, exitDt, 30, false);
                    }
                }
                if (mins > 0)
                {
                    hour = Math.Round((decimal)mins / 60, 1);
                }
            }
            return(hour);
        }
Exemplo n.º 5
0
        public override decimal CalcalateCycleFee(double calMins, DateTime beginning, DateTime ending)
        {
            decimal  fee          = 0;
            double   minmutes     = 0;
            double   firstMinutes = FirstMinutes;                                                          //入场预定时间内
            TimeZone other        = new TimeZone(LimitationTimezone.Ending, LimitationTimezone.Beginning); //如果有限价时段,那么其它的时间就组成另一个时段

            //先计算没有限价的时段
            minmutes     = other.TimeZoneTotalMinutes();
            firstMinutes = calMins > FirstMinutes ? 0 : FirstMinutes - calMins;                     //预定时间的费用是否已收取
            firstMinutes = minmutes > firstMinutes ? firstMinutes : minmutes;                       //还在入场预定时间的分钟数
            fee         += ((decimal)Math.Ceiling(firstMinutes / FirstFee.Minutes)) * FirstFee.Fee; //先计算入场预定时间的费用
            minmutes    -= firstMinutes;
            if (minmutes > 0)
            {
                fee += (decimal)Math.Ceiling(minmutes / RegularFee.Minutes) * RegularFee.Fee;//再计算入场预定时间后的费用
            }

            //再计算限价时段的
            minmutes = LimitationTimezone.TimeZoneTotalMinutes();
            decimal tempFee = 0;

            tempFee += (decimal)(Math.Ceiling(minmutes / LimitationRegularFee.Minutes)) * LimitationRegularFee.Fee;
            fee     += Limitation > 0 && tempFee > Limitation ? Limitation : tempFee;

            if (FeeOf24Hour > 0 && fee > FeeOf24Hour)
            {
                fee = FeeOf24Hour;
            }

            if (FeeOfMax > 0 && fee > FeeOfMax)
            {
                fee = FeeOfMax;                                //有封顶费用
            }
            return(fee);
        }
Exemplo n.º 6
0
        public override decimal CalculateFee(DateTime beginning, DateTime ending)
        {
            decimal  fee       = 0;
            decimal  daysfee   = 0;
            TimeSpan ts        = new TimeSpan(ending.Ticks - beginning.Ticks);
            double   totalMins = Math.Ceiling(ts.TotalMinutes);
            double   calMins   = 0; //已经计费的分钟数

            if (totalMins < 0)
            {
                return(0);                //入场时间大于出场时间
            }
            if (FreeMinutes > 0 && totalMins <= FreeMinutes)
            {
                return(0);                             //小于免费停车时间
            }
            if (ts.TotalDays >= 1 && FeeOf24Hour > 0)  //如果有每天最高收费,先计算出整天数的费用
            {
                double days = Math.Floor(ts.TotalDays);
                daysfee  += ((decimal)days) * FeeOf24Hour;
                calMins  += days * 1440;
                beginning = beginning.AddDays(days);
            }

            //把预定时间的费用收完
            double   sliceAll = 0;
            TimeZone other    = new TimeZone(LimitationTimezone.Ending, LimitationTimezone.Beginning); //如果有限价时段,那么其它的时间就组成另一个时段

            while (beginning < ending)
            {
                sliceAll = other.Slice(beginning, ending, FirstFee.Minutes, false);
                if (sliceAll > 0)
                {
                    if (sliceAll <= FirstMinutes) //如果还在入场时间内
                    {
                        fee += (decimal)Math.Ceiling(sliceAll / FirstFee.Minutes) * FirstFee.Fee;
                    }
                    else
                    {
                        fee += ((decimal)Math.Ceiling((double)FirstMinutes / FirstFee.Minutes)) * FirstFee.Fee;
                        //计算超过3小时部分阶段
                        double f**k = sliceAll - FirstMinutes;
                        fee += ((decimal)Math.Ceiling(f**k / RegularFee.Minutes)) * RegularFee.Fee;
                    }
                    calMins  += sliceAll;
                    beginning = beginning.AddMinutes(sliceAll);
                }
                sliceAll = LimitationTimezone.Slice(beginning, ending, FirstFee.Minutes, false);
                if (sliceAll > 0)
                {
                    decimal tempFee = 0;
                    tempFee  += (decimal)(Math.Ceiling(sliceAll / LimitationRegularFee.Minutes)) * LimitationRegularFee.Fee;
                    fee      += tempFee > Limitation ? Limitation : tempFee;
                    calMins  += sliceAll;
                    beginning = beginning.AddMinutes(sliceAll);
                }
            }
            if (FeeOf24Hour > 0 && FeeOf24Hour < fee)
            {
                fee = FeeOf24Hour;
            }
            return(fee + daysfee);
        }