Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }