Exemplo n.º 1
0
        private void FrmParkTarrif_Load(object sender, EventArgs e)
        {
            this.Text = ParkName + "停车场单独费率设置";

            this.btnOK.Enabled       = OperatorInfo.CurrentOperator.Permit(Permission.EditSysSetting);
            this.btnDownLoad.Enabled = OperatorInfo.CurrentOperator.Permit(Permission.EditSysSetting);

            TariffSetting ts = TariffSetting.Current;

            if (ts == null ||
                ts.ParkTariffDictionary == null ||
                !ts.ParkTariffDictionary.ContainsKey(ParkID) ||
                ts.ParkTariffDictionary[ParkID] == null ||
                ts.ParkTariffDictionary[ParkID].Count == 0)
            {
                this.lblHadSet.Visible   = true;
                this.lblHadSet.ForeColor = Color.Blue;
                this.lblHadSet.Text      = "未设置单独费率";
            }
            //if (ts.ParkTariffDictionary == null)
            //    ts.ParkTariffDictionary = new Dictionary<int, List<TariffBase>>();
            //if (!ts.ParkTariffDictionary.ContainsKey(ParkID))
            //{
            //    //ts.ParkTariffDictionary.Add(ParkID, new List<TariffBase>());
            //    this.lblHadSet.ForeColor = Color.Red;
            //    this.lblHadSet.Text = "未设置单独费率";
            //}
            //else
            //{
            //    this.lblHadSet.ForeColor = Color.Blue;
            //    this.lblHadSet.Text = "已设置单独费率";
            //}
            ShowTariffSetting(ts);
        }
Exemplo n.º 2
0
        public List <Packet> CreateDownloadTariffSettingPacket(byte address, TariffSetting ts)
        {
            byte          index   = 19;
            List <Packet> packets = new List <Packet>();
            Packet        packet  = FormatTariffOptions(ts.TariffOption);

            packets.Add(packet);
            for (int tariffType = 0; tariffType < 4; tariffType++)
            {
                for (int carType = 0; carType < 4; carType++)
                {
                    index += (byte)(tariffType * 4 + carType);
                    //普通收费
                    TariffBase tariff = ts.GetTariff(carType, (TariffType)tariffType);
                    if (tariff != null)
                    {
                        packet = FormatTariff(tariff, index, ts.TariffOption);
                        if (packet != null)
                        {
                            packets.Add(packet);
                        }
                    }
                }
            }
            return(packets);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 生成卡片外车场停车收费记录
        /// </summary>
        /// <param name="card">卡片</param>
        /// <param name="ts">停车场费率设置</param>
        /// <param name="tos" >收费设置选项</param>
        /// <param name="chargeDateTime">收费时间</param>
        /// <returns></returns>
        public static CardPaymentInfo CreateCardPaymentRecord(CardInfo card, TariffSetting ts, Byte carType, DateTime chargeDateTime)
        {
            CardPaymentInfo cardPayment = new CardPaymentInfo();

            cardPayment.CardID          = card.CardID;
            cardPayment.OwnerName       = card.OwnerName;
            cardPayment.CardCertificate = card.CardCertificate;
            cardPayment.CarPlate        = card.LastCarPlate;
            cardPayment.CardType        = card.CardType;
            cardPayment.CarType         = carType;
            cardPayment.EnterDateTime   = card.LastDateTime;
            cardPayment.ChargeDateTime  = chargeDateTime;

            //如果卡片的已缴费用与收费记录不一致,以卡片的数据为准
            if ((cardPayment.LastTotalFee + cardPayment.LastTotalDiscount) != card.TotalPaidFee)
            {
                cardPayment.LastTotalPaid     = card.TotalPaidFee;
                cardPayment.LastTotalDiscount = 0;
                cardPayment.LastStationID     = string.Empty;
            }

            ParkAccountsInfo parkFee = ts.CalculateCardParkFee(card, carType, chargeDateTime);

            cardPayment.Accounts   = parkFee.Accounts;
            cardPayment.TariffType = parkFee.TariffType;

            cardPayment.ParkFee     = parkFee.ParkFee;
            cardPayment.PaymentCode = PaymentCode.Computer;
            return(cardPayment);
        }
Exemplo n.º 4
0
        private TariffSetting GetTariffSettingFromInput()
        {
            TariffSetting ts = TariffSetting.Current;

            if (ts.ParkTariffDictionary == null)
            {
                ts.ParkTariffDictionary = new Dictionary <int, List <TariffBase> >();
            }

            if (!ts.ParkTariffDictionary.ContainsKey(ParkID))
            {
                ts.ParkTariffDictionary.Add(ParkID, new List <TariffBase>());
            }
            else
            {
                ts.ParkTariffDictionary[ParkID] = new List <TariffBase>();
            }

            foreach (DataGridViewRow row in tariffGrid.Rows)
            {
                for (int i = 1; i < tariffGrid.Columns.Count; i++)
                {
                    TariffBase tariff = row.Cells[i].Tag as TariffBase;
                    if (tariff != null)
                    {
                        ts.ParkTariffDictionary[ParkID].Add(tariff);
                    }
                }
            }

            return(ts);
        }
Exemplo n.º 5
0
        private void btnExportSetting_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否需要导出参数?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }
            try
            {
                string path = System.IO.Path.Combine(Application.StartupPath, "MySetting.xml");
                POS.Model.MySetting mysetting = new Model.MySetting();
                UserSetting         us        = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <UserSetting>();
                if (us != null)
                {
                    SetValue(mysetting, us);
                }
                KeySetting ks = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <KeySetting>();
                if (ks != null)
                {
                    SetValue(mysetting, ks);
                }
                TariffSetting ts = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <TariffSetting>();
                if (ts != null)
                {
                    SetValue(mysetting, ts);
                }
                HolidaySetting hs = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <HolidaySetting>();
                if (hs != null)
                {
                    SetValue(mysetting, hs);
                }
                List <OperatorInfo> opts = (new OperatorBll(AppSettings.CurrentSetting.ParkConnect)).GetAllOperators().QueryObjects;
                if (opts != null)
                {
                    SetValue(mysetting, opts);
                }

                XmlSerializer ser = new XmlSerializer(typeof(POS.Model.MySetting));
                using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write))
                {
                    ser.Serialize(stream, mysetting);
                }
                string remote = @"FlashDisk\RalidPos\MySetting.xml";
                OpenNETCF.Desktop.Communication.RAPI rapi = new OpenNETCF.Desktop.Communication.RAPI();
                if (rapi.DevicePresent)
                {
                    rapi.Connect();
                    rapi.CopyFileToDevice(path, remote, true);
                    rapi.Disconnect();
                }
                ShowMessage("导出参数成功,手持机上的收费软件需要重启后参数才会生效", Color.Black);
            }
            catch (Exception ex)
            {
                ShowMessage(ex.Message, Color.Red);
                Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
            }
        }
Exemplo n.º 6
0
 public override bool ApplyTariffSetting(TariffSetting tariffSetting)
 {
     if (Parent.WorkMode == ParkWorkMode.OffLine)
     {
         List <Packet> packets = _PacketCreater.CreateDownloadTariffSettingPacket(Address, tariffSetting);
         foreach (Packet packet in packets)
         {
             _CommComponent.SendPacket(packet);
             Thread.Sleep(1000);
         }
     }
     return(true);
 }
Exemplo n.º 7
0
        /// <summary>
        /// 生成卡片外车场停车收费记录
        /// </summary>
        /// <param name="card">卡片</param>
        /// <param name="ts">停车场费率设置</param>
        /// <param name="tos" >收费设置选项</param>
        /// <param name="chargeDateTime">收费时间</param>
        /// <returns></returns>
        public static CardPaymentInfo CreateCardPaymentRecord(CardInfo card, TariffSetting ts, Byte carType, DateTime chargeDateTime)
        {
            CardPaymentInfo cardPayment = new CardPaymentInfo();

            cardPayment.CardID          = card.CardID;
            cardPayment.OwnerName       = card.OwnerName;
            cardPayment.CardCertificate = card.CardCertificate;
            cardPayment.CarPlate        = card.IsCarPlateList ? card.CarPlate : card.LastCarPlate;//如果是名单车牌,以车牌号为准
            cardPayment.CardType        = card.CardType;
            cardPayment.CarType         = carType;
            cardPayment.EnterDateTime   = card.LastDateTime;
            cardPayment.ChargeDateTime  = chargeDateTime;

            //计算应收费用
            if (card.LastPayment != null)
            {
                cardPayment.LastTotalPaid     = card.LastPayment.TotalPaid;
                cardPayment.LastTotalDiscount = card.LastPayment.TotalDiscount;
                cardPayment.LastStationID     = card.LastPayment.StationID;
            }
            //如果卡片的已缴费用与收费记录不一致,以卡片的数据为准
            if (cardPayment.LastTotalFee != card.TotalPaidFee)
            {
                cardPayment.LastTotalPaid     = card.TotalPaidFee;
                cardPayment.LastTotalDiscount = 0;
                cardPayment.LastStationID     = string.Empty;
            }

            ParkAccountsInfo parkFee = ts.CalculateCardParkFee(card, carType, chargeDateTime);

            cardPayment.Accounts   = parkFee.Accounts;
            cardPayment.TariffType = parkFee.TariffType;

            cardPayment.ParkFee     = parkFee.ParkFee;
            cardPayment.PaymentCode = PaymentCode.Computer;

            if (card.EnableHotelApp && card.FreeDateTime.HasValue)
            {
                cardPayment.Memo = string.Format("{0} {1}", Resouce.Resource1.CardPaymentInfoFactory_Free, card.FreeDateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
            }

            return(cardPayment);
        }
Exemplo n.º 8
0
 public bool DownloadTariffSettingToEntrance(int entranceID, TariffSetting tariffSetting)
 {
     try
     {
         if (_Channel != null)
         {
             return(_Channel.DownloadTariffSettingToEntrance(entranceID, tariffSetting));
         }
     }
     catch (CommunicationException)
     {
         if (ParkAdapterConnectFail != null)
         {
             ParkAdapterConnectFail(this, EventArgs.Empty);
         }
     }
     catch (Exception ex)
     {
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
     return(false);
 }
Exemplo n.º 9
0
        private void ShowTariffSetting(TariffSetting ts)
        {
            tariffGrid.Columns["colGeneral"].Tag             = TariffType.Normal;
            tariffGrid.Columns["colHoliday"].Tag             = TariffType.Holiday;
            tariffGrid.Columns["colInnerRoom"].Tag           = TariffType.InnerRoom;
            tariffGrid.Columns["colHolidayAndInnerRoom"].Tag = TariffType.HolidayAndInnerRoom;

            List <CardType> cardTtypes = CardType.GetBaseCardTypes();

            if (CustomCardTypeSetting.Current != null && CustomCardTypeSetting.Current.CardTypes != null)
            {
                cardTtypes.AddRange(CustomCardTypeSetting.Current.CardTypes);
            }
            cardTtypes.Remove(CardType.Ticket);//纸票与临时卡使用同一种费率,所以这里就不在设置纸票的费率了
            foreach (CardType cardType in cardTtypes)
            {
                foreach (CarType carType in CarTypeSetting.Current.CarTypes)
                {
                    int row = tariffGrid.Rows.Add();
                    InitTariffGridRow(tariffGrid.Rows[row], cardType, carType, ts);
                }
            }
        }
Exemplo n.º 10
0
        public static CardEventReport CreateExitEvent(CardInfo card, int parkID, int entranceID, string entranceName, Byte carType, TariffSetting ts, DateTime eventDateTime)
        {
            CardEventReport report = new CardEventReport();

            report.ID                          = Guid.NewGuid();
            report.ParkID                      = parkID;
            report.EventDateTime               = eventDateTime;
            report.EntranceID                  = entranceID;
            report.SourceName                  = entranceName;
            report.IsExitEvent                 = true;
            report.CardID                      = card.CardID;
            report.OwnerName                   = card.OwnerName;
            report.CarPlate                    = card.CarPlate;
            report.CardCertificate             = card.CardCertificate;
            report.CardType                    = card.CardType;
            report.CarType                     = carType;
            report.EventStatus                 = CardEventStatus.Pending;
            report.LastDateTime                = card.LastDateTime;
            report.LastCarPlate                = card.LastCarPlate;
            report.CardPaymentInfo             = CardPaymentInfoFactory.CreateCardPaymentRecord(card, ts, carType, eventDateTime);
            report.Balance                     = card.Balance;
            report.ValidDate                   = card.ValidDate;
            report.OnlineHandleWhenOfflineMode = card.OnlineHandleWhenOfflineMode;
            report.ParkingStatus               = ParkingStatus.Out;

            if (card.EnableLimitation && UserSetting.Current != null && UserSetting.Current.LimitationPerMonth > 0)
            {
                DateTime s = new DateTime(report.EventDateTime.Year, report.EventDateTime.Month, 1);
                if (report.LastDateTime > s)
                {
                    s = report.LastDateTime.Value;
                }
                decimal hour = UserSetting.Current.CalculateLimitation(s, report.EventDateTime); //只计算本月分的限时停车时长
                report.Limitation = hour;

                if (!card.LimitationTimestamp.HasValue ||
                    card.LimitationTimestamp.Value.Date.Year != report.EventDateTime.Year ||
                    card.LimitationTimestamp.Value.Month != report.EventDateTime.Month)  //卡片累计的剩余时长非本月的,重新计算
                {
                    report.LimitationRemain = UserSetting.Current.LimitationPerMonth - report.Limitation;
                }
                else
                {
                    report.LimitationRemain = card.LimitationRemain.Value - report.Limitation;
                }
            }
            return(report);
        }
Exemplo n.º 11
0
 public override bool DownloadTariffSetting(TariffSetting tariffSetting)
 {
     TariffSetting.Current = tariffSetting;
     return(true);
 }
Exemplo n.º 12
0
 public bool DownloadTariffSetting(TariffSetting tariffSetting)
 {
     return(_Park.DownloadTariffSetting(tariffSetting));
 }
Exemplo n.º 13
0
 public bool DownloadTariffSettingToEntrance(int entranceID, TariffSetting tariffSetting)
 {
     return(_Park.DownloadTariffSettingToEntrance(entranceID, tariffSetting));
 }
Exemplo n.º 14
0
        /// <summary>
        /// 同步系统设置
        /// </summary>
        private bool SyncSystemOptions()
        {
            NotifyMsg(Resources.Resource1.FrmSyncDataToStandby_SynchronizingOptions);
            NotifyProgress(8, 0);

            bool          success = true;
            CommandResult result  = null;

            SysParaSettingsBll masterssb  = new SysParaSettingsBll(AppSettings.CurrentSetting.CurrentMasterConnect);
            SysParaSettingsBll standbyssb = new SysParaSettingsBll(AppSettings.CurrentSetting.CurrentStandbyConnect);

            UserSetting us = masterssb.GetSetting <UserSetting>();

            success = us != null ? success : false;
            if (us != null)
            {
                result  = standbyssb.SaveSetting <UserSetting>(us);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (us != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_UserSetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_UserSetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            HolidaySetting hs = masterssb.GetSetting <HolidaySetting>();

            success = hs != null ? success : false;
            if (hs != null)
            {
                result  = standbyssb.SaveSetting <HolidaySetting>(hs);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (hs != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_HolidaySetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_HolidaySetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            AccessSetting acs = masterssb.GetSetting <AccessSetting>();

            success = acs != null ? success : false;
            if (acs != null)
            {
                result  = standbyssb.SaveSetting <AccessSetting>(acs);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (acs != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_AccessSetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_AccessSetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            TariffSetting ts = masterssb.GetSetting <TariffSetting>();

            success = ts != null ? success : false;
            if (ts != null)
            {
                result  = standbyssb.SaveSetting <TariffSetting>(ts);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (ts != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_TariffSetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_TariffSetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            CarTypeSetting cts = masterssb.GetSetting <CarTypeSetting>();

            success = cts != null ? success : false;
            if (cts != null)
            {
                result  = standbyssb.SaveSetting <CarTypeSetting>(cts);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (cts != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_CarTypeSetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_CarTypeSetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            CustomCardTypeSetting ccts = masterssb.GetSetting <CustomCardTypeSetting>();

            success = ccts != null ? success : false;
            if (ccts != null)
            {
                result  = standbyssb.SaveSetting <CustomCardTypeSetting>(ccts);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (ccts != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_CustomCardTypeSetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_CustomCardTypeSetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            BaseCardTypeSetting bcts = masterssb.GetSetting <BaseCardTypeSetting>();

            success = bcts != null ? success : false;
            if (bcts != null)
            {
                result  = standbyssb.SaveSetting <BaseCardTypeSetting>(bcts);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (bcts != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_BaseCardTypeSetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_BaseCardTypeSetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            KeySetting ks = masterssb.GetSetting <KeySetting>();

            success = ks != null ? success : false;
            if (ks != null)
            {
                result  = standbyssb.SaveSetting <KeySetting>(ks);
                success = result.Result == ResultCode.Successful;
                NotifyProgress(null, null);
            }
            if (ks != null && result.Result == ResultCode.Successful)
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_KeySetting, Resources.Resource1.Form_Success));
            }
            else
            {
                NotifyInfo(string.Format("{0}{1}", Resources.Resource1.FrmSyncDataToStandby_KeySetting, Resources.Resource1.Form_Fail), Color.Red);
            }

            NotifyMsg(Resources.Resource1.FrmSyncDataToStandby_OptionsFinish);

            return(success);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 获取某卡号的停车收费信息接口
        /// </summary>
        /// <param name="cardID">卡号</param>
        /// <param name="discountHour">优惠时长</param>
        /// <param name="discountAmount">优惠金额</param>
        /// <param name="reserve1">预留1</param>
        /// <param name="reserve2">预留2</param>
        /// <returns>Result 0:成功,其他:失败;QueryObject:返回收费信息对象</returns>
        public QueryResult <WSCardPaymentInfo> GetCardPayment(string cardID, string discountHour, string discountAmount, string reserve1, string reserve2)
        {
            try
            {
                #region 先验证输入参数
                if (string.IsNullOrEmpty(cardID.Trim()))
                {
                    return(new QueryResult <WSCardPaymentInfo>(ResultCode.ParameterError, "参数卡号错误", null));
                }
                int discountHourInt = 0;
                if (!string.IsNullOrEmpty(discountHour.Trim()))
                {
                    if (!int.TryParse(discountHour, out discountHourInt))
                    {
                        return(new QueryResult <WSCardPaymentInfo>(ResultCode.ParameterError, "参数优惠时长错误", null));
                    }
                }
                decimal discountAmountD = 0;
                if (!string.IsNullOrEmpty(discountAmount.Trim()))
                {
                    if (!decimal.TryParse(discountAmount, out discountAmountD))
                    {
                        return(new QueryResult <WSCardPaymentInfo>(ResultCode.ParameterError, "参数优惠金额错误", null));
                    }
                }
                #endregion

                #region 接口日志记录
                if (AppConifg.Current.Log)
                {
                    try
                    {
                        string log = string.Format("卡号:{0} 优惠时长:{1} 优惠金额:{2} 预留1:{3} 预留2:{4}"
                                                   , cardID
                                                   , discountHour
                                                   , discountAmount
                                                   , reserve1
                                                   , reserve2);
                        Ralid.GeneralLibrary.LOG.FileLog.Log(AppConifg.Current.LogPath, "GetCardPayment", log);
                    }
                    catch (Exception ex)
                    {
                        Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
                    }
                }
                #endregion

                #region 验证卡片信息
                //查找该卡号的卡片
                CardBll cardBll = new CardBll(AppConifg.Current.ParkingConnection);
                QueryResult <CardInfo> cResult = cardBll.GetCardByID(cardID);
                if (cResult.Result != ResultCode.Successful)
                {
                    return(new QueryResult <WSCardPaymentInfo>(cResult.Result, "获取卡片信息失败", null));
                }
                CardInfo card = cResult.QueryObject;
                if (card == null)
                {
                    return(new QueryResult <WSCardPaymentInfo>(ResultCode.NoRecord, "此卡未登记", null));
                }
                if (!card.IsInPark)
                {
                    return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, "此卡已出场", null));
                }
                string msg = string.Empty;
                if (!ValidateCard(card, out msg))
                {
                    return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, msg, null));
                }
                DateTime chargeDateTime = DateTime.Now;
                if (card.LastDateTime > chargeDateTime)
                {
                    return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, "入场时间晚于计费时间", null));
                }

                //获取卡片所在停车场信息
                EntranceBll  entranceBll = new EntranceBll(AppConifg.Current.ParkingConnection);
                EntranceInfo entrance    = entranceBll.GetEntranceInfo(card.LastEntrance).QueryObject;
                if (entrance == null)
                {
                    return(new QueryResult <WSCardPaymentInfo>(ResultCode.NoRecord, "没有找到入场通道信息", null));
                }
                ParkBll  parkBll = new ParkBll(AppConifg.Current.ParkingConnection);
                ParkInfo park    = parkBll.GetParkInfoByID(entrance.ParkID).QueryObject;
                if (park == null)
                {
                    return(new QueryResult <WSCardPaymentInfo>(ResultCode.NoRecord, "没有找到停车场信息", null));
                }
                //判断卡片合法性
                if (card.IsCardList && park.IsWriteCardMode && !card.OnlineHandleWhenOfflineMode)
                {
                    //写卡模式时,脱机处理的卡片名单不能缴费
                    return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, "该卡片为写卡处理卡片,不能进行在线缴费", null));
                }
                #endregion

                #region 获取费率和节假日
                SysParaSettingsBll ssb    = new SysParaSettingsBll(AppConifg.Current.ParkingConnection);
                TariffSetting      tariff = ssb.GetSetting <TariffSetting>();
                if (tariff == null)
                {
                    return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, "获取费率失败", null));
                }
                TariffSetting.Current = tariff;
                HolidaySetting holiday = ssb.GetSetting <HolidaySetting>();
                if (holiday == null)
                {
                    return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, "获取节假日失败", null));
                }
                HolidaySetting.Current = holiday;
                #endregion

                #region 判断是否已缴过费
                if (card.IsCompletedPaid && tariff.IsInFreeTime(card.PaidDateTime.Value, chargeDateTime))
                {
                    //已缴费,并且未过免费时间,不允许缴费
                    msg = string.Format("已缴费,请在{0}分钟内离场!", tariff.FreeTimeRemaining(card.PaidDateTime.Value, chargeDateTime));
                    return(new QueryResult <WSCardPaymentInfo>(ResultCode.Fail, msg, null));
                }
                #endregion

                //重设卡片优惠时长
                card.DiscountHour += discountHourInt;
                if (card.DiscountHour > 0xFF)
                {
                    card.DiscountHour = 0xFF;
                }

                //生成卡片缴费记录
                CardPaymentInfo chargeRecord = CardPaymentInfoFactory.CreateCardPaymentRecord(park.ParkID, card, tariff, card.CarType, chargeDateTime);
                //计算优惠后的缴费费用
                chargeRecord.Discount += discountAmountD;
                if (chargeRecord.Discount > chargeRecord.Accounts)
                {
                    //如果优惠金额比应收费用多,优惠金额为应收费用,这是为了防止实际支付费用为负数的情况出现
                    chargeRecord.Discount = chargeRecord.Accounts;
                }

                WSCardPaymentInfo wsRecord = new WSCardPaymentInfo();
                wsRecord.SetWSCardPaymentInfo(chargeRecord);
                wsRecord.EntranceName = entrance.EntranceName;

                return(new QueryResult <WSCardPaymentInfo>(ResultCode.Successful, wsRecord));
            }
            catch (Exception ex)
            {
                Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
                string msg = string.Format("接口发生异常,异常信息:{0}", ex.Message);
                return(new QueryResult <WSCardPaymentInfo>(ResultCode.InterfaceException, msg, null));
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// 应用费率设置
 /// </summary>
 /// <param name="tariffSetting"></param>
 public abstract bool ApplyTariffSetting(TariffSetting tariffSetting);
Exemplo n.º 17
0
        /// <summary>
        /// 停车收费接口
        /// </summary>
        /// <param name="cardID">卡号</param>
        /// <param name="chargeDateTime">计费时间(格式:yyyy-MM-dd HH:mm:ss.fff)</param>
        /// <param name="paid">实付金额</param>
        /// <param name="payMode">支付方式[0代表现金,1代表微信,…]</param>
        /// <param name="memo">费用说明</param>
        /// <param name="reserve1">预留1</param>
        /// <param name="reserve2">预留2</param>
        /// <returns>Result 0:成功,其他:失败</returns>
        public CommandResult CardFeePay(string cardID, string chargeDateTime, string paid, string payMode, string memo, string reserve1, string reserve2)
        {
            try
            {
                #region 先验证输入参数
                if (string.IsNullOrEmpty(cardID.Trim()))
                {
                    return(new CommandResult(ResultCode.ParameterError, "参数卡号错误"));
                }
                DateTime chargeTime = new DateTime(2011, 1, 1);
                if (!DateTime.TryParse(chargeDateTime, out chargeTime))
                {
                    return(new CommandResult(ResultCode.ParameterError, "参数计费时间错误"));
                }
                if (chargeTime > DateTime.Now)
                {
                    return(new CommandResult(ResultCode.ParameterError, "计费时间大于系统当前时间"));
                }
                decimal paidD = 0;
                if (!decimal.TryParse(paid, out paidD))
                {
                    return(new CommandResult(ResultCode.ParameterError, "参数实付金额错误"));
                }
                int payModeI = 0;
                if (!int.TryParse(payMode, out payModeI))
                {
                    return(new CommandResult(ResultCode.ParameterError, "参数支付方式错误"));
                }
                #endregion

                #region 接口日志记录
                if (AppConifg.Current.Log)
                {
                    try
                    {
                        string log = string.Format("卡号:{0} 计费时间:{1} 实付金额:{2} 支付方式:{3} 费用说明:{4} 预留1:{5} 预留2:{6}"
                                                   , cardID
                                                   , chargeDateTime
                                                   , paid
                                                   , payMode
                                                   , memo
                                                   , reserve1
                                                   , reserve2);
                        Ralid.GeneralLibrary.LOG.FileLog.Log(AppConifg.Current.LogPath, "CardFeePay", log);
                    }
                    catch (Exception ex)
                    {
                        Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
                    }
                }
                #endregion

                #region 验证卡片信息
                //查找该卡号的卡片
                CardBll cardBll = new CardBll(AppConifg.Current.ParkingConnection);
                QueryResult <CardInfo> cResult = cardBll.GetCardByID(cardID);
                if (cResult.Result != ResultCode.Successful)
                {
                    return(new CommandResult(cResult.Result, "获取卡片信息失败"));
                }
                CardInfo card = cResult.QueryObject;
                if (card == null)
                {
                    return(new CommandResult(ResultCode.NoRecord, "此卡未登记"));
                }
                if (!card.IsInPark)
                {
                    return(new CommandResult(ResultCode.Fail, "此卡已出场"));
                }
                string msg = string.Empty;
                if (!ValidateCard(card, out msg))
                {
                    return(new CommandResult(ResultCode.Fail, msg));
                }
                if (card.LastDateTime > chargeTime)
                {
                    return(new CommandResult(ResultCode.ParameterError, "入场时间晚于计费时间"));
                }
                //获取卡片所在停车场信息
                EntranceBll  entranceBll = new EntranceBll(AppConifg.Current.ParkingConnection);
                EntranceInfo entrance    = entranceBll.GetEntranceInfo(card.LastEntrance).QueryObject;
                if (entrance == null)
                {
                    return(new CommandResult(ResultCode.NoRecord, "没有找到入场通道信息"));
                }
                ParkBll  parkBll = new ParkBll(AppConifg.Current.ParkingConnection);
                ParkInfo park    = parkBll.GetParkInfoByID(entrance.ParkID).QueryObject;
                if (park == null)
                {
                    return(new CommandResult(ResultCode.NoRecord, "没有找到停车场信息"));
                }
                //判断卡片合法性
                if (card.IsCardList && park.IsWriteCardMode && !card.OnlineHandleWhenOfflineMode)
                {
                    //写卡模式时,脱机处理的卡片名单不能缴费
                    return(new CommandResult(ResultCode.Fail, "该卡片为写卡处理卡片,不能进行在线收费"));
                }
                #endregion

                #region 获取费率和节假日
                SysParaSettingsBll ssb    = new SysParaSettingsBll(AppConifg.Current.ParkingConnection);
                TariffSetting      tariff = ssb.GetSetting <TariffSetting>();
                if (tariff == null)
                {
                    return(new CommandResult(ResultCode.Fail, "获取费率失败"));
                }
                TariffSetting.Current = tariff;
                HolidaySetting holiday = ssb.GetSetting <HolidaySetting>();
                if (holiday == null)
                {
                    return(new CommandResult(ResultCode.Fail, "获取节假日失败"));
                }
                HolidaySetting.Current = holiday;
                #endregion

                #region 判断是否已缴过费
                if (card.IsCompletedPaid && tariff.IsInFreeTime(card.PaidDateTime.Value, chargeTime))
                {
                    //已缴费,并且未过免费时间,不允许缴费
                    msg = string.Format("已缴费,请在{0}分钟内离场!", tariff.FreeTimeRemaining(card.PaidDateTime.Value, chargeTime));
                    return(new CommandResult(ResultCode.Fail, msg));
                }
                #endregion

                //生成卡片缴费记录
                CardPaymentInfo chargeRecord = CardPaymentInfoFactory.CreateCardPaymentRecord(park.ParkID, card, tariff, card.CarType, chargeTime);
                //将收费信息重新赋值
                chargeRecord.Paid     = paidD;
                chargeRecord.Discount = chargeRecord.Accounts - paidD;
                if (chargeRecord.Discount < 0)
                {
                    chargeRecord.Discount = 0;
                }
                chargeRecord.PaymentCode    = PaymentCode.Internet;
                chargeRecord.PaymentMode    = payModeI == 1 ? PaymentMode.WeChat : PaymentMode.Cash;
                chargeRecord.IsCenterCharge = true;
                chargeRecord.StationID      = string.Empty;
                chargeRecord.OperatorID     = string.Empty;
                if (!string.IsNullOrEmpty(memo))
                {
                    chargeRecord.Memo = memo;
                }
                if (chargeRecord.Memo == null)
                {
                    chargeRecord.Memo = string.Empty;
                }

                CommandResult result = cardBll.PayParkFee(chargeRecord);
                if (result.Result == ResultCode.Successful)
                {
                    //缴费成功,返回缴费后离场提示信息
                    msg = string.Format("缴费成功,请在{0}分钟内离场!", tariff.FreeTimeRemaining(chargeTime, DateTime.Now));
                }

                return(result);
            }
            catch (Exception ex)
            {
                Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
                string msg = string.Format("接口发生异常,异常信息:{0}", ex.Message);
                return(new CommandResult(ResultCode.InterfaceException, msg));
            }
        }
Exemplo n.º 18
0
        private void btnExportSetting_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(Resource1.FrmMain_ExportConfig, Resource1.FrmMain_Query, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }
            try
            {
                string path = System.IO.Path.Combine(Application.StartupPath, "MySetting.xml");
                POS.Model.MySetting     mysetting = new Model.MySetting();
                FrmWorkstationSelection frm       = new FrmWorkstationSelection();
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    mysetting.StationID = frm.SelectedWorkstation;
                    UserSetting us = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <UserSetting>();
                    if (us != null)
                    {
                        SetValue(mysetting, us);
                    }
                    KeySetting ks = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <KeySetting>();
                    if (ks != null)
                    {
                        SetValue(mysetting, ks);
                    }
                    TariffSetting ts = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <TariffSetting>();
                    if (ts != null)
                    {
                        SetValue(mysetting, ts);
                    }
                    HolidaySetting hs = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <HolidaySetting>();
                    if (hs != null)
                    {
                        SetValue(mysetting, hs);
                    }
                    List <OperatorInfo> opts = (new OperatorBll(AppSettings.CurrentSetting.ParkConnect)).GetAllOperators().QueryObjects;
                    if (opts != null)
                    {
                        SetValue(mysetting, opts);
                    }

                    XmlSerializer ser = new XmlSerializer(typeof(POS.Model.MySetting));
                    using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write))
                    {
                        ser.Serialize(stream, mysetting);
                    }
                    string remote = @"FlashDisk\RalidPos\MySetting.xml";
                    OpenNETCF.Desktop.Communication.RAPI rapi = new OpenNETCF.Desktop.Communication.RAPI();
                    if (rapi.DevicePresent)
                    {
                        rapi.Connect();
                        if (!rapi.Connected)
                        {
                            ShowMessage(Resource1.FrmMain_ConnectHandsetFail, Color.Red);
                            return;
                        }

                        rapi.CopyFileToDevice(path, remote, true);
                        rapi.Disconnect();
                        ShowMessage(Resource1.FrmMain_ExportConfigSuccess, Color.Black);
                    }
                    else
                    {
                        ShowMessage(Resource1.FrmMain_FindnotHandet, Color.Red);
                    }
                }
            }
            catch (Exception ex)
            {
                ShowMessage(ex.Message, Color.Red);
                Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
            }
        }
Exemplo n.º 19
0
        public static CardEventReport CreateExitEvent(CardInfo card, int parkID, int entranceID, string entranceName, ParkWorkMode workMode, Byte carType, TariffSetting ts, DateTime eventDateTime)
        {
            CardEventReport report = new CardEventReport();

            report.ID              = Guid.NewGuid();
            report.ParkID          = parkID;
            report.EventDateTime   = eventDateTime;
            report.EntranceID      = entranceID;
            report.SourceName      = entranceName;
            report.IsExitEvent     = true;
            report.CardID          = card.CardID;
            report.OwnerName       = card.OwnerName;
            report.Department      = card.Department;
            report.CardCarPlate    = card.CarPlate;
            report.CarPlate        = card.RegCarPlate;
            report.CardCertificate = card.CardCertificate;
            report.ListType        = card.ListType;
            report.CardType        = card.CardType;
            report.CarType         = carType;
            report.EventStatus     = CardEventStatus.Pending;
            report.LastDateTime    = card.LastDateTime;
            report.LastCarPlate    = card.LastCarPlate;
            report.LastEntrance    = card.LastEntrance;
            //report.CardPaymentInfo = CardPaymentInfoFactory.CreateCardPaymentRecord(card, ts, carType, eventDateTime);
            report.CardPaymentInfo             = CardPaymentInfoFactory.CreateCardPaymentRecord(report.ParkID, card, ts, carType, eventDateTime);
            report.Balance                     = card.Balance;
            report.ValidDate                   = card.ValidDate;
            report.OnlineHandleWhenOfflineMode = (card.OnlineHandleWhenOfflineMode || card.IsCarPlateList);//车牌名单时固定按在线处理
            report.ParkingStatus               = ParkingStatus.Out;
            report.UpdateFlag                  = true;
            report.WorkMode                    = workMode;
            report.FreeDateTime                = card.FreeDateTime;
            if (card.EnableHotelApp && !card.HotelCheckOut && card.IsInFreeTime(eventDateTime))
            {
                //如果启用了酒店应用,并且未退房,并且未过免费时间的,需要保留以下状态
                report.EnableHotelApp = card.EnableHotelApp;
                report.HotelCheckOut  = card.HotelCheckOut;
            }
            report.CardOptions = card.Options;
            return(report);
        }
Exemplo n.º 20
0
        public static CardPaymentInfo CreateCardPaymentRecord(int?parkID, CardInfo card, TariffSetting ts, Byte carType, DateTime chargeDateTime)
        {
            CardPaymentInfo cardPayment = new CardPaymentInfo();

            cardPayment.CardID          = card.CardID;
            cardPayment.OwnerName       = card.OwnerName;
            cardPayment.CardCertificate = card.CardCertificate;
            cardPayment.CarPlate        = card.IsCarPlateList ? card.CarPlate : card.LastCarPlate;//如果是车牌名单,车牌号码为名单车牌
            cardPayment.CardType        = card.CardType;
            cardPayment.CarType         = carType;
            cardPayment.EnterDateTime   = card.LastDateTime;
            cardPayment.ChargeDateTime  = chargeDateTime;

            //计算应收费用
            if (card.LastPayment != null)
            {
                cardPayment.LastTotalPaid     = card.LastPayment.TotalPaid;
                cardPayment.LastTotalDiscount = card.LastPayment.TotalDiscount;
                cardPayment.LastStationID     = card.LastPayment.StationID;
            }
            //如果卡片的已缴费用与收费记录不一致,以卡片的数据为准
            if (cardPayment.LastTotalFee != card.TotalPaidFee)
            {
                cardPayment.LastTotalPaid     = card.TotalPaidFee;
                cardPayment.LastTotalDiscount = 0;
                cardPayment.LastStationID     = string.Empty;
            }

            ParkAccountsInfo parkFee = ts.CalculateCardParkFee(parkID, card, carType, chargeDateTime);

            cardPayment.Accounts   = parkFee.Accounts;
            cardPayment.TariffType = parkFee.TariffType;

            cardPayment.ParkFee     = parkFee.ParkFee;
            cardPayment.PaymentCode = PaymentCode.Computer;

            //从入场时间截止本次收费时间的优惠金额
            int     currentWorkHour = 0;                                                            //本次优惠时数
            int     usedHour        = card.LastPayment != null ? card.LastPayment.DiscountHour : 0; //已使用的优惠时数
            decimal discountMoney   = ts.CalculateCardDiscountMoney(parkID, card, carType, chargeDateTime, usedHour, out currentWorkHour);

            //如果计算出的优惠金额大于应收费用时,优惠金额为应收费用
            cardPayment.Discount         = cardPayment.Accounts < discountMoney ? cardPayment.Accounts : discountMoney;
            cardPayment.DiscountHour     = usedHour + currentWorkHour; //累计已优惠时数=已使用优惠时数+本次优惠时数
            cardPayment.CurrDiscountHour = currentWorkHour;            //本次优惠时数

            //cardPayment.Discount = (discountMoney - cardPayment.LastTotalDiscount) > parkFee.Accounts ? parkFee.Accounts : (discountMoney - cardPayment.LastTotalDiscount) > 0 ? (discountMoney - cardPayment.LastTotalDiscount) : 0; //本次折扣额 = 【入场~收费时间】优惠金额-累计折扣
            //cardPayment.DiscountHour = currentWorkHour; //累计已优惠时数=计算优惠时数
            //if (card.LastPayment != null)
            //    cardPayment.CurrDiscountHour = cardPayment.DiscountHour - card.LastPayment.CurrHasPaidDiscountHour;
            //else
            //    cardPayment.CurrDiscountHour = currentWorkHour;


            if (card.EnableHotelApp && card.FreeDateTime.HasValue)
            {
                cardPayment.Memo = string.Format("{0} {1};", Resouce.Resource1.CardPaymentInfoFactory_Free, card.FreeDateTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
            }

            if (card.DiscountHour > 0 && card.PreferentialTime.HasValue)
            {
                //yyyy-MM-dd HH:mm:ss 优惠 n 小时
                cardPayment.Memo += string.Format("{0} {1} {2} {3};", card.PreferentialTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), Resouce.Resource1.Preferential, card.DiscountHour, Resouce.Resource1.Hour);
            }

            return(cardPayment);
        }
Exemplo n.º 21
0
        public static CardEventReport CreateExitEvent(CardInfo card, int parkID, int entranceID, string entranceName, ParkWorkMode workMode, Byte carType, TariffSetting ts, DateTime eventDateTime)
        {
            CardEventReport report = new CardEventReport();

            report.ID                          = Guid.NewGuid();
            report.ParkID                      = parkID;
            report.EventDateTime               = eventDateTime;
            report.EntranceID                  = entranceID;
            report.SourceName                  = entranceName;
            report.IsExitEvent                 = true;
            report.CardID                      = card.CardID;
            report.OwnerName                   = card.OwnerName;
            report.CardCarPlate                = card.CarPlate;
            report.CarPlate                    = card.RegCarPlate;
            report.CardCertificate             = card.CardCertificate;
            report.CardType                    = card.CardType;
            report.CarType                     = carType;
            report.EventStatus                 = CardEventStatus.Pending;
            report.LastDateTime                = card.LastDateTime;
            report.LastCarPlate                = card.LastCarPlate;
            report.CardPaymentInfo             = CardPaymentInfoFactory.CreateCardPaymentRecord(card, ts, carType, eventDateTime);
            report.Balance                     = card.Balance;
            report.ValidDate                   = card.ValidDate;
            report.OnlineHandleWhenOfflineMode = card.OnlineHandleWhenOfflineMode;
            report.ParkingStatus               = ParkingStatus.Out;
            report.UpdateFlag                  = true;
            report.WorkMode                    = workMode;
            return(report);
        }
Exemplo n.º 22
0
        private void InitTariffGridRow(DataGridViewRow row, CardType cardType, CarType carType, TariffSetting ts)
        {
            TariffBase tariff = null;

            row.Cells["colCardType"].Value = cardType.Name;
            row.Cells["colCardType"].Tag   = cardType.ID;

            row.Cells["colCarType"].Value = carType.Description;
            row.Cells["colCarType"].Tag   = carType.ID;

            tariff = ts.GetAloneTariff(ParkID, cardType.ID, carType.ID, TariffType.Normal);
            row.Cells["colGeneral"].Value = (tariff != null) ? tariff.ToString() : "N/A";
            row.Cells["colGeneral"].Tag   = (tariff != null) ? tariff : null;

            tariff = ts.GetAloneTariff(ParkID, cardType.ID, carType.ID, TariffType.Holiday);
            row.Cells["colHoliday"].Value = (tariff != null) ? tariff.ToString() : "N/A";
            row.Cells["colHoliday"].Tag   = (tariff != null) ? tariff : null;

            tariff = ts.GetAloneTariff(ParkID, cardType.ID, carType.ID, TariffType.InnerRoom);
            row.Cells["colInnerRoom"].Value = (tariff != null) ? tariff.ToString() : "N/A";
            row.Cells["colInnerRoom"].Tag   = (tariff != null) ? tariff : null;

            tariff = ts.GetAloneTariff(ParkID, cardType.ID, carType.ID, TariffType.HolidayAndInnerRoom);
            row.Cells["colHolidayAndInnerRoom"].Value = (tariff != null) ? tariff.ToString() : "N/A";
            row.Cells["colHolidayAndInnerRoom"].Tag   = (tariff != null) ? tariff : null;
        }
Exemplo n.º 23
0
 private void SetValue(POS.Model.MySetting mysetting, TariffSetting ts)
 {
     if (ts.TariffOption != null)
     {
         mysetting.FreeTimeAfterPay = ts.TariffOption.FreeTimeAfterPay;
     }
     if (ts.TariffArray != null && ts.TariffArray.Count > 0)
     {
         foreach (TariffBase tb in ts.TariffArray)
         {
             if (tb is TariffOfDixiakongjian)
             {
                 if (mysetting.TariffOfDixiakongjians == null)
                 {
                     mysetting.TariffOfDixiakongjians = new List <TariffOfDixiakongjian>();
                 }
                 mysetting.TariffOfDixiakongjians.Add(tb as TariffOfDixiakongjian);
             }
             else if (tb is TariffOfGuanZhou)
             {
                 if (mysetting.TariffOfGuanZhous == null)
                 {
                     mysetting.TariffOfGuanZhous = new List <TariffOfGuanZhou>();
                 }
                 mysetting.TariffOfGuanZhous.Add(tb as TariffOfGuanZhou);
             }
             else if (tb is TariffOfLimitation)
             {
                 if (mysetting.TariffOfLimitations == null)
                 {
                     mysetting.TariffOfLimitations = new List <TariffOfLimitation>();
                 }
                 mysetting.TariffOfLimitations.Add(tb as TariffOfLimitation);
             }
             else if (tb is TariffOfTurningLimited)
             {
                 if (mysetting.TariffOfTurningLimiteds == null)
                 {
                     mysetting.TariffOfTurningLimiteds = new List <TariffOfTurningLimited>();
                 }
                 mysetting.TariffOfTurningLimiteds.Add(tb as TariffOfTurningLimited);
             }
             else if (tb is TariffOfTurning)
             {
                 if (mysetting.TariffOfTurnings == null)
                 {
                     mysetting.TariffOfTurnings = new List <TariffOfTurning>();
                 }
                 mysetting.TariffOfTurnings.Add(tb as TariffOfTurning);
             }
             else if (tb is TariffPerDay)
             {
                 if (mysetting.TariffPerDays == null)
                 {
                     mysetting.TariffPerDays = new List <TariffPerDay>();
                 }
                 mysetting.TariffPerDays.Add(tb as TariffPerDay);
             }
             else if (tb is TariffPerTime)
             {
                 if (mysetting.TariffPerTimes == null)
                 {
                     mysetting.TariffPerTimes = new List <TariffPerTime>();
                 }
                 mysetting.TariffPerTimes.Add(tb as TariffPerTime);
             }
         }
     }
 }
Exemplo n.º 24
0
        public static CardEventDetailReport CreateExitEvent(CardInfo card, EntranceInfo entrance, TariffSetting ts)
        {
            CardEventDetailReport report = new CardEventDetailReport();
            DateTime eventDateTime       = DateTime.Now;

            report.ParkID   = entrance.ParkID;
            report.Address  = entrance.Address;
            report.Entrance = entrance;
            report.CardType = card.CardType;
            report.CarType  = card.CarType;
            if (!card.CardType.IsMonthCard)
            {
                ParkAccountsInfo parkFee = TariffSetting.Current.CalculateCardParkFee(card, card.CarType, eventDateTime);
                report.Accounts   = parkFee.Accounts;
                report.TariffType = parkFee.TariffType;
            }
            report.CardID        = card.CardID;
            report.EventDateTime = eventDateTime;
            report.EventStatus   = 0;
            report.LastAddress   = card.LastAddress;
            report.LastDateTime  = card.LastDateTime;
            report.CarPlate      = card.LastCarPlate;
            if (card.CardType.IsPrepayCard)
            {
                if (card.Balance < report.Accounts) //余额不足,当成临时卡收费
                {
                    report.ParkingStatus = card.ParkingStatus | ParkingStatus.BIT_AsTempCard;
                    report.Balance       = card.Balance;
                }
                else
                {
                    report.ParkingStatus = card.ParkingStatus;
                    report.Balance       = card.Balance - report.Accounts;
                }
            }
            else
            {
                report.ParkingStatus = card.ParkingStatus;
            }
            return(report);
        }