Ejemplo n.º 1
0
        public static ParkFeeRule QueryParkFeeRuleByFeeRuleId(string feeRuleId)
        {
            if (string.IsNullOrWhiteSpace(feeRuleId))
            {
                throw new ArgumentNullException("feeRuleId");
            }

            IParkFeeRule factory = ParkFeeRuleFactory.GetFactory();

            return(factory.QueryParkFeeRuleByFeeRuleId(feeRuleId));
        }
Ejemplo n.º 2
0
        public static decimal TestCalculateFee(DateTime startTime, DateTime endTime, string feeRuleId)
        {
            IParkFeeRule factory = ParkFeeRuleFactory.GetFactory();
            ParkFeeRule  rule    = factory.QueryParkFeeRuleByFeeRuleId(feeRuleId);

            if (rule == null)
            {
                throw new MyException("获取规则失败");
            }

            switch (rule.FeeType)
            {
            case FeeType.DayAndNight: {
                IFeeRule IFee = new DayNight();
                IFee.ParkingBeginTime = startTime;
                IFee.ParkingEndTime   = endTime;
                IFee.FeeRule          = rule;
                IFee.listRuleDetail   = rule.ParkFeeRuleDetails;
                return(IFee.CalcFee());
            }

            case FeeType.Hour12:
            {
                IFeeRule IFee = new Hours12();
                IFee.ParkingBeginTime = startTime;
                IFee.ParkingEndTime   = endTime;
                IFee.FeeRule          = rule;
                IFee.listRuleDetail   = rule.ParkFeeRuleDetails;
                return(IFee.CalcFee());
            }

            case FeeType.Hour24:
            {
                IFeeRule IFee = new Hours24();
                IFee.ParkingBeginTime = startTime;
                IFee.ParkingEndTime   = endTime;
                IFee.FeeRule          = rule;
                IFee.listRuleDetail   = rule.ParkFeeRuleDetails;
                return(IFee.CalcFee());
            }

            case FeeType.NaturalDay:
            {
                IFeeRule IFee = new NaturalDay();
                IFee.ParkingBeginTime = startTime;
                IFee.ParkingEndTime   = endTime;
                IFee.FeeRule          = rule;
                IFee.listRuleDetail   = rule.ParkFeeRuleDetails;
                return(IFee.CalcFee());
            }

            case FeeType.Custom:
            {
                IFeeRule IFee = new Userdefined2();
                IFee.ParkingBeginTime = startTime;
                IFee.ParkingEndTime   = endTime;
                IFee.FeeRule          = rule;
                IFee.FeeText          = rule.RuleText;
                return(IFee.CalcFee());
            }

            default: throw new MyException("算费规则不存在");
            }
        }