Example #1
0
        /// <summary>
        /// 获取卡片开始时间当天的计算停车费用的收费费率
        /// </summary>
        /// <param name="cardType">卡片类型</param>
        /// <param name="carType">车型</param>
        /// <param name="parkingStatus">停车状态</param>
        /// <param name="beginning">开始时间</param>
        /// <returns></returns>
        private TariffBase GetCalculateTariff(Byte?cardType, Byte carType, ParkingStatus parkingStatus, DateTime beginning)
        {
            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);
        }
Example #2
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);
        }
Example #3
0
        ///// <summary>
        ///// 计算一个计费周期的停车费用
        ///// </summary>
        ///// <param name="minutes">已计费的分钟数</param>
        ///// <param name="beginning">计费周期的开始时间</param>
        ///// <param name="ending">计费周期的结束时间</param>
        ///// <returns></returns>
        //public virtual decimal CalcalateCycleFee(double calMins, DateTime beginning, DateTime ending)
        //{
        //    throw new NotImplementedException("子类没有重写基类的CalcalateCycleFee方法");
        //}

        ///// <summary>
        ///// 计算一天内的停车费用
        ///// </summary>
        ///// <param name="calMins">已计费的分钟数</param>
        ///// <param name="beginning">开始时间</param>
        ///// <param name="ending">结束时间</param>
        ///// <returns></returns>
        //public virtual decimal CalcalateIntradayFee(double calMins, DateTime beginning, DateTime ending)
        //{
        //    throw new NotImplementedException("子类没有重写基类的CalcalateIntradayFee方法");
        //}

        ///// <summary>
        ///// 计算一个收费单元的费用
        ///// </summary>
        ///// <param name="beginning">开始时间</param>
        ///// <returns></returns>
        //public virtual decimal GetChargeUnitFee(DateTime beginning)
        //{
        //    throw new NotImplementedException("子类没有重写基类的GetChargeUnitFee方法");
        //}
        #endregion

        #region 重写基类方法
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is TariffBase))
            {
                return(false);
            }
            if (object.ReferenceEquals(this, obj))
            {
                return(true);
            }
            else
            {
                TariffBase tb = obj as TariffBase;
                return(this.CalculateFee(new DateTime(2011, 1, 1), new DateTime(2011, 1, 2)) == tb.CalculateFee(new DateTime(2011, 1, 1), new DateTime(2011, 1, 2)));
            }
        }
Example #4
0
        /// <summary>
        /// 获取某卡片某车型beginning时间的当天费率
        /// </summary>
        /// <param name="card"></param>
        /// <param name="carType"></param>
        /// <param name="beginning"></param>
        /// <returns></returns>
        public TariffBase GetIntradayTariff(CardInfo card, Byte carType, DateTime beginning)
        {
            TariffBase tariff = null;

            //if (GlobalVariables.IsNETParkAndOffLie)
            //{
            //    //网络型写卡模式获取费用
            //    tariff = TariffSetting.Current.GetCalculateTariff(card.CardType.ID, carType, card.ParkingStatus, beginning);
            //}
            //else
            //{
            //    //其他模式获取费率
            //    if (card.CardType.IsPrimaryCardType && (card.CardType.IsTempCard || card.CardType.IsPrepayCard))
            //    {
            //        tariff = TariffSetting.Current.GetCalculateTariff(null, carType, card.ParkingStatus, beginning);
            //    }
            //    else
            //    {
            //        tariff = card.CardType.GetTariff();
            //    }
            //}
            tariff = TariffSetting.Current.GetCalculateTariff(card.CardType.ID, carType, card.ParkingStatus, beginning);
            return(tariff);
        }
Example #5
0
        private Ralid.Park.Hardware.H_TariffInfo ConvertTariffInfo(short freeTimeAfterPay, Ralid.Park.BusinessModel.Model.TariffBase tariff)
        {
            H_TariffInfo h_Tariff = new H_TariffInfo();

            h_Tariff.TariffType = ConvertTariffType(tariff.TariffType);
            h_Tariff.CardType   = ConvertTariffCardType(tariff.CardType);
            h_Tariff.CarType    = ConvertTariffCarType(tariff.CarType, tariff.TariffType);
            h_Tariff.T2         = freeTimeAfterPay;

            if (tariff is TariffPerTime)//按次收费
            {
                TariffPerTime t = tariff as TariffPerTime;
                h_Tariff.ChargeType     = H_Tariff_ChargeType.Mode1;
                h_Tariff.ChargeProperty = H_Tariff_ChargeProperty.OverTimeInvalid
                                          | H_Tariff_ChargeProperty.DailyLimitInvalid
                                          | H_Tariff_ChargeProperty.IntervalTop1Invalid
                                          | H_Tariff_ChargeProperty.IntervalTop2Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval1Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval2Invalid
                                          | H_Tariff_ChargeProperty.MaximumAmountInvalid;
                h_Tariff.T1    = t.FreeMinutes;
                h_Tariff.M1[0] = (int)(t.FeePerTime * 100);
            }

            if (tariff is TariffPerDay)//按天收费
            {
                TariffPerDay t = tariff as TariffPerDay;
                h_Tariff.ChargeType     = H_Tariff_ChargeType.Mode2;
                h_Tariff.ChargeProperty = H_Tariff_ChargeProperty.DailyLimitInvalid
                                          | H_Tariff_ChargeProperty.IntervalTop1Invalid
                                          | H_Tariff_ChargeProperty.IntervalTop2Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval1Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval2Invalid;
                h_Tariff.T1    = t.FreeMinutes;
                h_Tariff.M1[0] = (int)(t.FeePerDay * 100);

                if (t.OverDay > 0)
                {
                    h_Tariff.T3 = t.OverDay;
                    h_Tariff.M2 = (int)(t.FeePerOverDay * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.OverTimeInvalid;
                }

                if (t.FeeOfMax > 0)
                {
                    h_Tariff.M7 = (int)(t.FeeOfMax * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.MaximumAmountInvalid;
                }
            }

            if (tariff is TariffOfTurning)//过点收费
            {
                TariffOfTurning t = tariff as TariffOfTurning;
                h_Tariff.ChargeType     = H_Tariff_ChargeType.Mode1;
                h_Tariff.ChargeProperty = H_Tariff_ChargeProperty.DailyLimitInvalid
                                          | H_Tariff_ChargeProperty.IntervalTop1Invalid
                                          | H_Tariff_ChargeProperty.IntervalTop2Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval1Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval2Invalid;
                h_Tariff.T1    = t.FreeMinutes;
                h_Tariff.M1[0] = (int)(t.FirstFee * 100);
                h_Tariff.T3    = (short)(Ralid.GeneralLibrary.BCDConverter.IntToBCD(t.Turning.Hour) * 0x100 + Ralid.GeneralLibrary.BCDConverter.IntToBCD(t.Turning.Minute));
                h_Tariff.M2    = (int)(t.FeeOfTurning * 100);

                if (t.FeeOfMax > 0)
                {
                    h_Tariff.M7 = (int)(t.FeeOfMax * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.MaximumAmountInvalid;
                }
            }

            if (tariff is TariffOfLimitation)//限额收费
            {
                TariffOfLimitation t = tariff as TariffOfLimitation;
                h_Tariff.ChargeType     = H_Tariff_ChargeType.Mode4;
                h_Tariff.ChargeProperty = H_Tariff_ChargeProperty.OverTimeInvalid
                                          | H_Tariff_ChargeProperty.IntervalTop2Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval1Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval2Invalid;
                h_Tariff.T1 = t.FreeMinutes;
                if (t.FirstCharge != null)
                {
                    h_Tariff.T4    = t.FirstCharge.Minutes;
                    h_Tariff.T5[0] = t.FirstCharge.Minutes;
                    h_Tariff.M1[0] = (int)(t.FirstCharge.Fee * 100);
                }
                h_Tariff.T6[0] = t.RegularCharge.Minutes;
                h_Tariff.M3[0] = (int)(t.RegularCharge.Fee * 100);
                if (t.FeeOf12Hour > 0)
                {
                    h_Tariff.T7 = 12 * 60;//12小时限额
                    h_Tariff.M5 = (int)(t.FeeOf12Hour * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.IntervalTop1Invalid;
                }
                if (t.FeeOf24Hour > 0)
                {
                    h_Tariff.M6 = (int)(t.FeeOf24Hour * 100);//24小时限额
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.DailyLimitInvalid;
                }
                if (t.FeeOfMax > 0)//封顶收费,最高收费
                {
                    h_Tariff.M7 = (int)(t.FeeOfMax * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.MaximumAmountInvalid;
                }
            }

            if (tariff is TariffOfGuanZhou)//日夜差异收费
            {
                TariffOfGuanZhou t = tariff as TariffOfGuanZhou;
                h_Tariff.ChargeType     = H_Tariff_ChargeType.Mode3;
                h_Tariff.ChargeProperty = H_Tariff_ChargeProperty.OverTimeInvalid;
                h_Tariff.T1             = t.FreeMinutes;
                h_Tariff.M6             = (int)(t.FeeOf24Hour * 100);//24小时限额

                //白天时段
                h_Tariff.TimeInterval[0]           = new H_TimeInterval();
                h_Tariff.TimeInterval[0].BeginTime = new H_TimeEntity(t.DayTimezone.Beginning.Hour, t.DayTimezone.Beginning.Minute);
                h_Tariff.TimeInterval[0].EndTime   = new H_TimeEntity(t.DayTimezone.Ending.Hour, t.DayTimezone.Ending.Minute);
                h_Tariff.T6[0] = t.DayTimezone.RegularCharge.Minutes;
                h_Tariff.M3[0] = (int)(t.DayTimezone.RegularCharge.Fee * 100);
                if (t.DayTimezone.LimiteFee.HasValue && t.DayTimezone.LimiteFee.Value > 0)//白天时段有最高限额
                {
                    h_Tariff.M4[0] = (int)(t.DayTimezone.LimiteFee.Value * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.IntervalTop1Invalid;
                }

                //夜间时段
                h_Tariff.TimeInterval[1]           = new H_TimeInterval();
                h_Tariff.TimeInterval[1].BeginTime = new H_TimeEntity(t.NightTimezone.Beginning.Hour, t.NightTimezone.Beginning.Minute);
                h_Tariff.TimeInterval[1].EndTime   = new H_TimeEntity(t.NightTimezone.Ending.Hour, t.NightTimezone.Ending.Minute);
                h_Tariff.T6[1] = t.NightTimezone.RegularCharge.Minutes;
                h_Tariff.M3[1] = (int)(t.NightTimezone.RegularCharge.Fee * 100);
                if (t.NightTimezone.LimiteFee.HasValue && t.NightTimezone.LimiteFee.Value > 0)//夜间有最高限额
                {
                    h_Tariff.M4[1] = (int)(t.NightTimezone.LimiteFee.Value * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.IntervalTop2Invalid;
                }

                if (t.FeeOf24Hour > 0)
                {
                    h_Tariff.M6 = (int)(t.FeeOf24Hour * 100);//24小时限额
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.DailyLimitInvalid;
                }

                if (t.FeeOfMax > 0)//封顶收费,最高收费
                {
                    h_Tariff.M7 = (int)(t.FeeOfMax * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.MaximumAmountInvalid;
                }
            }

            if (tariff is TariffOfDixiakongjian)//时段限额收费
            {
                TariffOfDixiakongjian t = tariff as TariffOfDixiakongjian;
                h_Tariff.ChargeType     = H_Tariff_ChargeType.Mode3;
                h_Tariff.ChargeProperty = H_Tariff_ChargeProperty.OverTimeInvalid
                                          | H_Tariff_ChargeProperty.IntervalTop1Invalid;
                h_Tariff.T1 = t.FreeMinutes;
                h_Tariff.M6 = (int)(t.FeeOf24Hour * 100);//24小时限额

                //正常时段
                h_Tariff.TimeInterval[0]           = new H_TimeInterval();
                h_Tariff.TimeInterval[0].BeginTime = new H_TimeEntity(t.LimitationTimezone.Ending.Hour, t.LimitationTimezone.Ending.Minute);       //以限价时段结束时间为开始时间
                h_Tariff.TimeInterval[0].EndTime   = new H_TimeEntity(t.LimitationTimezone.Beginning.Hour, t.LimitationTimezone.Beginning.Minute); //以限价时段开始时间为结束时间
                h_Tariff.T4    = (short)t.FirstMinutes;
                h_Tariff.T5[0] = t.FirstFee.Minutes;
                h_Tariff.M1[0] = (int)(t.FirstFee.Fee * 100);
                h_Tariff.T6[0] = t.RegularFee.Minutes;
                h_Tariff.M3[0] = (int)(t.RegularFee.Fee * 100);

                //限价时段
                h_Tariff.TimeInterval[1]           = new H_TimeInterval();
                h_Tariff.TimeInterval[1].BeginTime = new H_TimeEntity(t.LimitationTimezone.Beginning.Hour, t.LimitationTimezone.Beginning.Minute);
                h_Tariff.TimeInterval[1].EndTime   = new H_TimeEntity(t.LimitationTimezone.Ending.Hour, t.LimitationTimezone.Ending.Minute);
                h_Tariff.T6[1] = t.LimitationRegularFee.Minutes;
                h_Tariff.M3[1] = (int)(t.LimitationRegularFee.Fee * 100);
                h_Tariff.M4[1] = (int)(t.Limitation * 100);

                if (t.FeeOf24Hour > 0)
                {
                    h_Tariff.M6 = (int)(t.FeeOf24Hour * 100);//24小时限额
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.DailyLimitInvalid;
                }
                if (t.FeeOfMax > 0)//封顶收费,最高收费
                {
                    h_Tariff.M7 = (int)(t.FeeOfMax * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.MaximumAmountInvalid;
                }
            }

            return(h_Tariff);
        }
Example #6
0
        /// <summary>
        /// 计算停车费用
        /// </summary>
        /// <param name="enter">入场时间</param>
        /// <param name="exit">出场时间</param>
        /// <returns></returns>
        public virtual decimal CalculateFee(DateTime beginning, DateTime ending)
        {
            //throw new NotImplementedException("子类没有重写基类的CalculateFee方法");
            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);
            }

            fee = fee + daysfee;


            if (FeeOfMax > 0 && fee > FeeOfMax)
            {
                fee = FeeOfMax;                                //有封顶费用
            }
            return(fee);
        }
Example #7
0
        /// <summary>
        /// 计算卡片的优惠金额
        /// </summary>
        /// <param name="parkID">停车场ID</param>
        /// <param name="card">卡片实体类</param>
        /// <param name="carType">卡片类型</param>
        /// <param name="chargeDateTime">计费时间</param>
        /// <param name="usedHour">已使用优惠时数</param>
        /// <param name="currentHour">输出:当前使用的优惠时数</param>
        /// <returns></returns>
        public decimal CalculateCardDiscountMoney(int?parkID, CardInfo card, Byte carType, DateTime chargeDateTime, int usedHour, out int currentHour)
        {
            currentHour = 0;
            int discountHour = card.DiscountHour - usedHour;

            if (discountHour <= 0)
            {
                return(0);
            }
            //优惠时数有效期为24小时
            if (card.PreferentialTime != null && chargeDateTime.AddHours(-24) > card.PreferentialTime.Value)
            {
                return(0);
            }

            decimal discountMoney = 0;

            #region 以卡片的入场时间、出场时间获取费率费率
            //以卡片的入场时间计算
            DateTime beginning = GetMyDateTime(card.LastDateTime);
            //如果启用了酒店应用
            if (card.EnableHotelApp)
            {
                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);
            TariffBase tariff    = null;
            //由于优惠算法是太古汇使用的,太古汇现场没有节假日不同费率收费的情况,所以这里不考虑工作日与节假日交替计算优惠的情况
            tariff = GetCalculateTariff(parkID, card.CardType.ID, carType, card.ParkingStatus, beginning);

            //DateTime begin = beginning;
            //DateTime end = beginning;
            //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;
            //            tariff = tb;
            //            begin = end <= ending ? end : ending;
            //            end = begin;
            //            break;
            //        }
            //    }
            //    if (end.Date == ending.Date) break;
            //}
            #endregion

            if (tariff != null)
            {
                if (tariff is TariffOfGuanZhou)//日夜差异收费
                {
                    TariffOfGuanZhou gzTariff = tariff as TariffOfGuanZhou;
                    discountMoney = gzTariff.CalculateDiscountFee(beginning, ending, discountHour, out currentHour);
                }
            }
            return(discountMoney);
        }
Example #8
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);
        }
Example #9
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);
        }