コード例 #1
0
        public override void CalcParkingFees(ref struBillInfo struBillInfo, CTariffDto tariffTBL)
        {
            //struBillInfo.dtStartTime = struBillInfo.dtEndTime.AddMonths(-m_dMonths);
            struBillInfo.strCalculateDays = (struBillInfo.dtEndTime - DateTime.Now).Days.ToString();

            if (0 > struBillInfo.fPayableFee && struBillInfo.dtEndTime < DateTime.Now)
            {// 当前卡已存车且IC卡已过期,请补交费用
                int   nDays          = Math.Max(struBillInfo.dtEndTime.Subtract(struBillInfo.dtStartTime).Days, 1);
                float fDayFee        = struBillInfo.fTariffNorm / nDays;
                int   nCalculateDays = Math.Max(DateTime.Now.Subtract(struBillInfo.dtEndTime).Days, 0);
                struBillInfo.fPayableFee = nCalculateDays * fDayFee;
            }
        }
コード例 #2
0
 public void CalcParkingFees(ref struBillInfo struBillInfo, CTariffDto tariffTBL)
 {
     m_objStandard.CalcParkingFees(ref struBillInfo, tariffTBL);
 }
コード例 #3
0
        /// <summary>
        /// 单位向上取整方式-计算临时卡计时卡费用(0点为跨天节点)
        /// </summary>
        /// <param name="struBillInfo"></param>
        /// <param name="tariffTBL"></param>
        private void CalcTempFeeByUnit(ref struBillInfo struBillInfo, CTariffDto tariffTBL)
        {
            if (null == tariffTBL || null == struBillInfo.dtStartTime || null == struBillInfo.dtEndTime)
            {
                return;
            }

            float fPayableFee = 0;
            // 是否区分工作日
            bool bWorkday = true;
            // 工作日高峰起始时间、工作日高峰截止时间、非工作日高峰起始时间、非工作日高峰截止时间
            TimeSpan tsWorkPeakStart, tsWorkPeakEnd, tsNonworkPeakStart, tsNonworkPeakEnd;
            // 工作日限额、非工作日限额、一天费用
            float fWorkDayFee, fNonworkDayFee, fFee;

            // 工作日高峰首单位内单价、工作日高峰首单位外单价、工作日非高峰首单位内单价、工作日非高峰首单位外单价
            float fWorkPeakInFee, fWorkPeakOutFee, fWorkNonpeakInFee, fWorkNonpeakOutFee;
            // 工作日高峰首单位内单位、工作日高峰首单位外单位、工作日非高峰首单位内单位、工作日非高峰首单位外单位(以分钟为单元)
            int nWorkPeakInUnit, nWorkPeakOutUnit, nWorkNonpeakInUnit, nWorkNonpeakOutUnit;

            // 非工作日高峰首单位内单价、非工作日高峰首单位外单价、非工作日非高峰首单位内单价、非工作日非高峰首单位外单价
            float fNonworkPeakInFee, fNonworkPeakOutFee, fNonworkNonpeakInFee, fNonworkNonpeakOutFee;
            // 非工作日高峰首单位内单位、非工作日高峰首单位外单位、非工作日非高峰首单位内单位、非工作日非高峰首单位外单位(以分钟为单元)
            int      nNonworkPeakInUnit, nNonworkPeakOutUnit, nNonworkNonpeakInUnit, nNonworkNonpeakOutUnit;
            TimeSpan ts24End;// 24:00:00时间
            DateTime dsCurrent = struBillInfo.dtStartTime;
            DateTime dsEnd     = struBillInfo.dtEndTime;

            #region 解析CTariffDto属性值
            if (0 == tariffTBL.isworkday)
            {
                bWorkday = false;
            }
            CBaseMethods.MyBase.ConvertTimePeriod(tariffTBL.workpeakperiod, out tsWorkPeakStart, out tsWorkPeakEnd);
            CBaseMethods.MyBase.ConvertTimePeriod(tariffTBL.nonworkpeakperiod, out tsNonworkPeakStart, out tsNonworkPeakEnd);
            fWorkDayFee           = null == tariffTBL.workdayquotafee ? 0.0f : (float)tariffTBL.workdayquotafee;
            fNonworkDayFee        = null == tariffTBL.nonworkdayquotafee ? 0.0f : (float)tariffTBL.nonworkdayquotafee;
            fFee                  = null == tariffTBL.fee ? 0.0f : (float)tariffTBL.fee;
            fWorkPeakInFee        = CBaseMethods.MyBase.ConvertUnitToInt(tariffTBL.workpeakinunitfee, out nWorkPeakInUnit);
            fWorkPeakOutFee       = CBaseMethods.MyBase.ConvertUnitToInt(tariffTBL.workpeakoutunitfee, out nWorkPeakOutUnit);
            fWorkNonpeakInFee     = CBaseMethods.MyBase.ConvertUnitToInt(tariffTBL.worknonpeakinunitfee, out nWorkNonpeakInUnit);
            fWorkNonpeakOutFee    = CBaseMethods.MyBase.ConvertUnitToInt(tariffTBL.worknonpeakoutunitfee, out nWorkNonpeakOutUnit);
            fNonworkPeakInFee     = CBaseMethods.MyBase.ConvertUnitToInt(tariffTBL.nonworkpeakinunitfee, out nNonworkPeakInUnit);
            fNonworkPeakOutFee    = CBaseMethods.MyBase.ConvertUnitToInt(tariffTBL.nonworkpeakoutunitfee, out nNonworkPeakOutUnit);
            fNonworkNonpeakInFee  = CBaseMethods.MyBase.ConvertUnitToInt(tariffTBL.nonworknonpeakinunitfee, out nNonworkNonpeakInUnit);
            fNonworkNonpeakOutFee = CBaseMethods.MyBase.ConvertUnitToInt(tariffTBL.nonworknonpeakoutunitfee, out nNonworkNonpeakOutUnit);
            TimeSpan.TryParse("24:00:00", out ts24End);
            #endregion

            #region 首单位内计算
            if (bWorkday && IsNonworkdays(dsCurrent))
            {// 区分工作日,判断当前日期是否为非工作日
                string strNonworkFirstUnit = tariffTBL.nonworkpeakfirstunit;
                if (0 > dsCurrent.TimeOfDay.CompareTo(tsNonworkPeakStart) || 0 < dsCurrent.TimeOfDay.CompareTo(tsNonworkPeakEnd))
                {// 起始时间在非工作日非高峰时段内
                    strNonworkFirstUnit = tariffTBL.nonworknonpeakfirstunit;
                }

                if (!CBaseMethods.MyBase.IsEmpty(strNonworkFirstUnit))
                {// 区分首单位(以分钟为单元)
                    int nNonworkFirstUnit;
                    CBaseMethods.MyBase.ConvertUnitToInt(strNonworkFirstUnit, out nNonworkFirstUnit);
                    dsCurrent = dsCurrent.AddMinutes(nNonworkFirstUnit);

                    if (struBillInfo.dtStartTime.Date == dsCurrent.Date)
                    {
                        fPayableFee += CalculateOneDayFee(struBillInfo.dtStartTime.TimeOfDay, dsCurrent.TimeOfDay, tsNonworkPeakStart, tsNonworkPeakEnd, nNonworkPeakInUnit, nNonworkNonpeakInUnit, fNonworkPeakInFee, fNonworkNonpeakInFee);
                    }
                    else
                    {// 跨天情况
                        fPayableFee += CalculateOneDayFee(struBillInfo.dtStartTime.TimeOfDay, ts24End, tsNonworkPeakStart, tsNonworkPeakEnd, nNonworkPeakInUnit, nNonworkNonpeakInUnit, fNonworkPeakInFee, fNonworkNonpeakInFee);
                        fPayableFee += CalculateOneDayFee(new TimeSpan(0, 0, 0), dsCurrent.TimeOfDay, tsNonworkPeakStart, tsNonworkPeakEnd, nNonworkPeakInUnit, nNonworkNonpeakInUnit, fNonworkPeakInFee, fNonworkNonpeakInFee);
                    }
                }
            }
            else
            {// 工作日
                string strWorkFirstUnit = tariffTBL.workpeakfirstunit;
                if (0 > dsCurrent.TimeOfDay.CompareTo(tsWorkPeakStart) || 0 < dsCurrent.TimeOfDay.CompareTo(tsWorkPeakEnd))
                {// 起始时间在工作日非高峰时段内
                    strWorkFirstUnit = tariffTBL.worknonpeakfirstunit;
                }

                if (!CBaseMethods.MyBase.IsEmpty(strWorkFirstUnit))
                {// 区分首单位
                    int nWorkFirstUnit;
                    CBaseMethods.MyBase.ConvertUnitToInt(strWorkFirstUnit, out nWorkFirstUnit);
                    dsCurrent = dsCurrent.AddMinutes(nWorkFirstUnit);

                    if (struBillInfo.dtStartTime.Date == dsCurrent.Date)
                    {
                        fPayableFee += CalculateOneDayFee(struBillInfo.dtStartTime.TimeOfDay, dsCurrent.TimeOfDay, tsWorkPeakStart, tsWorkPeakEnd, nWorkPeakInUnit, nWorkNonpeakInUnit, fWorkPeakInFee, fWorkNonpeakInFee);
                    }
                    else
                    {// 跨天情况
                        fPayableFee += CalculateOneDayFee(struBillInfo.dtStartTime.TimeOfDay, ts24End, tsWorkPeakStart, tsWorkPeakEnd, nWorkPeakInUnit, nWorkNonpeakInUnit, fWorkPeakInFee, fWorkNonpeakInFee);
                        fPayableFee += CalculateOneDayFee(new TimeSpan(0, 0, 0), dsCurrent.TimeOfDay, tsWorkPeakStart, tsWorkPeakEnd, nWorkPeakInUnit, nWorkNonpeakInUnit, fWorkPeakInFee, fWorkNonpeakInFee);
                    }
                }
            }
            #endregion

            #region 首单位外计算
            while (dsCurrent < dsEnd)
            {
                TimeSpan tsPeakStart, tsPeakEnd;
                int      nPeakUnit, nNonpeakUnit;
                float    fPeakFee, fNonpeakFee, fDayFee, fCalulateFee;

                if (bWorkday && IsNonworkdays(dsCurrent))
                {// 区分工作日,判断当前日期是否为非工作日
                    tsPeakStart  = tsNonworkPeakStart;
                    tsPeakEnd    = tsNonworkPeakEnd;
                    nPeakUnit    = nNonworkPeakOutUnit;
                    nNonpeakUnit = nNonworkNonpeakOutUnit;
                    fPeakFee     = fNonworkPeakOutFee;
                    fNonpeakFee  = fNonworkNonpeakOutFee;
                    float dPeakMinutes = (float)(tsPeakEnd.Subtract(tsPeakStart)).TotalMinutes;
                    fDayFee = dPeakMinutes / nPeakUnit * fPeakFee + (1440 - dPeakMinutes) / nNonpeakUnit * fNonpeakFee;
                    // 无限额时,按照一天费用计算
                    fDayFee = fNonworkDayFee < 0.1 ? fDayFee : fNonworkDayFee;
                }
                else
                {// 工作日
                    tsPeakStart  = tsWorkPeakStart;
                    tsPeakEnd    = tsWorkPeakEnd;
                    nPeakUnit    = nWorkPeakOutUnit;
                    nNonpeakUnit = nWorkNonpeakOutUnit;
                    fPeakFee     = fWorkPeakOutFee;
                    fNonpeakFee  = fWorkNonpeakOutFee;
                    // 无限额时,按照一天费用计算
                    fDayFee = fWorkDayFee < 0.1 ? fFee : fWorkDayFee;
                }

                if (dsCurrent.Date == dsEnd.Date && 0 > dsCurrent.TimeOfDay.CompareTo(dsEnd.TimeOfDay))
                {// 一天内情况
                    fCalulateFee = CalculateOneDayFee(dsCurrent.TimeOfDay, dsEnd.TimeOfDay, tsPeakStart, tsPeakEnd, nPeakUnit, nNonpeakUnit, fPeakFee, fNonpeakFee);
                    fCalulateFee = fCalulateFee < fDayFee ? fCalulateFee : fDayFee;
                    fPayableFee += fCalulateFee;
                    break;
                }
                else if (dsCurrent.Date < dsEnd.Date)
                {     // 跨天情况
                    if (0 == dsCurrent.TimeOfDay.TotalSeconds)
                    { // 一整天时间
                        fPayableFee += fDayFee;
                    }
                    else
                    {// 计算当天
                        fCalulateFee = CalculateOneDayFee(dsCurrent.TimeOfDay, ts24End, tsPeakStart, tsPeakEnd, nPeakUnit, nNonpeakUnit, fPeakFee, fNonpeakFee);
                        fCalulateFee = fCalulateFee < fDayFee ? fCalulateFee : fDayFee;
                        fPayableFee += fCalulateFee;
                    }
                    // 累积天数向截止日期靠拢
                    dsCurrent = dsCurrent.AddDays(1).Date;
                }
                else
                {
                    break;
                }
            }
            #endregion

            struBillInfo.fPayableFee = fPayableFee;
            TimeSpan ts    = struBillInfo.dtEndTime - struBillInfo.dtStartTime;
            int      hours = ts.Hours + (ts.Minutes > 0 ? 1 : 0);// 停车总时间
            struBillInfo.strCalculateDays = ts.Days + "天" + hours + "小时";
        }
コード例 #4
0
 public abstract void CalcParkingFees(ref struBillInfo struBillInfo, CTariffDto tariffTBL);
コード例 #5
0
 public override void CalcParkingFees(ref struBillInfo struBillInfo, CTariffDto tariffTBL)
 {
     CalcTempFeeEnterTimeByUnit(ref struBillInfo, tariffTBL);
 }