/// <summary> /// 卡片挂失,除了收取了卡片工本费还收取了卡片在场内的停车费用,并把卡片置为出场 /// </summary> /// <param name="info"></param> /// <param name="reason"></param> /// <param name="lostCardCost"></param> /// <param name="paymode"></param> /// <param name="parkFee"></param> /// <returns></returns> public CommandResult CardLoss(CardInfo info, string reason, decimal lostCardCost, PaymentMode paymode, CardPaymentInfo parkFee) { string op = OperatorInfo.CurrentOperator.OperatorName; string station = WorkStationInfo.CurrentStation.StationName; IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri); CardLostRestoreRecord record = new CardLostRestoreRecord { CardID = info.CardID, OwnerName = info.OwnerName, CardCertificate = info.CardCertificate, CarPlate = info.CarPlate, CardStatus = (byte)info.Status, //保存卡片的原有卡状态 LostDateTime = DateTime.Now, LostOperator = op, LostStation = station, LostMemo = reason, LostCardCost = lostCardCost, PaymentMode = paymode }; ICardLostRestoreRecordProvider lostProvider = ProviderFactory.Create <ICardLostRestoreRecordProvider>(_RepoUri); lostProvider.Insert(record, unitWork); if (parkFee != null) { parkFee.OperatorID = op; parkFee.StationID = station; parkFee.PaymentMode = paymode; parkFee.Memo = "卡片挂失"; ICardPaymentRecordProvider icpp = ProviderFactory.Create <ICardPaymentRecordProvider>(_RepoUri); icpp.Insert(parkFee, unitWork); } //卡片置为挂失并出场 CardInfo original = info.Clone(); info.Status = CardStatus.Loss; info.ParkingStatus = ParkingStatus.Out; ICardProvider icp = ProviderFactory.Create <ICardProvider>(_RepoUri); icp.Update(info, original, unitWork); return(unitWork.Commit()); }
///// <summary> ///// 卡片出内车场费用后的卡片信息(将费用累加到累计停车费用) ///// </summary> ///// <param name="info">卡片</param> ///// <param name="ts">费率</param> ///// <param name="carType">车型</param> ///// <param name="chargeDateTime">缴费时间</param> ///// <returns></returns> //private void CardPayNestedParkFee(CardInfo card, TariffSetting ts, Byte carType, DateTime chargeDateTime) //{ // ParkAccountsInfo parkFee = ts.CalculateCardNestedParkFee(card, carType, chargeDateTime); // ////不产生费用的,不记录缴费时间和累计停车费用,只更新内车场累计停车时间 // //if (parkFee.Accounts > 0) // //{ // // card.TotalFee += parkFee.Accounts; // // card.IsIndoorPaid = true;//更新内车场缴费标识 // // card.PaidDateTime = chargeDateTime;//记录缴费时间 // //} // card.TotalFee += parkFee.Accounts; // if (card.IsIndoorPaid && ts.IsInFreeTime(card.PaidDateTime.Value, chargeDateTime)) // { // //已缴费,并且处于缴费后免费时间的,不记录缴费时间 // //(防止下面这种情况出现:中央收费后设置允许15分钟内可以免费出场,则有些车主在入场后每隔15分钟去刷一次卡交费, // //这样出场时就不会产生费用) // } // else // { // card.PaidDateTime = chargeDateTime;//记录缴费时间 // } // card.IsInNestedPark = false ;//出内车场状态 // card.IsIndoorPaid = true;//更新内车场缴费标识 // card.UpdateIndoorTimeInterval(chargeDateTime);//更新内车场累计停车时间 //} ///// <summary> ///// 卡片进入内车场 ///// </summary> ///// <param name="info">卡片</param> ///// <param name="enterDateTime">进入时间</param> ///// <returns>进行后的卡片信息</returns> //private void CardEnterNestedPark(CardInfo info, DateTime enterDateTime) //{ // info.IsIndoorPaid = false ;//清除内车场缴费标识 // info.IsInNestedPark = true; // info.IndoorInDateTime = enterDateTime; //} #endregion #region 公共方法 ///// <summary> ///// 更新卡片写卡模式的相关数据(包括卡格式版本、室内停车场的进入时间、 ///// 室内停车场累计停车时间、缴费时间、当前车场已收的停车费用、累计停车费用、停车状态等) ///// </summary> ///// <param name="info"></param> ///// <returns></returns> //public CommandResult UpdateOffLineCardData(CardInfo info) //{ // CardInfo original = _Provider.GetByID(info.CardID).QueryObject; // if (original != null) // { // CardInfo card = original.Clone(); // //只更新写卡模式相关的属性 // card.CardVersion = info.CardVersion; // card.IndoorInDateTime = info.IndoorInDateTime; // card.IndoorTimeInterval = info.IndoorTimeInterval; // card.PaidDateTime = info.PaidDateTime; // card.ParkFee = info.ParkFee; // card.TotalFee = info.TotalFee; // //收费时需要更停车状态 // card.ParkingStatus = info.ParkingStatus; // return _Provider.Update(card, original); // } // return new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord)); //} /// <summary> /// 删除卡片最近的一条缴费记录 /// </summary> /// <param name="info"></param> /// <returns></returns> public CommandResult DeleteLastPayment(CardInfo info) { if (info.LastPayment != null) { CardInfo card = info.Clone(); CardPaymentInfo paymentInfo = info.LastPayment; //CardPaymentInfo record = null; IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri); ICardPaymentRecordProvider recordProvider = ProviderFactory.Create <ICardPaymentRecordProvider>(_RepoUri); ////重新设置卡片费用信息 ////card.TotalFee += paymentInfo.Paid + paymentInfo.Discount;//加上删除的收费费用和折扣 //if (!string.IsNullOrEmpty(paymentInfo.LastStationID) // || paymentInfo.LastTotalPaid != 0 // || paymentInfo.LastTotalDiscount != 0) //{ // //有上上次的缴费记录 // //先查找卡片是否有多条缴费记录 // CardPaymentRecordSearchCondition con = new CardPaymentRecordSearchCondition(); // con.CardID = card.CardID; // con.EnterDateTime = card.LastDateTime; // List<CardPaymentInfo> records = recordProvider.GetItems(con).QueryObjects; // if (records.Count > 1)//有多条缴费记录 // { // records = (from r in records // orderby r.ChargeDateTime descending // select r).ToList(); // record = records[1];//获取第二近的缴费记录 // } //} //if (record != null) //{ // //删除的记录的车场停车费用比上一条记录的停车费用多,说明两条记录之间有费用产生 // if (paymentInfo.ParkFee > record.ParkFee) // { // //如果两条记录相隔缴费时间内有产生费用,累计费用需要减去产生的费用 // card.TotalFee -= paymentInfo.ParkFee - record.ParkFee; // card.ParkFee = record.ParkFee;//重新设置外车场费用 // } // card.PaidDateTime = record.ChargeDateTime;//重新设置收费时间 // card.IsPaid = true; //} //else //{ // //没有上上次的缴费记录 // card.TotalFee -= paymentInfo.Accounts;//减去应缴费用 // card.TotalFee = card.TotalFee < 0 ? 0 : card.TotalFee; // card.ParkFee = 0; // card.IsPaid = false;//设置为未缴费 // card.PaidDateTime = null; //} //已缴费用减去记录收取的费用和折扣费用 card.TotalPaidFee -= paymentInfo.Paid + paymentInfo.Discount; if (card.TotalPaidFee < 0) { card.TotalPaidFee = 0; } _Provider.Update(card, info, unitWork); recordProvider.Delete(paymentInfo); CommandResult result = unitWork.Commit(); if (result.Result == ResultCode.Successful) { //删除成功,更新卡片信息 //info.ParkingStatus = card.ParkingStatus; //info.TotalFee = card.TotalFee; //info.PaidDateTime = card.PaidDateTime; //info.ParkFee = card.ParkFee; info.TotalPaidFee = card.TotalPaidFee; } return(result); } return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); }
/// <summary> /// 操作员结算 /// </summary> /// <param name="opt"></param> /// <returns></returns> public CommandResult Settle(OperatorSettleLog opt) { IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri); IOperatorLogProvider ip = ProviderFactory.Create <IOperatorLogProvider>(_RepoUri); ip.Insert(opt, unitWork); if (opt.PaymentRecords != null && opt.PaymentRecords.Count > 0) { ICardPaymentRecordProvider provider = ProviderFactory.Create <ICardPaymentRecordProvider>(_RepoUri); foreach (CardPaymentInfo record in opt.PaymentRecords) { CardPaymentInfo original = record.Clone(); record.SettleDateTime = opt.SettleDateTime; provider.Update(record, original, unitWork); } } if (opt.ReleaseRecords != null && opt.ReleaseRecords.Count > 0) { ICardReleaseRecordProvider provider = ProviderFactory.Create <ICardReleaseRecordProvider>(_RepoUri); foreach (CardReleaseRecord record in opt.ReleaseRecords) { CardReleaseRecord original = record.Clone(); record.SettleDateTime = opt.SettleDateTime; provider.Update(record, original, unitWork); } } if (opt.ChargeRecords != null && opt.ChargeRecords.Count > 0) { ICardChargeRecordProvider provider = ProviderFactory.Create <ICardChargeRecordProvider>(_RepoUri); foreach (CardChargeRecord record in opt.ChargeRecords) { CardChargeRecord original = record.Clone(); record.SettleDateTime = opt.SettleDateTime; provider.Update(record, original, unitWork); } } if (opt.DeferRecords != null && opt.DeferRecords.Count > 0) { ICardDeferRecordProvider provider = ProviderFactory.Create <ICardDeferRecordProvider>(_RepoUri); foreach (CardDeferRecord record in opt.DeferRecords) { CardDeferRecord original = record.Clone(); record.SettleDateTime = opt.SettleDateTime; provider.Update(record, original, unitWork); } } if (opt.CardLostRecords != null && opt.CardLostRecords.Count > 0) { ICardLostRestoreRecordProvider provider = ProviderFactory.Create <ICardLostRestoreRecordProvider>(_RepoUri); foreach (CardLostRestoreRecord record in opt.CardLostRecords) { CardLostRestoreRecord original = record.Clone(); record.SettleDateTime = opt.SettleDateTime; provider.Update(record, original, unitWork); } } if (opt.RecycleRecords != null && opt.RecycleRecords.Count > 0) { ICardRecycleRecordProvider provider = ProviderFactory.Create <ICardRecycleRecordProvider>(_RepoUri); foreach (CardRecycleRecord record in opt.RecycleRecords) { CardRecycleRecord original = record.Clone(); record.SettleDateTime = opt.SettleDateTime; provider.Update(record, original, unitWork); } } if (opt.EventRecords != null && opt.EventRecords.Count > 0) { ICardEventProvider provider = ProviderFactory.Create <ICardEventProvider>(_RepoUri); foreach (CardEventRecord record in opt.EventRecords) { CardEventRecord original = record.Clone(); record.SettleDateTime = opt.SettleDateTime; provider.Update(record, original, unitWork); } } if (opt.AlarmRecords != null && opt.AlarmRecords.Count > 0) { IAlarmProvider provider = ProviderFactory.Create <IAlarmProvider>(_RepoUri); foreach (AlarmInfo record in opt.AlarmRecords) { AlarmInfo original = record.Clone(); record.SettleDateTime = opt.SettleDateTime; provider.Update(record, original, unitWork); } } return(unitWork.Commit()); }