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); }
/// <summary> /// 读取到卡号处理 /// </summary> /// <param name="cardID">卡号</param> /// <param name="info">从卡片扇区数据中读取到的卡片信息</param> private void ReadCardHandler(CardInfo card) { string msg = string.Empty; if (card.OnlineHandleWhenOfflineMode) { MessageBox.Show("卡片不能写入,请到停车场收费处缴费"); this.timer1.Enabled = true; return; //卡片只能在线处理,返回 } if (!card.IsInPark) { MessageBox.Show("卡片已出场"); this.timer1.Enabled = true; return; } if (card.LastDateTime > DateTime.Now) { MessageBox.Show("入场时间大于当前时间"); this.timer1.Enabled = true; return; } if (MySetting.Current.GetTariff(card.CardType.ID, card.CarType) == null) { MessageBox.Show("非收费卡,可直接出场"); this.timer1.Enabled = true; return; } _Card = card; _ChargeRecord = CardPaymentInfoFactory.CreateCardPaymentRecord(card, MySetting.Current, card.CarType, DateTime.Now); ShowCardPaymentInfo(_ChargeRecord); }
private void CarType_Selected(object sender, EventArgs e) { if (_ChargeRecord != null && CarTypeSetting.Current[carTypePanel1.SelectedCarType] != null) { _ChargeRecord = CardPaymentInfoFactory.CreateCardPaymentRecord(_cardInfo, TariffSetting.Current, carTypePanel1.SelectedCarType, _ChargeRecord.ChargeDateTime); ShowCardPaymentInfo(_ChargeRecord); } }
private void parkCombobox1_SelectedIndexChanged(object sender, EventArgs e) { if (_cardInfo != null) { _ChargeRecord = CardPaymentInfoFactory.CreateCardPaymentRecord(this.parkCombobox1.SelectedParkID, _cardInfo, TariffSetting.Current, _cardInfo.CarType, DateTime.Now); ShowCardPaymentInfo(_ChargeRecord); } }
private void parkCombobox1_SelectedIndexChanged(object sender, EventArgs e) { if (LossRestoreCard != null) { _ParkPayment = CardPaymentInfoFactory.CreateCardPaymentRecord(this.parkCombobox1.SelectedParkID, LossRestoreCard, TariffSetting.Current, LossRestoreCard.CarType, DateTime.Now); txtParkFee.DecimalValue = _ParkPayment.Accounts; } }
/// <summary> /// 读取到卡号处理 /// </summary> /// <param name="cardID">卡号</param> /// <param name="info">从卡片扇区数据中读取到的卡片信息</param> private void ReadCardIDHandler(string cardID, CardInfo info) { txtCardID.TextChanged -= txtCardID_TextChanged; this.txtCardID.Text = cardID; this.txtCardID.ReadOnly = true; string msg = string.Empty; CardInfo card = _CardBll.GetCardDetail(this.txtCardID.Text); if (card == null) { msg = CardInvalidDescripition.GetDescription(EventInvalidType.INV_UnRegister); } else if (AppSettings.CurrentSetting.EnableWriteCard && !card.OnlineHandleWhenOfflineMode && !CardDateResolver.Instance.CopyCardDataToCard(card, info)) { //写卡模式时,卡片信息从扇区数据中获取 msg = Resource1.FrmCardCenterCharge_CardDataErr; } else if (!ValidateCard(card, out msg)) { //卡片无效 } else if (TariffSetting.Current.GetTariff(card.CardType.ID, card.CarType) == null) { //msg = Resource1.FrmCardPaying_NotTempCard; msg = Resource1.FrmCardCenterCharge_NotPaymentCard; } else if (!card.IsInPark) { msg = CardInvalidDescripition.GetDescription(EventInvalidType.INV_StillOut); } else if (card.LastDateTime > DateTime.Now) { msg = CardInvalidDescripition.GetDescription(EventInvalidType.INV_WrongInTime); } else { _cardInfo = card; _ChargeRecord = CardPaymentInfoFactory.CreateCardPaymentRecord(_cardInfo, TariffSetting.Current, _cardInfo.CarType, DateTime.Now); ShowCardPaymentInfo(_ChargeRecord); } if (!string.IsNullOrEmpty(msg)) { if (_ChargeLed != null) { _ChargeLed.DisplayMsg(msg); } if (AppSettings.CurrentSetting.EnableTTS) { TTSSpeech.Instance.Speek(msg); } ClearInput(); this.txtCardID.Text = cardID; this.txtMemo.Text = msg; } txtCardID.TextChanged += txtCardID_TextChanged; }
private void carTypePanel1_CarTypeSelectedChanged(object sender, EventArgs e) { if (_ChargeRecord != null && CarTypeSetting.Current[carTypePanel1.SelectedCarType] != null) { //_ChargeRecord = CardPaymentInfoFactory.CreateCardPaymentRecord(_cardInfo, TariffSetting.Current, carTypePanel1.SelectedCarType, _ChargeRecord.ChargeDateTime); _ChargeRecord = CardPaymentInfoFactory.CreateCardPaymentRecord(this.parkCombobox1.SelectedParkID, _cardInfo, TariffSetting.Current, carTypePanel1.SelectedCarType, _ChargeRecord.ChargeDateTime); ShowCardPaymentInfo(_ChargeRecord); } }
private void CarType_Selected(object sender, EventArgs e) { if (_ChargeRecord != null && CarTypeSetting.Current[carTypePanel1.SelectedCarType] != null) { //专门针对长隆停车场设置一种“转会员卡"车型,选择“转会员卡"车型时必须重新刷一张会员卡才能时行这个操作,并在收费说明中写入“转会员卡+会员卡号" //这个功能采用硬编码 if (CarTypeSetting.Current[carTypePanel1.SelectedCarType].Description == _ToVipCard) { FrmVipCardReader frm = new FrmVipCardReader(); if (frm.ShowDialog() == DialogResult.OK) { string cardid = frm.VipCardID; if (DataBaseConnectionsManager.Current.MasterConnected || DataBaseConnectionsManager.Current.StandbyConnected) { CardInfo card = null; if (DataBaseConnectionsManager.Current.MasterConnected) { card = (new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect)).GetCardByID(cardid).QueryObject; } else { card = (new CardBll(AppSettings.CurrentSetting.CurrentStandbyConnect)).GetCardByID(cardid).QueryObject; } if (card != null && card.CardType.Name == _VipCard) { _TempCardID = _ChargeRecord.CardID; _VipCardID = cardid; } else { MessageBox.Show(string.Format("卡号为 {0} 的卡不存在或者不是会员卡,请刷会员卡", cardid), Resource1.Form_Alert); return; } } else { MessageBox.Show("数据库连接失败!"); return; } } else { return; } } //end 转会员卡功能 _ChargeRecord = CardPaymentInfoFactory.CreateCardPaymentRecord(_cardInfo, TariffSetting.Current, carTypePanel1.SelectedCarType, _ChargeRecord.ChargeDateTime); ShowCardPaymentInfo(_ChargeRecord); } }
/// <summary> /// 读取到卡号处理 /// </summary> /// <param name="cardID">卡号</param> /// <param name="info">从卡片扇区数据中读取到的卡片信息</param> private void ReadCardIDHandler(string cardID, CardInfo info) { this.txtCardID.Text = cardID; this.txtCardID.ReadOnly = true; string msg = string.Empty; CardInfo card = info; if (card == null) { msg = Resource1.FrmCardCenterCharge_CardDataErr; } else if (!ValidateCard(card, out msg)) { //卡片无效 } else if (TariffSetting.Current.GetTariff(card.CardType.ID, card.CarType) == null) { msg = Resource1.FrmCardCenterCharge_NotPaymentCard; } else if (!card.IsInPark) { msg = CardInvalidDescripition.GetDescription(EventInvalidType.INV_StillOut); } else if (card.LastDateTime > DateTime.Now) { msg = CardInvalidDescripition.GetDescription(EventInvalidType.INV_WrongInTime); } else { _cardInfo = card; _ChargeRecord = CardPaymentInfoFactory.CreateCardPaymentRecord(_cardInfo, TariffSetting.Current, _cardInfo.CarType, DateTime.Now); _ChargeRecord.CarPlate = _cardInfo.CarPlate; ShowCardPaymentInfo(_ChargeRecord); } if (!string.IsNullOrEmpty(msg)) { if (_ChargeLed != null) { _ChargeLed.DisplayMsg(msg); } if (AppSettings.CurrentSetting.EnableTTS) { TTSSpeech.Instance.Speek(msg); } ClearInput(); this.txtCardID.Text = cardID; this.txtMemo.Text = msg; this.eventList.InsertMessage(msg); } }
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); }
private void ShowCardInfo(CardInfo info) { string caption = null; if (LossRestoreCard != null) { this.ucCardInfo.Card = LossRestoreCard; if (LossRestoreCard.Status == CardStatus.Loss) { caption = Resources.Resource1.FrmCardLostRestore_Restore; this.txtCardCost.Enabled = false; this.comPaymentMode.Enabled = false; } else { caption = Resources.Resource1.FrmCardLostRestore_Lost; this.txtCardCost.Enabled = true; this.comPaymentMode.Enabled = true; } this.Text = caption; this.groupBox1.Text = caption; if (LossRestoreCard.Status != CardStatus.Loss && LossRestoreCard.IsInPark) { //EntranceBll eBll = new EntranceBll(AppSettings.CurrentSetting.ParkConnect); //EntranceInfo eInfo = eBll.GetEntranceInfo(LossRestoreCard.LastEntrance).QueryObject; //int parkID = 0; //if (eInfo != null) // parkID = eInfo.ParkID; //this.parkCombobox1.SelectedParkID = parkID; //_ParkPayment = CardPaymentInfoFactory.CreateCardPaymentRecord(LossRestoreCard, TariffSetting.Current, LossRestoreCard.CarType, DateTime.Now); //_ParkPayment = CardPaymentInfoFactory.CreateCardPaymentRecord(this.parkCombobox1.SelectedParkID,LossRestoreCard, TariffSetting.Current, LossRestoreCard.CarType, DateTime.Now); _ParkPayment = CardPaymentInfoFactory.CreateCardPaymentRecord(null, LossRestoreCard, TariffSetting.Current, LossRestoreCard.CarType, DateTime.Now); txtParkFee.DecimalValue = _ParkPayment.Accounts; chkPayParkFee.Enabled = true; chkPayParkFee.Checked = true; } if (!info.IsCardList) { //不是卡片名单时,不需要进行写卡 this.chkWriteCard.Checked = false; this.chkWriteCard.Enabled = false; } } }
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); }
private void FrmCardLostRestore_Load(object sender, EventArgs e) { this.chkWriteCard.Checked = AppSettings.CurrentSetting.EnableWriteCard; //写卡模式时默认选中 this.chkWriteCard.Visible = AppSettings.CurrentSetting.EnableWriteCard; //写卡模式时显示 this.comPaymentMode.Init(); this.comPaymentMode.SelectedPaymentMode = PaymentMode.Cash; this.ucCardInfo.Init(); this.ucCardInfo.UseToShow(); ShowCardInfo(LossRestoreCard); if (LossRestoreCard.Status != CardStatus.Loss && LossRestoreCard.IsInPark) { _ParkPayment = CardPaymentInfoFactory.CreateCardPaymentRecord(LossRestoreCard, TariffSetting.Current, LossRestoreCard.CarType, DateTime.Now); txtParkFee.DecimalValue = _ParkPayment.Accounts; chkPayParkFee.Enabled = true; chkPayParkFee.Checked = true; } if (AppSettings.CurrentSetting.EnableWriteCard) { CardReaderManager.GetInstance(UserSetting.Current.WegenType).PushCardReadRequest(CardReadHandler); } }
/// <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)); } }
/// <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)); } }