private CommandResult SaveCardPayment(PaymentMode paymentMode) { CommandResult result = null; _ChargeRecord.PaymentMode = paymentMode; _ChargeRecord.OperatorID = OperatorInfo.CurrentOperator.OperatorName; _ChargeRecord.StationID = WorkStationInfo.CurrentStation.StationName; _ChargeRecord.Paid = this.txtPaid.DecimalValue; _ChargeRecord.Discount = _ChargeRecord.Accounts - this.txtPaid.DecimalValue; _ChargeRecord.IsCenterCharge = true; _ChargeRecord.Memo = this.txtMemo.Text; CardBll cbll = new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect); bool both = WorkStationInfo.CurrentStation.NeedBothDatabaseUpdate; bool offlineHandleCard = AppSettings.CurrentSetting.EnableWriteCard && _cardInfo != null && !_cardInfo.OnlineHandleWhenOfflineMode; result = cbll.PayParkFee(_cardInfo, _ChargeRecord, AppSettings.CurrentSetting.CurrentStandbyConnect, both, offlineHandleCard); if (result.Result != ResultCode.Successful && offlineHandleCard) { //与主数据库通信故障时,脱机模式时按脱机模式处理的卡片,收费信息写入本地数据库,待通信正在时,上传到主数据库 LDB_CardPaymentRecordBll ldb_cbll = new LDB_CardPaymentRecordBll(LDB_AppSettings.Current.LDBConnect); result = ldb_cbll.PayParkFee(_cardInfo, _ChargeRecord); } //写卡模式需要将收费信息写入卡片扇区 if (result.Result == ResultCode.Successful && offlineHandleCard) { CardOperationManager.Instance.WriteCardLoop(_cardInfo); } return(result); }
private CommandResult SaveCardPayment(PaymentMode paymentMode) { CommandResult result = null; _ChargeRecord.PaymentMode = paymentMode; _ChargeRecord.OperatorID = OperatorInfo.CurrentOperator.OperatorName; _ChargeRecord.StationID = WorkStationInfo.CurrentStation.StationName; _ChargeRecord.Paid = this.txtPaid.DecimalValue; _ChargeRecord.Discount = _ChargeRecord.Accounts - this.txtPaid.DecimalValue; _ChargeRecord.IsCenterCharge = true; _ChargeRecord.Memo = this.txtMemo.Text; CardBll cbll = new CardBll(AppSettings.CurrentSetting.ParkConnect); result = cbll.PayParkFee(_cardInfo, _ChargeRecord); //写卡模式需要将收费信息写入卡片扇区 if (AppSettings.CurrentSetting.EnableWriteCard && _cardInfo != null && !_cardInfo.OnlineHandleWhenOfflineMode && result.Result == ResultCode.Successful) { CardOperationManager.Instance.WriteCardLoop(_cardInfo); } return(result); }
private CommandResult SaveCardPayment(CardPaymentInfo cardPayment, PaymentMode paymentMode) { CommandResult result = null; cardPayment.Paid = txtPaid.DecimalValue; cardPayment.Discount = cardPayment.Accounts - cardPayment.Paid; cardPayment.Memo = txtMemo.Text; cardPayment.PaymentMode = paymentMode; cardPayment.OperatorID = OperatorInfo.CurrentOperator.OperatorName; cardPayment.StationID = WorkStationInfo.CurrentStation.StationName; cardPayment.IsCenterCharge = false; CardBll cbll = new CardBll(AppSettings.CurrentSetting.ParkConnect); result = cbll.PayParkFee(_cardInfo, cardPayment); //写卡模式并且不是按在线模式处理时需要将收费信息写入卡片扇区 if (AppSettings.CurrentSetting.EnableWriteCard && result.Result == ResultCode.Successful && !_processingEvent.OnlineHandleWhenOfflineMode) { _cardInfo.IsInPark = false;//标记已出场 CardOperationManager.Instance.WriteCardLoop(_cardInfo); } return(result); }
private CommandResult SaveCardPayment(CardPaymentInfo cardPayment, PaymentMode paymentMode) { CommandResult result = null; cardPayment.PaymentMode = paymentMode; cardPayment.OperatorID = OperatorInfo.CurrentOperator.OperatorName; cardPayment.StationID = WorkStationInfo.CurrentStation.StationName; cardPayment.IsCenterCharge = true; CardBll cbll = new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect); result = cbll.PayParkFee(null, cardPayment, AppSettings.CurrentSetting.CurrentStandbyConnect, false, false); return(result); }
private CommandResult SaveCardPayment(CardPaymentInfo cardPayment, PaymentMode paymentMode) { CommandResult result = null; cardPayment.Paid = txtPaid.DecimalValue; cardPayment.Discount = cardPayment.Accounts - cardPayment.Paid; cardPayment.Memo = txtMemo.Text; cardPayment.PaymentMode = paymentMode; cardPayment.OperatorID = OperatorInfo.CurrentOperator.OperatorName; cardPayment.StationID = WorkStationInfo.CurrentStation.StationName; cardPayment.IsCenterCharge = false; CardBll cbll = new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect); bool both = WorkStationInfo.CurrentStation.NeedBothDatabaseUpdate; bool offlineHandleCard = AppSettings.CurrentSetting.EnableWriteCard && _cardInfo != null && !_processingEvent.OnlineHandleWhenOfflineMode && (paymentMode == PaymentMode.Cash || paymentMode == PaymentMode.Prepay); result = cbll.PayParkFee(_cardInfo, cardPayment, AppSettings.CurrentSetting.CurrentStandbyConnect, both, offlineHandleCard); if (result.Result != ResultCode.Successful && offlineHandleCard) { //与主数据库通信故障时,脱机模式时按脱机模式处理的卡片,收费信息写入本地数据库,待通信正在时,上传到主数据库 _cardInfo.UpdateFlag = false; LDB_CardPaymentRecordBll ldb_cbll = new LDB_CardPaymentRecordBll(LDB_AppSettings.Current.LDBConnect); result = ldb_cbll.PayParkFee(_cardInfo, cardPayment); } //写卡模式并且不是按在线模式处理时需要将收费信息写入卡片扇区 if (result.Result == ResultCode.Successful && offlineHandleCard) { _cardInfo.IsInPark = false;//标记已出场 CardOperationManager.Instance.WriteCardLoop(_cardInfo); } return(result); }
protected override void OnCardPermitted(OfflineCardReadReport report) { EntranceBase entrance = GetEntrance(report.EntranceID); if (entrance == null) { return; } if (entrance.ProcessingEvent != null && entrance.ProcessingEvent.CardID == report.CardID) { if (entrance.ProcessingEvent.CardType.IsPrepayCard && entrance.ProcessingEvent.CardPaymentInfo != null && entrance.ProcessingEvent.CardPaymentInfo.Accounts > 0 && entrance.ProcessingCard.Balance >= entrance.ProcessingEvent.CardPaymentInfo.Accounts ) //储值卡扣除余额 { entrance.ProcessingEvent.CardPaymentInfo.Paid = entrance.ProcessingEvent.CardPaymentInfo.Accounts; entrance.ProcessingEvent.CardPaymentInfo.OperatorID = string.Empty; entrance.ProcessingEvent.CardPaymentInfo.StationID = string.Empty; entrance.ProcessingEvent.CardPaymentInfo.PaymentMode = PaymentMode.Prepay; CardBll cpb = new CardBll(AppSettings.CurrentSetting.ParkConnect); cpb.PayParkFee(entrance.ProcessingEvent.CardPaymentInfo); entrance.ProcessingEvent.Balance = entrance.ProcessingEvent.Balance - entrance.ProcessingEvent.CardPaymentInfo.Accounts; entrance.ProcessingCard.Balance = entrance.ProcessingEvent.Balance; } CardEventReport cardEvent = entrance.ProcessingEvent.Clone(); cardEvent.EventStatus = CardEventStatus.Valid; cardEvent.OperatorID = string.Empty; cardEvent.StationID = string.Empty; CardBll cbll = new CardBll(AppSettings.CurrentSetting.ParkConnect); cbll.SaveCardAndEvent(entrance.ProcessingCard, cardEvent); RaiseCardEventReporting(cardEvent); entrance.ProcessingEvent = null; } }
/// <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)); } }