Ejemplo n.º 1
0
        public JsonResult CalculateNewEndDate(DateTime?beginDate, DateTime?endDate, int month)
        {
            DateTime   start = beginDate.HasValue ? (beginDate.Value == DateTime.MaxValue ? DateTime.Now : beginDate.Value) : DateTime.Now;
            JsonResult json  = new JsonResult();

            json.Data = BaseCardServices.CalculateNewEndDate(start, endDate, month).ToString("yyyy-MM-dd");
            return(json);
        }
Ejemplo n.º 2
0
        private string CalculateNewEndDate(DateTime?beginDate, DateTime?endDate, int month)
        {
            TxtLogServices.WriteTxtLog(Convert.ToString(beginDate));
            TxtLogServices.WriteTxtLog(Convert.ToString(endDate));
            //TxtLogServices.WriteTxtLog(beginDate);
            DateTime start = beginDate.HasValue ? (beginDate.Value == DateTime.MaxValue ? DateTime.Now : beginDate.Value) : DateTime.Now;

            TxtLogServices.WriteTxtLog(Convert.ToString(beginDate));
            TxtLogServices.WriteTxtLog(Convert.ToString(endDate));
            return(BaseCardServices.CalculateNewEndDate(start, endDate, month).ToString("yyyy-MM-dd"));
        }
Ejemplo n.º 3
0
        public static bool Add(BaseEmployee employee, EmployeePlate plate, BaseCard card, ParkGrant parkGrant, DbOperator dbOperator)
        {
            if (employee == null)
            {
                throw new ArgumentNullException("employee");
            }
            if (plate == null)
            {
                throw new ArgumentNullException("plate");
            }
            if (card == null)
            {
                throw new ArgumentNullException("card");
            }
            if (parkGrant == null)
            {
                throw new ArgumentNullException("parkGrant");
            }

            bool result = BaseEmployeeServices.AddOrUpdateBaseEmployee(employee, dbOperator);

            if (!result)
            {
                throw new MyException("保存人员信息失败");
            }

            result = BaseCardServices.AddOrUpdateCard(card, dbOperator);
            if (!result)
            {
                throw new MyException("保存卡信息失败");
            }

            result = EmployeePlateServices.AddOrUpdateEmployeePlate(plate, dbOperator);
            if (!result)
            {
                throw new MyException("保存车牌信息失败");
            }

            parkGrant.PlateID = plate.PlateID;
            parkGrant.CardID  = card.CardID;
            result            = AddOrderUpdateParkGrant(parkGrant, dbOperator);
            if (!result)
            {
                throw new MyException("保存授权失败");
            }
            if (result)
            {
                OperateLogServices.AddOperateLog <BaseEmployee>(employee, OperateType.Add);
                OperateLogServices.AddOperateLog <EmployeePlate>(plate, OperateType.Add);
                OperateLogServices.AddOperateLog <BaseCard>(card, OperateType.Add);
                OperateLogServices.AddOperateLog <ParkGrant>(parkGrant, OperateType.Add);
            }
            return(result);
        }
Ejemplo n.º 4
0
        private void CheckMonthCardOrder(ParkUserCarInfo card, int month, double paymoney, PaymentChannel paytype, DateTime afterdate)
        {
            TxtLogServices.WriteTxtLog("31");
            if (card == null)
            {
                throw new MyException("获月卡信息失败");
            }

            if (!card.IsAllowOnlIne)
            {
                throw new MyException("该车场不支持手机续期");
            }

            if (month < 1)
            {
                throw new MyException("请选择续期月数");
            }

            if (card.MaxMonth != 0 && card.MaxMonth < month)
            {
                throw new MyException(string.Format("续期月数必须小于等于{0}个月", card.MaxMonth));
            }
            if (card.Amount * month != (decimal)paymoney)
            {
                throw new MyException("支付金额不正确");
            }

            TxtLogServices.WriteTxtLog("32");
            DateTime start = DateTime.Now;

            if (card.BeginDate != DateTime.MinValue)
            {
                start = card.BeginDate;
            }

            TxtLogServices.WriteTxtLog("M:" + Convert.ToString(month));
            TxtLogServices.WriteTxtLog(Convert.ToString(start));
            TxtLogServices.WriteTxtLog(Convert.ToString(card.EndDate));

            DateTime dtCal = BaseCardServices.CalculateNewEndDate(start, card.EndDate, month);

            TxtLogServices.WriteTxtLog(Convert.ToString(dtCal));
            TxtLogServices.WriteTxtLog(Convert.ToString(afterdate));

            if (BaseCardServices.CalculateNewEndDate(start, card.EndDate, month) != afterdate.Date)
            {
                throw new MyException("计算月卡结束时间错误");
            }
            TxtLogServices.WriteTxtLog("34");
        }
Ejemplo n.º 5
0
        public static bool DAAdd(List <DAAddMonth> listmonth)
        {
            if (listmonth.Count == 0)
            {
                throw new ArgumentNullException("employee");
            }
            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                dbOperator.BeginTransaction();
                try
                {
                    foreach (var obj in listmonth)
                    {
                        bool result = BaseEmployeeServices.AddOrUpdateBaseEmployee(obj.employye, dbOperator);
                        if (!result)
                        {
                            throw new MyException("保存人员信息失败");
                        }

                        result = BaseCardServices.AddOrUpdateCard(obj.card, dbOperator);
                        if (!result)
                        {
                            throw new MyException("保存卡信息失败");
                        }

                        result = EmployeePlateServices.AddOrUpdateEmployeePlate(obj.plate, dbOperator);
                        if (!result)
                        {
                            throw new MyException("保存车牌信息失败");
                        }

                        obj.grant.PlateID = obj.plate.PlateID;
                        obj.grant.CardID  = obj.card.CardID;
                        result            = AddOrderUpdateParkGrant(obj.grant, dbOperator);
                        if (!result)
                        {
                            throw new MyException("保存授权失败");
                        }
                        dbOperator.CommitTransaction();
                    }

                    return(true);
                }
                catch
                {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
        }
Ejemplo n.º 6
0
        public static BaseCard GenerateCardModel(string VID, string PKID, BaseEmployee employee, EmployeePlate plate, string loginUserRecordId)
        {
            BaseCard model = new BaseCard();

            model.CardID   = GuidGenerator.GetGuidString();
            model.CardNo   = plate.PlateNo;
            model.CardNumb = model.CardNo;
            model.VID      = VID;

            BaseCard oldCard = BaseCardServices.QueryBaseCardByParkingId(PKID, model.CardNo);

            if (oldCard != null)
            {
                model.CardID = oldCard.CardID;
                if (oldCard != null && oldCard.CardID != model.CardID)
                {
                    throw new MyException("车牌号已存在,不能重复添加");
                }

                string errorMsg = string.Empty;
                model = BaseCardServices.GetBaseCard(model.CardID, out errorMsg);
                if (model == null || !string.IsNullOrWhiteSpace(errorMsg))
                {
                    throw new MyException("获取卡信息失败");
                }

                model.CardNo   = plate.PlateNo;
                model.CardNumb = model.CardNo;
                model.VID      = VID;
            }
            else
            {
                if (oldCard != null)
                {
                    throw new MyException("车牌号已存在,不能重复添加");
                }
                model.RegisterTime = DateTime.Now;
            }

            model.OperatorID = loginUserRecordId;
            model.CardSystem = CardSystem.Park;
            model.EmployeeID = employee.EmployeeID;
            model.CardType   = CardType.Plate;
            return(model);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 续期或续费
        /// </summary>
        /// <param name="grantId"></param>
        /// <param name="renewalMonth"></param>
        /// <param name="payTotalMoney"></param>
        /// <param name="operatorId"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public static bool RenewalsOrRecharge(string grantId, int renewalMonth, decimal payTotalMoney, string operatorId, DateTime startDate, DateTime endDate)
        {
            lock (parkGrant_lock)
            {
                ParkGrant grant = ParkGrantServices.QueryByGrantId(grantId);
                if (grant == null)
                {
                    throw new MyException("获取授权信息失败");
                }

                if (endDate != null && endDate != DateTime.MinValue)
                {
                    endDate = endDate.Date.AddDays(1).AddSeconds(-1);
                }
                string   errorMsg = string.Empty;
                BaseCard card     = BaseCardServices.GetBaseCard(grant.CardID, out errorMsg);
                if (card == null || !string.IsNullOrWhiteSpace(errorMsg))
                {
                    throw new MyException("获取卡失败");
                }

                ParkCarType carType = ParkCarTypeServices.QueryParkCarTypeByRecordId(grant.CarTypeID);
                if (carType == null)
                {
                    throw new MyException("获取卡类失败");
                }

                List <ParkGrant> operateTargets = new List <ParkGrant>();
                List <string>    ioRecords      = new List <string>();

                using (DbOperator dbOperator = ConnectionManager.CreateConnection())
                {
                    try
                    {
                        bool renewalsResult = false;
                        dbOperator.BeginTransaction();
                        switch (carType.BaseTypeID)
                        {
                        case BaseCarType.StoredValueCar:
                        {
                            IBaseCard factory = BaseCardFactory.GetFactory();
                            if (payTotalMoney > 0)
                            {
                                ParkOrder order = ParkOrderServices.AddStoredValueCarOrder(grant.PKID, payTotalMoney, card, operatorId, dbOperator);
                                if (order == null)
                                {
                                    throw new MyException("创建充值订单失败");
                                }

                                decimal cardtotalmoney = card.Balance + payTotalMoney;
                                if (order.NewMoney != cardtotalmoney)
                                {
                                    throw new MyException("充值金额计算错误");
                                }
                                renewalsResult = factory.Recharge(card.CardID, payTotalMoney, dbOperator);
                                if (!renewalsResult)
                                {
                                    throw new MyException("卡充值失败【更改卡余额失败】");
                                }
                            }
                            renewalsResult = factory.SetEndDate(card.CardID, endDate, dbOperator);
                            if (!renewalsResult)
                            {
                                throw new MyException("卡充值失败【更改有效期失败】");
                            }
                            break;
                        }

                        case BaseCarType.VIPCar:
                        {
                            ParkOrder order = ParkOrderServices.AddVipCardOrder(grant.PKID, grantId, grant.BeginDate, grant.EndDate, startDate, endDate, renewalMonth, operatorId, dbOperator);
                            if (order == null)
                            {
                                throw new MyException("充值失败【创建充值订单失败】");
                            }

                            IParkGrant factory = ParkGrantFactory.GetFactory();
                            renewalsResult = factory.Renewals(grant.GID, startDate, endDate, dbOperator);
                            if (!renewalsResult)
                            {
                                throw new MyException("修改车辆有效期失败");
                            }
                            break;
                        }

                        case BaseCarType.MonthlyRent:
                        {
                            int pkLotQuantity = 1;
                            if (!string.IsNullOrWhiteSpace(grant.PKLot))
                            {
                                pkLotQuantity = grant.PKLot.TrimEnd(',').Split(',').Length;
                            }
                            decimal amount = ParkOrderServices.CalculateMonthlyRentExpiredWaitPayAmount(startDate, grantId);

                            //if (payTotalMoney != ((carType.Amount * renewalMonth * pkLotQuantity) + amount))
                            //    throw new MyException("凭证续期金额计算有误");



                            List <ParkGrant> shareCardGrants = new List <ParkGrant>();
                            if (!string.IsNullOrWhiteSpace(grant.PKLot))
                            {
                                shareCardGrants = ParkGrantServices.QueryByParkingAndLotAndCarType(grant.PKID, grant.PKLot, BaseCarType.MonthlyRent, grant.GID);
                            }
                            IParkGrant factory = ParkGrantFactory.GetFactory();
                            renewalsResult = factory.Renewals(grant.GID, startDate, endDate, dbOperator);
                            if (!renewalsResult)
                            {
                                throw new MyException("修改车辆有效期失败");
                            }


                            //修改多车多位的有效期
                            foreach (var item in shareCardGrants)
                            {
                                if (string.IsNullOrWhiteSpace(item.PKLot))
                                {
                                    continue;
                                }

                                int len1 = item.PKLot.TrimEnd(',').Split(',').Length;
                                int len2 = grant.PKLot.TrimEnd(',').Split(',').Length;
                                if (len1 != len2)
                                {
                                    continue;
                                }

                                item.BeginDate = startDate;
                                item.EndDate   = endDate;
                                factory.Update(item, dbOperator);
                                operateTargets.Add(item);
                            }
                            //过期转临停订单处理
                            if (grant.EndDate.Date < DateTime.Now.Date)
                            {
                                List <string> plateNos = new List <string>();
                                EmployeePlate plate    = EmployeePlateServices.Query(grant.PlateID);
                                if (plate == null)
                                {
                                    throw new MyException("授权车牌信息不存在");
                                }

                                plateNos.Add(plate.PlateNo);

                                foreach (var item in shareCardGrants)
                                {
                                    if (string.IsNullOrWhiteSpace(item.PKLot))
                                    {
                                        continue;
                                    }

                                    int len1 = item.PKLot.TrimEnd(',').Split(',').Length;
                                    int len2 = grant.PKLot.TrimEnd(',').Split(',').Length;
                                    if (len1 != len2)
                                    {
                                        continue;
                                    }

                                    EmployeePlate otherplate = EmployeePlateServices.Query(item.PlateID);
                                    if (otherplate == null)
                                    {
                                        throw new MyException("多车多位存在无效的车牌");
                                    }
                                    plateNos.Add(otherplate.PlateNo);
                                }

                                if (plateNos.Count > 0 && grant.EndDate != DateTime.MinValue)
                                {
                                    IParkIORecord ioRecord = ParkIORecordFactory.GetFactory();
                                    ioRecords = ioRecord.QueryMonthExpiredNotPayAmountIORecordIds(grant.EndDate.AddDays(1).Date, startDate, grant.PKID, plateNos);
                                    if (ioRecords.Count > 0)
                                    {
                                        bool result = ioRecord.UpdateIORecordEnterType(ioRecords, 0, dbOperator);
                                        if (!result)
                                        {
                                            throw new MyException("修改进出记录类型失败");
                                        }
                                        result = ParkOrderServices.AddExpiredToProStopOrder(ioRecords, operatorId, dbOperator);
                                        if (!result)
                                        {
                                            throw new MyException("创建月卡转临停订单失败");
                                        }
                                    }
                                }
                            }
                            ParkOrder order = ParkOrderServices.AddMonthlyRentOrderCS(grant.PKID, carType.CarTypeID, grant.GID, grant.BeginDate, grant.EndDate, startDate, endDate, renewalMonth, pkLotQuantity, operatorId, payTotalMoney, dbOperator);
                            if (order == null)
                            {
                                throw new MyException("续期失败【创建续期订单失败】");
                            }
                            break;
                        }

                        //case BaseCarType.WorkCar:
                        //    {
                        //        IParkGrant factory = ParkGrantFactory.GetFactory();
                        //        renewalsResult = factory.Renewals(grant.GID, startDate, endDate, dbOperator);
                        //        if (!renewalsResult) throw new MyException("修改卡结束时间错误");
                        //        break;
                        //    }
                        default: throw new MyException("选择的车辆不能续期和充值");
                        }
                        dbOperator.CommitTransaction();

                        string remark = string.Format("grantId:{0};renewalMonth:{1};payTotalMoney:{2};operatorId:{3};startDate:{4};endDate:{5}", grantId, renewalMonth, payTotalMoney, operatorId, startDate.ToString("yyyy-MM-dd"), endDate.ToString("yyyy-MM-dd"));
                        OperateLogServices.AddOperateLog(OperateType.Update, remark);
                        if (ioRecords.Count > 0)
                        {
                            string updateIORecord = string.Format("修改IORecord表,RecordIDs:{0},EnterType:0", string.Join(",", ioRecords));
                            OperateLogServices.AddOperateLog(OperateType.Update, updateIORecord);
                        }
                        return(renewalsResult);
                    }
                    catch (Exception ex)
                    {
                        dbOperator.RollbackTransaction();
                        throw ex;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Context工厂
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        private RuleHandler CreateRuleHandler(InputAgs args, ResultAgs rst)
        {
            string errorMsg = "";

            if (args.AreadInfo.IsNestArea && args.AreadInfo.Parent == null)//内部车场时 且上级区域为空时
            {
                args.AreadInfo.Parent = ParkAreaServices.QueryByRecordId(args.AreadInfo.MasterID);
                if (args.AreadInfo.Parent == null)//还是找不到上级区域时
                {
                    LogerHelper.Loger.Error(string.Format("找不到车场[{0}]的上级车场,上级车场ID为[{1}].", args.AreadInfo.AreaName, args.AreadInfo.MasterID));
                    args.AreadInfo.MasterID = "";//找不到就至为空
                }
            }
            //判断系统停车或非系统停车
            var cartype = BaseCarType.TempCar;

            if (!args.Plateinfo.LicenseNum.Contains("无") && args.Plateinfo.LicenseNum.Length > 3)//不是“无车牌”
            {
                EmployeePlate platenumber = null;
                if (args.GateInfo.OpenPlateBlurryMatch == YesOrNo.Yes)
                {
                    string likeplate = args.Plateinfo.LicenseNum;
                    platenumber = EmployeePlateServices.GetEmployeePlateNumberByPlateNumber(args.AreadInfo.Parkinfo.VID, likeplate, out errorMsg);

                    if (platenumber == null && args.Plateinfo.LicenseNum.Length >= 3)//模糊识别 前一位后一位模糊识别
                    {
                        likeplate   = args.Plateinfo.LicenseNum.Substring(2, args.Plateinfo.LicenseNum.Length - 2);
                        platenumber = EmployeePlateServices.GetGrantPlateNumberByLike(args.AreadInfo.Parkinfo.VID, likeplate, out errorMsg);
                        if (platenumber == null)
                        {
                            likeplate   = args.Plateinfo.LicenseNum.Substring(0, args.Plateinfo.LicenseNum.Length - 2);
                            platenumber = EmployeePlateServices.GetGrantPlateNumberByLike(args.AreadInfo.Parkinfo.VID, likeplate, out errorMsg);
                        }
                        if (platenumber != null)
                        {
                            args.Plateinfo.LicenseNum = platenumber.PlateNo;
                        }
                    }
                }
                else
                {
                    platenumber = EmployeePlateServices.GetEmployeePlateNumberByPlateNumber(args.AreadInfo.Parkinfo.VID, args.Plateinfo.LicenseNum, out errorMsg);
                }
                if (platenumber != null)
                {
                    //根据车牌获取车辆用户信息
                    var pkcard = ParkGrantServices.GetParkGrantByPlateNumberID(args.AreadInfo.PKID, platenumber.PlateID, out errorMsg);

                    if (pkcard.Count() > 0)
                    {
                        //判断是否有区域 通道限制
                        var cardinfo = pkcard.First();
                        args.LastCardInfo = cardinfo;
                        if (cardinfo.AreaIDS.IsEmpty())//没有限制
                        {
                            if ((cardinfo.GateID.IsEmpty()) ||
                                cardinfo.GateID.Contains(args.GateInfo.GateID))     //区域包含 且通道未控制授权 或 通道已经授权
                            {
                                args.CardInfo = cardinfo;
                                args.CardInfo.OwnerPlateNumber = platenumber;
                                var usercard = BaseCardServices.GetBaseCard(args.CardInfo.CardID, out errorMsg);
                                if (usercard != null)
                                {
                                    args.CardInfo.Usercard = usercard;
                                }
                                else
                                {
                                    args.CardInfo = null;
                                }
                            }
                        }
                        else
                        {
                            if (cardinfo.AreaIDS.Contains(args.AreadInfo.AreaID) && (cardinfo.GateID.IsEmpty()) ||
                                cardinfo.GateID.Contains(args.GateInfo.GateID))   //区域包含 且通道未控制授权 或 通道已经授权
                            {
                                args.CardInfo = cardinfo;
                                args.CardInfo.OwnerPlateNumber = platenumber;
                                var usercard = BaseCardServices.GetBaseCard(args.CardInfo.CardID, out errorMsg);
                                if (usercard != null)
                                {
                                    args.CardInfo.Usercard = usercard;
                                }
                                else
                                {
                                    args.CardInfo = null;
                                }
                            }
                        }
                        if (args.CardInfo == null)
                        {
                            rst.ValidMsg = "非本区域月卡";
                        }
                    }
                }

                if (args.CardInfo != null)
                {
                    var pkcardtype = ParkCarTypeServices.QueryParkCarTypeByRecordId(args.CardInfo.CarTypeID);
                    if (pkcardtype != null)
                    {
                        args.CarTypeInfo = pkcardtype;
                    }
                    else
                    {
                        //获取对应的卡类型
                        var pkcardtypes = ParkCarTypeServices.QueryCardTypesByBaseCardType(args.AreadInfo.PKID, BaseCarType.TempCar);
                        if (pkcardtypes != null && pkcardtypes.Count() > 0)
                        {
                            args.CarTypeInfo = pkcardtypes.First();
                        }
                    }

                    if (!args.CardInfo.CarModelID.IsEmpty())
                    {
                        var model = ParkCarModelServices.QueryByRecordId(args.CardInfo.CarModelID);
                        args.CarModel = model;
                    }
                    if (args.CarModel == null)
                    {
                        //获取卡对应的车类型
                        var listcarmodel = ParkCarModelServices.GetDefaultCarModel(args.AreadInfo.PKID, out errorMsg);
                        if (listcarmodel != null)
                        {
                            args.CarModel = listcarmodel;
                        }
                    }
                }
                else
                {
                    //默认为临时车
                    var pkcardtypes = ParkCarTypeServices.QueryCardTypesByBaseCardType(args.AreadInfo.PKID, BaseCarType.TempCar);
                    if (pkcardtypes != null && pkcardtypes.Count() > 0)
                    {
                        args.CarTypeInfo = pkcardtypes.First();
                    }

                    ////获取默认车类型
                    //var listcarmodel = ParkCarModelServices.GetDefaultCarModel(args.AreadInfo.PKID, out errorMsg);
                    //if (listcarmodel != null)
                    //{
                    //    args.CarModel = listcarmodel;
                    //}

                    if (args.Plateinfo.PlateColor != null && args.Plateinfo.PlateColor.Contains("黄"))
                    {
                        var list = ParkCarModelServices.QueryByParkingId(args.AreadInfo.PKID);
                        foreach (var item in list)
                        {
                            if (item.PlateColor != null && item.PlateColor.Contains("黄"))
                            {
                                args.CarModel = item;
                                break;
                            }
                        }
                    }
                    if (args.CarModel == null)
                    {
                        //获取卡对应的车类型
                        var carmode = ParkCarModelServices.GetDefaultCarModel(args.AreadInfo.PKID, out errorMsg);
                        if (carmode != null)
                        {
                            args.CarModel = carmode;
                        }
                    }
                }
            }
            else
            {
                //默认为临时车
                var pkcardtypes = ParkCarTypeServices.QueryCardTypesByBaseCardType(args.AreadInfo.PKID, BaseCarType.TempCar);
                if (pkcardtypes != null && pkcardtypes.Count() > 0)
                {
                    args.CarTypeInfo = pkcardtypes.First();
                }
                if (args.Plateinfo.PlateColor != null && args.Plateinfo.PlateColor.Contains("黄"))
                {
                    var list = ParkCarModelServices.QueryByParkingId(args.AreadInfo.PKID);
                    foreach (var item in list)
                    {
                        if (item.PlateColor != null && item.PlateColor.Contains("黄"))
                        {
                            args.CarModel = item;
                            break;
                        }
                    }
                }
                if (args.CarModel == null)
                {
                    //获取卡对应的车类型
                    var carmode = ParkCarModelServices.GetDefaultCarModel(args.AreadInfo.PKID, out errorMsg);
                    if (carmode != null)
                    {
                        args.CarModel = carmode;
                    }
                }
            }
            if (args.AreadInfo.IsNestArea)//小车场 先查询对应的通行记录
            {
                ParkIORecord ioRecord = ParkIORecordServices.GetNoExitIORecordByPlateNumber(args.AreadInfo.PKID, args.Plateinfo.LicenseNum, out errorMsg);

                args.NestAreaIORecord = ioRecord;
            }
            if (args.CarTypeInfo == null)
            {
                rst.ResCode = ResultCode.LocalError;
                throw new Exception("参数错误:默认卡片类型为空");
            }
            if (args.CarTypeInfo == null)
            {
                rst.ResCode = ResultCode.LocalError;
                throw new Exception("参数错误:默认车辆类型为空");
            }

            cartype = args.CarTypeInfo.BaseTypeID;
            #region 生产对应的验证规则
            //此处可根据配置文件利用反射生成配置的验证规则
            RuleHandler ruleHandler = null;
            switch (cartype)
            {
            case BaseCarType.MonthlyRent:
                #region 月卡
                if (args.GateInfo.IoState == IoState.GoIn)    //进
                {
                    ruleHandler = RuleHandlerFactory.Instance.CreateMonthMainInRuleHandler();
                }
                else    //出
                {
                    ruleHandler = RuleHandlerFactory.Instance.CreateMonthMainOutRuleHandler();
                }
                #endregion
                break;

            case BaseCarType.TempCar:
                #region 临时卡
                if (args.GateInfo.IoState == IoState.GoIn)    //进
                {
                    ruleHandler = RuleHandlerFactory.Instance.CreateTempMainInRuleHandler();
                }
                else    //出
                {
                    ruleHandler = RuleHandlerFactory.Instance.CreateTempMainOutRuleHandler();
                }
                #endregion
                break;

            case BaseCarType.StoredValueCar:
                #region 储值卡
                if (args.GateInfo.IoState == IoState.GoIn)    //进
                {
                    ruleHandler = RuleHandlerFactory.Instance.CreateValueMainInRuleHandler();
                }
                else    //出
                {
                    ruleHandler = RuleHandlerFactory.Instance.CreateValueMainOutRuleHandler();
                }
                #endregion
                break;

            case BaseCarType.VIPCar:
                #region VIP卡
                if (args.GateInfo.IoState == IoState.GoIn)    //进
                {
                    ruleHandler = RuleHandlerFactory.Instance.CreateVIPMainInRuleHandler();
                }
                else    //出
                {
                    ruleHandler = RuleHandlerFactory.Instance.CreateVIPMainOutRuleHandler();
                }
                #endregion
                break;
            }
            #endregion
            return(ruleHandler);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 白天黑夜最大收费参数设置
        /// </summary>
        //public static DayAndNightMaxMoneyPara DayAndNightMaxMoneyPara { get; set; }

        //private static XDocument document;
        //public static XDocument _XDocument
        //{
        //    get
        //    {
        //        return document;
        //    }
        //    private set
        //    {
        //        document = value;
        //    }
        //}

        //static RateProcesser()
        //{
        //    try
        //    {
        //        string xmlName = "TimeShareFeeRule.xml";
        //        var dirName = Path.Combine(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase, xmlName);

        //        XDocument xdoc = XDocument.Load(dirName);
        //        foreach (var item in xdoc.Root.Elements())
        //        {
        //            if (item.Attribute("IsEnable").Value.ToBoolean())
        //            {
        //                _XDocument = xdoc;
        //            }
        //            break;
        //        }
        //    }
        //    catch(Exception ex)
        //    {
        //        LogerHelper.Loger.Error(ex);
        //    }
        //}

        //public static void  LoadCustomFeerule(string ruletext)
        //{

        //    try
        //    {
        //        using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(ruletext)))
        //        {
        //            XDocument xdoc = XDocument.Load(stream);
        //            foreach (var item in xdoc.Root.Elements())
        //            {
        //                if (item.Attribute("IsEnable").Value.ToBoolean())
        //                {
        //                    _XDocument = xdoc;
        //                }
        //                break;
        //            }

        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        LogerHelper.Loger.Error(ex);
        //    }
        //}
        /// <summary>
        /// 根据入场记录算费
        /// </summary>
        /// <param name="ioRecord"></param>
        /// <returns></returns>
        public static ResultAgs GetRateResult(ParkIORecord ioRecord, ParkGate outGate, DateTime exitTime, string carModeid = "")
        {
            if (outGate == null)
            {
                return(null);
            }
            string   errorMsg = "";
            InputAgs args     = new InputAgs();

            args.AreadInfo = ParkAreaServices.QueryByRecordId(ioRecord.AreaID);
            if (args.AreadInfo.IsNestArea && args.AreadInfo.Parent == null)//内部车场时 且上级区域为空时
            {
                args.AreadInfo.Parent = ParkAreaServices.QueryByRecordId(args.AreadInfo.MasterID);
                if (args.AreadInfo.Parent == null)//还是找不到上级区域时
                {
                    LogerHelper.Loger.Error(string.Format("找不到车场[{0}]的上级车场,上级车场ID为[{1}].", args.AreadInfo.AreaName, args.AreadInfo.MasterID));
                    args.AreadInfo.MasterID = "";//找不到就至为空
                }
            }
            args.AreadInfo.Parkinfo = ParkingServices.QueryParkingByParkingID(args.AreadInfo.PKID);
            if (args.AreadInfo.Parkinfo == null)//还是找不到上级区域时
            {
                LogerHelper.Loger.Error(string.Format("找不到区域[{0}]对应的车场.", args.AreadInfo.AreaName));
                return(null);
            }
            args.Plateinfo             = new PlateInfo();
            args.Plateinfo.LicenseNum  = ioRecord.PlateNumber;
            args.Plateinfo.TriggerTime = exitTime;
            args.CarTypeInfo           = ParkCarTypeServices.QueryParkCarTypeByRecordId(ioRecord.CarTypeID);
            string        str         = errorMsg;
            EmployeePlate platenumber = EmployeePlateServices.GetEmployeePlateNumberByPlateNumber(args.AreadInfo.Parkinfo.VID, args.Plateinfo.LicenseNum, out errorMsg);

            if (platenumber != null)
            {
                //根据车牌获取车辆用户信息
                var pkcard = ParkGrantServices.GetParkGrantByPlateNumberID(args.AreadInfo.PKID, platenumber.PlateID, out errorMsg);
                if (pkcard.Count() > 0)
                {
                    //判断是否有区域 通道限制
                    var cardinfo = pkcard.First();
                    args.CardInfo = cardinfo;
                    args.CardInfo.OwnerPlateNumber = platenumber;
                    var usercard = BaseCardServices.GetBaseCard(args.CardInfo.CardID, out errorMsg);
                    if (usercard != null)
                    {
                        args.CardInfo.Usercard = usercard;
                    }
                    else
                    {
                        args.CardInfo = null;
                    }
                    if (!args.CardInfo.CarModelID.IsEmpty())
                    {
                        carModeid = args.CardInfo.CarModelID;
                    }
                }
            }

            if (args.CarTypeInfo == null)
            {
                return(null);
            }
            if (carModeid.IsEmpty())
            {
                args.CarModel = ParkCarModelServices.GetDefaultCarModel(args.AreadInfo.PKID, out errorMsg);
            }
            else
            {
                args.CarModel = ParkCarModelServices.QueryByRecordId(carModeid);
                if (args.CarModel == null)
                {
                    args.CarModel = ParkCarModelServices.GetDefaultCarModel(args.AreadInfo.PKID, out errorMsg);
                }
            }
            if (args.CarModel == null)
            {
                return(null);
            }
            //获取默认车类型
            args.GateInfo = outGate;
            args.IORecord = ioRecord;

            ResultAgs rst = new ResultAgs();

            rst.InOutBaseCardType = BaseCarType.TempCar;
            rst.ResCode           = ResultCode.OutOK;
            var rateContext = new RateTemplate();

            rateContext.Process(args, rst);
            return(rst);
        }