public static IParkIORecord GetFactory() { if (factory == null) { Type type = Type.GetType("Common." + SystemDefaultConfig.DatabaseProvider + "Repository.ParkIORecordDAL,Common." + SystemDefaultConfig.DatabaseProvider + "Repository", true); factory = (IParkIORecord)Activator.CreateInstance(type); } return(factory); }
public static int GetMonthIORecordCountByPlateNumber(string parkingID, string plateNumber, DateTime datetime, out string ErrorMessage) { if (parkingID.IsEmpty()) { throw new ArgumentNullException("parkingID"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.GetMonthIORecordCountByPlateNumber(parkingID, plateNumber, datetime, out ErrorMessage)); }
/// <summary> /// 查询没有出场的临停记录 /// </summary> /// <param name="parkingIds"></param> /// <param name="plateNumber"></param> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="recordTotalCount"></param> /// <returns></returns> public static List <ParkIORecord> QueryPageNotExit(string parkingId, string plateNumber, int pageSize, int pageIndex, out int recordTotalCount) { if (string.IsNullOrWhiteSpace(parkingId)) { throw new ArgumentNullException("parkingId"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.QueryPageNotExit(parkingId, plateNumber, pageSize, pageIndex, out recordTotalCount)); }
public static List <ParkIORecord> GetIORecordWhitPageTab(string parkingID, int pageSize, int pageIndex, List <string> cardTypeIDs, string carModelID, string likePlateNumber, string ingateid, string outgateid, DateTime startTime, DateTime endTime, out int pageCount, out string ErrorMessage, int isExit = 0, int stayDay = -1) { if (parkingID.IsEmpty()) { throw new ArgumentNullException("parkingID"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.GetIORecordWhitPageTab(parkingID, pageSize, pageIndex, cardTypeIDs, carModelID, likePlateNumber, ingateid, outgateid, startTime, endTime, out pageCount, out ErrorMessage, isExit, stayDay)); }
public static int GetAreaCarNumWhenTimeseriesUnExit(string areaID, out string ErrorMessage) { if (areaID.IsEmpty()) { throw new ArgumentNullException("areaID"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.GetAreaCarNumWhenTimeseriesUnExit(areaID, out ErrorMessage)); }
public static int GetIsEditCarNum(string areaID, out string ErrorMessage) { if (areaID.IsEmpty()) { throw new ArgumentNullException("areaID"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.GetIsEditCarNum(areaID, out ErrorMessage)); }
public static bool ModifyIORecord(ParkIORecord mode, out string ErrorMessage) { if (mode == null) { throw new ArgumentNullException("mode"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.ModifyIORecord(mode, out ErrorMessage)); }
public static List <ParkIORecord> GetInParkingNoPlatenumberRecords(string pkid, DateTime datetime) { if (pkid.IsEmpty()) { throw new ArgumentNullException("pkid"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.GetInParkingNoPlatenumberRecords(pkid, datetime)); }
public static List <ParkIORecord> GetInParkingIORecords(string pkid) { if (pkid.IsEmpty()) { throw new ArgumentNullException("pkid"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.GetInParkingIORecords(pkid)); }
public static ParkIORecord GetIORecordContainsDelete(string recordID, out string ErrorMessage) { if (recordID.IsEmpty()) { throw new ArgumentNullException("recordID"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.GetIORecordContainsDelete(recordID, out ErrorMessage)); }
public static List <ParkIORecord> GetIORecordUseLikeStrWhitPageTab(string parkingID, int pageSize, int pageIndex, List <string> cardTypeIDs, string likePlateNumberStr, out int pageCount, out string ErrorMessage, int isExit = 0) { if (parkingID.IsEmpty()) { throw new ArgumentNullException("parkingID"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.GetIORecordUseLikeStrWhitPageTab(parkingID, pageSize, pageIndex, cardTypeIDs, likePlateNumberStr, out pageCount, out ErrorMessage, isExit)); }
/// <summary> /// 查询车牌时段内的记录 /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="platenumber"></param> /// <param name="parkingId"></param> /// <param name="IsExit">false时 end无效</param> /// <returns></returns> public static List <ParkIORecord> QueryPlatenumberIORecordByTime(DateTime start, DateTime end, string platenumber, string parkingId, bool IsExit) { if (start == null) { throw new ArgumentNullException("start"); } if (end == null) { throw new ArgumentNullException("end"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.QueryPlatenumberIORecordByTime(start, end, platenumber, parkingId, IsExit)); }
public static List <ParkIORecord> QueryIORecordIds(DateTime start, DateTime end, string parkingId, bool IsExit) { if (start == null) { throw new ArgumentNullException("start"); } if (end == null) { throw new ArgumentNullException("end"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.QueryMonthExpiredIORecordIds(start, end, parkingId, IsExit)); }
public static ParkIORecord GetNoExitIORecordByPlateNumber(string parkid, string plateNumber, out string ErrorMessage) { if (parkid.IsEmpty()) { throw new ArgumentNullException("mode"); } if (plateNumber.IsEmpty()) { throw new ArgumentNullException("plateNumber"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.GetNoExitIORecordByPlateNumber(parkid, plateNumber, out ErrorMessage)); }
public static List <string> QueryMonthExpiredNotPayAmountIORecordIds(DateTime start, DateTime end, string parkingId, List <string> plateNumbers) { if (parkingId.IsEmpty()) { throw new ArgumentNullException("parkingId"); } if (plateNumbers.Count == 0) { throw new ArgumentNullException("plateNumbers"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.QueryMonthExpiredNotPayAmountIORecordIds(start, end, parkingId, plateNumbers)); }
public static bool RemoveRepeatInIORecordByPlateNumber(string parkingID, string plateNumber, out string ErrorMessage) { if (parkingID.IsEmpty()) { throw new ArgumentNullException("parkingID"); } if (plateNumber.IsEmpty()) { throw new ArgumentNullException("plateNumber"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.RemoveRepeatInIORecordByPlateNumber(parkingID, plateNumber, out ErrorMessage)); }
public static bool RemoveRepeatInIORecordByCardNo(string parkingID, string cardNo, out string ErrorMessage) { if (parkingID.IsEmpty()) { throw new ArgumentNullException("parkingID"); } if (cardNo.IsEmpty()) { throw new ArgumentNullException("cardNo"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.RemoveRepeatInIORecordByCardNo(parkingID, cardNo, out ErrorMessage)); }
public static DateTime?GetLastRecordEnterTimeByPlateNumber(string parkingID, string platenumber, out string ErrorMessage) { if (parkingID.IsEmpty()) { throw new ArgumentNullException("parkingID"); } if (platenumber.IsEmpty()) { throw new ArgumentNullException("platenumber"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.GetLastRecordEnterTimeByPlateNumber(parkingID, platenumber, out ErrorMessage)); }
public static DateTime?GetLastRecordEnterTimeByCarNo(string parkingID, string cardNo, out string ErrorMessage) { if (parkingID.IsEmpty()) { throw new ArgumentNullException("parkingID"); } if (cardNo.IsEmpty()) { throw new ArgumentNullException("cardNo"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.GetLastRecordEnterTimeByCarNo(parkingID, cardNo, out ErrorMessage)); }
public static ParkIORecord QueryCarLastNotExitIORecord(string parkingId, string plateNumber) { if (parkingId.IsEmpty()) { throw new ArgumentNullException("parkingId"); } if (plateNumber.IsEmpty()) { throw new ArgumentNullException("plateNumber"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.QueryCarLastNotExitIORecord(parkingId, plateNumber)); }
public static Dictionary <string, DateTime> QueryLastNotExitIORecord(string parkingId, List <string> plateNumbers) { if (parkingId.IsEmpty()) { throw new ArgumentNullException("parkingId"); } if (plateNumbers.Count == 0) { throw new ArgumentNullException("plateNumbers"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.QueryLastNotExitIORecord(parkingId, plateNumbers)); }
public static ParkIORecord GetNoExitIORecordByCardNo(string parkid, string cardNo, out string ErrorMessage) { if (parkid.IsEmpty()) { throw new ArgumentNullException("mode"); } if (cardNo.IsEmpty()) { throw new ArgumentNullException("cardNo"); } IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.GetNoExitIORecordByCardNo(parkid, cardNo, out ErrorMessage)); }
public static List <ParkIORecord> QueryInIORecordIds(string parkingId, bool IsExit) { IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.QueryInIORecordIds(parkingId, IsExit)); }
public static ParkIORecord QueryInCarTempIORecordByLikePlateNumber(string parkid, string plateNumber, out string errorMsg) { IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.QueryInCarTempIORecordByLikePlateNumber(parkid, plateNumber, out errorMsg)); }
/// <summary> /// 修改车类型 /// </summary> /// <param name="RecordID"></param> /// <param name="CarType"></param> /// <returns></returns> public static bool EditParkIORecord(string RecordID, string CarModelID) { IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.EditParkIORecord(RecordID, CarModelID)); }
public static bool DelParkIORecord(string RecordID) { IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.DelParkIORecord(RecordID)); }
public static ParkIORecord QueryLastExitIORecordByPlateNumber(string plateNumber) { IParkIORecord factory = ParkIORecordFactory.GetFactory(); return(factory.QueryLastExitIORecordByPlateNumber(plateNumber)); }
public void Statistics_DailyByGate(List <ParkGate> gatelist, BaseParkinfo park, DateTime startdate, DateTime enddate) { #region 统计通道的实收应收 按小时 if (gatelist == null || gatelist.Count == 0) { return; } IParkIORecord iorecordfactory = ParkIORecordFactory.GetFactory(); IParkOrder iorder = ParkOrderFactory.GetFactory(); IStatistics_GatherGate igathergate = Statistics_GatherGateFactory.GetFactory(); foreach (var g in gatelist) { int hours = 0; int maxhours = 23; List <Statistics_GatherGate> gathergates = new List <Statistics_GatherGate>(); List <DateTime> DeleteGather = new List <DateTime>(); if (startdate.ToString("yyyyMMdd") == startdate.ToString("yyyyMMdd")) { maxhours = startdate.Hour; } while (hours <= maxhours) { System.Threading.Thread.Sleep(50); Statistics_GatherGate gather = new Statistics_GatherGate(); DateTime tempstartdate = startdate.AddHours(hours); DateTime tempenddate = enddate.AddHours(hours); gather.StatisticsGatherID = System.Guid.NewGuid().ToString(); gather.ParkingID = park.PKID; gather.ParkingName = park.PKName; gather.GatherTime = tempstartdate; gather.BoxID = g.BoxID; gather.BoxName = g.BoxName; gather.GateID = g.GateID; gather.GateName = g.GateName; if (startdate.ToString("yyyyMMdd") == startdate.ToString("yyyyMMdd")) { if (hours == maxhours || hours == maxhours - 1) { DeleteGather.Add(tempstartdate); } else { if (igathergate.IsExists(g.GateID, tempstartdate)) { hours++; continue; } } } else { if (igathergate.IsExists(g.GateID, tempstartdate)) { hours++; continue; } } //查询进场数 gather.Entrance_Count = iorecordfactory.EntranceCountByGate(g.GateID, tempstartdate, tempenddate); //查询出场数 gather.Exit_Count = iorecordfactory.ExitCountByGate(g.GateID, tempstartdate, tempenddate); #region 进场卡片类型 List <KeyValue> _InCardType = iorecordfactory.GetInCardTypeByGateID(g.GateID, tempstartdate, tempenddate); if (_InCardType != null && _InCardType.Count > 0) { foreach (var kv in _InCardType) { switch (kv.KeyName) { case "0": gather.VIPCard = kv.Key_Value; break; case "1": gather.StordCard = kv.Key_Value; break; case "2": gather.MonthCard = kv.Key_Value; break; case "3": gather.TempCard = kv.Key_Value; break; case "4": gather.JobCard = kv.Key_Value; break; default: break; } } } #endregion #region 统计放行类型 List <KeyValue> _ReleaseType = iorecordfactory.GetReleaseTypeByGate(g.GateID, tempstartdate, tempenddate); if (_ReleaseType != null && _ReleaseType.Count > 0) { foreach (var kv in _ReleaseType) { switch (kv.KeyName) { case "0": gather.ReleaseType_Normal = kv.Key_Value; break; case "1": gather.ReleaseType_Charge = kv.Key_Value; break; case "2": gather.ReleaseType_Free = kv.Key_Value; break; case "3": gather.ReleaseType_Catch = kv.Key_Value; break; } } } #endregion #region 统计费用相关 List <ParkOrder> _orderfee = iorder.GetOrdersByGateID(park.PKID, g.GateID, tempstartdate, tempenddate); if (_orderfee != null && _orderfee.Count > 0) { foreach (var o in _orderfee) { gather.Receivable_Amount += o.Amount; gather.Real_Amount += o.PayAmount; gather.Diff_Amount += o.UnPayAmount; //支付方式(1.现金、2.微信、3.支付宝、4.网银、5.电子钱包、6.优免卷7.余额 switch (o.PayWay) { case OrderPayWay.Cash: gather.Cash_Amount += o.PayAmount; gather.Cash_Count++; if (o.DiscountAmount > 0) { gather.CashDiscount_Amount += o.DiscountAmount; gather.CashDiscount_Count++; gather.Discount_Amount += o.DiscountAmount; gather.Discount_Count++; } break; case OrderPayWay.WeiXin: case OrderPayWay.Alipay: case OrderPayWay.OnlineBanking: case OrderPayWay.Wallet: gather.OnLine_Amount += o.PayAmount; gather.OnLine_Count++; if (o.DiscountAmount > 0) { gather.OnLineDiscount_Amount += o.DiscountAmount; gather.OnLineDiscount_Count++; gather.Discount_Amount += o.DiscountAmount; gather.Discount_Count++; } break; case OrderPayWay.PreferentialTicket: gather.Discount_Amount += o.DiscountAmount; gather.Discount_Count++; break; case OrderPayWay.ValueCard: gather.StordCard_Amount += o.PayAmount; gather.StordCard_Count++; break; } switch (o.OrderType) { //临时卡缴费 case OrderType.TempCardPayment: case OrderType.AreaTempCardPayment: switch (o.PayWay) { case OrderPayWay.WeiXin: case OrderPayWay.Alipay: case OrderPayWay.OnlineBanking: case OrderPayWay.Wallet: gather.OnLineTemp_Amount += o.PayAmount; gather.OnLineTemp_Count++; break; default: gather.Temp_Amount += o.PayAmount; gather.Temp_Count++; break; } break; //月卡续期 case OrderType.MonthCardPayment: switch (o.PayWay) { case OrderPayWay.WeiXin: case OrderPayWay.Alipay: case OrderPayWay.OnlineBanking: case OrderPayWay.Wallet: gather.OnLineMonthCardExtend_Amount += o.PayAmount; gather.OnLineMonthCardExtend_Count++; break; default: gather.MonthCardExtend_Amount += o.PayAmount; gather.MonthCardExtend_Count++; break; } break; //VIP卡续期 case OrderType.VIPCardRenewal: gather.VIPExtend_Count++; break; //储值卡充值 case OrderType.ValueCardRecharge: switch (o.PayWay) { case OrderPayWay.WeiXin: case OrderPayWay.Alipay: case OrderPayWay.OnlineBanking: case OrderPayWay.Wallet: gather.OnLineStordCard_Amount += o.PayAmount; gather.OnLineStordCard_Count++; break; default: gather.StordCardRecharge_Amount += o.PayAmount; gather.StordCardRecharge_Count++; break; } break; } } } #endregion gathergates.Add(gather); hours++; } if (gathergates != null) { using (DbOperator dboperator = ConnectionManager.CreateReadConnection()) { try { dboperator.BeginTransaction(); foreach (DateTime d in DeleteGather) { igathergate.Delete(park.PKID, startdate, dboperator); } foreach (var gate in gathergates) { if (!igathergate.Insert(gate, dboperator)) { throw new Exception("插入通道统计数据失败"); } } dboperator.CommitTransaction(); } catch (Exception ex) { Common.Services.TxtLogServices.WriteTxtLog("添加通道统计信息异常 异常信息:{0}", ex.Message); dboperator.RollbackTransaction(); } } } } #endregion }
/// <summary> /// 当班统计 /// </summary> public void Statistics_OnDuty(string ParkingID) { try { IParking iparking = ParkingFactory.GetFactory(); IParkIORecord iorecordfactory = ParkIORecordFactory.GetFactory(); IStatistics_Gather gatherfactory = Statistics_GatherFactory.GetFactory(); IParkChangeshiftrecord ichangeshift = ParkChangeshiftrecordFactory.GetFactory(); IParkOrder iorder = ParkOrderFactory.GetFactory(); IParkBox iparkbox = ParkBoxFactory.GetFactory(); IStatistics_ChangeShift istatisticschangeshift = Statistics_ChangeShiftFactory.GetFactory(); BaseParkinfo parking = iparking.QueryParkingByParkingID(ParkingID); List <ParkBox> boxlist = iparkbox.QueryByParkingID(parking.PKID); if (boxlist != null && boxlist.Count > 0) { foreach (ParkBox box in boxlist) { List <ParkChangeshiftrecord> ondutys = ichangeshift.GetChangeShiftRecord(box.BoxID); if (ondutys == null || ondutys.Count == 0) { continue; } foreach (ParkChangeshiftrecord onduty in ondutys) { Statistics_ChangeShift changeshift = new Statistics_ChangeShift { BoxID = onduty.BoxID, ParkingName = parking.PKName, StartWorkTime = onduty.StartWorkTime, EndWorkTime = onduty.EndWorkTime, ParkingID = parking.PKID, AdminID = onduty.UserID, ChangeShiftID = onduty.RecordID }; DateTime starttime = onduty.StartWorkTime; DateTime endtime = DateTime.Now; if (onduty.EndWorkTime > DateTime.MinValue) { endtime = onduty.EndWorkTime; } //统计相关信息 //查询进场数 changeshift.Entrance_Count = iorecordfactory.EntranceCountByBox(box.BoxID, starttime, endtime); //查询出场数 changeshift.Exit_Count = iorecordfactory.ExitCountByBox(box.BoxID, starttime, endtime); #region 进场卡片类型 List <KeyValue> _InCardType = iorecordfactory.GetInCardTypeByBoxID(box.BoxID, starttime, endtime); if (_InCardType != null && _InCardType.Count > 0) { foreach (var k in _InCardType) { switch (k.KeyName) { case "0": changeshift.VIPCard = k.Key_Value; break; case "1": changeshift.StordCard = k.Key_Value; break; case "2": changeshift.MonthCard = k.Key_Value; break; case "3": changeshift.TempCard = k.Key_Value; break; case "4": changeshift.JobCard = k.Key_Value; break; default: break; } } } #endregion #region 统计放行类型 List <KeyValue> _ReleaseType = iorecordfactory.GetReleaseTypeByBox(box.BoxID, starttime, endtime); if (_ReleaseType != null && _ReleaseType.Count > 0) { foreach (KeyValue k in _ReleaseType) { switch (k.KeyName) { case "0": changeshift.ReleaseType_Normal = k.Key_Value; break; case "1": changeshift.ReleaseType_Charge = k.Key_Value; break; case "2": changeshift.ReleaseType_Free = k.Key_Value; break; case "3": changeshift.ReleaseType_Catch = k.Key_Value; break; } } } #endregion #region 统计费用相关 List <ParkOrder> _orderfee = iorder.GetOrdersByBoxID(parking.PKID, onduty.BoxID, starttime, endtime); if (_orderfee != null && _orderfee.Count > 0) { foreach (ParkOrder o in _orderfee) { changeshift.Receivable_Amount += o.Amount; changeshift.Diff_Amount += o.UnPayAmount; changeshift.Real_Amount = (changeshift.Receivable_Amount - changeshift.Diff_Amount); //支付方式(1.现金、2.微信、3.支付宝、4.网银、5.电子钱包、6.优免卷7.余额 switch (o.PayWay) { case OrderPayWay.Cash: changeshift.Cash_Amount += o.PayAmount; changeshift.Cash_Count++; if (o.DiscountAmount > 0) { changeshift.CashDiscount_Amount += o.DiscountAmount; changeshift.CashDiscount_Count++; changeshift.Discount_Amount += o.DiscountAmount; changeshift.Discount_Count++; } break; case OrderPayWay.WeiXin: case OrderPayWay.Alipay: case OrderPayWay.OnlineBanking: case OrderPayWay.Wallet: changeshift.OnLine_Amount += o.PayAmount; changeshift.OnLine_Count++; if (o.DiscountAmount > 0) { changeshift.OnLineDiscount_Amount += o.DiscountAmount; changeshift.OnLineDiscount_Count++; changeshift.Discount_Amount += o.DiscountAmount; changeshift.Discount_Count++; } break; case OrderPayWay.PreferentialTicket: changeshift.Discount_Amount += o.DiscountAmount; changeshift.Discount_Count++; break; case OrderPayWay.ValueCard: changeshift.StordCard_Amount += o.PayAmount; changeshift.StordCard_Count++; break; } switch (o.OrderType) { //临时卡缴费 case OrderType.TempCardPayment: case OrderType.AreaTempCardPayment: switch (o.PayWay) { case OrderPayWay.WeiXin: case OrderPayWay.Alipay: case OrderPayWay.OnlineBanking: case OrderPayWay.Wallet: changeshift.OnLineTemp_Amount += o.PayAmount; changeshift.OnLineTemp_Count++; break; default: changeshift.Temp_Amount += o.PayAmount; changeshift.Temp_Count++; break; } break; //月卡续期 case OrderType.MonthCardPayment: switch (o.PayWay) { case OrderPayWay.WeiXin: case OrderPayWay.Alipay: case OrderPayWay.OnlineBanking: case OrderPayWay.Wallet: changeshift.OnLineMonthCardExtend_Amount += o.PayAmount; changeshift.OnLineMonthCardExtend_Count++; break; default: changeshift.MonthCardExtend_Amount += o.PayAmount; changeshift.MonthCardExtend_Count++; break; } break; //VIP卡续期 case OrderType.VIPCardRenewal: changeshift.VIPExtend_Count++; break; //储值卡充值 case OrderType.ValueCardRecharge: switch (o.PayWay) { case OrderPayWay.WeiXin: case OrderPayWay.Alipay: case OrderPayWay.OnlineBanking: case OrderPayWay.Wallet: changeshift.OnLineStordCard_Amount += o.PayAmount; changeshift.OnLineStordCard_Count++; break; default: changeshift.StordCardRecharge_Amount += o.PayAmount; changeshift.StordCardRecharge_Count++; break; } break; } } } #endregion using (DbOperator dboperator = ConnectionManager.CreateReadConnection()) { try { dboperator.BeginTransaction(); istatisticschangeshift.Delete(onduty.RecordID, dboperator); istatisticschangeshift.Insert(changeshift, dboperator); dboperator.CommitTransaction(); } catch (Exception ex) { TxtLogServices.WriteTxtLog("添加当班信息异常 异常信息:{0}", ex.Message); dboperator.RollbackTransaction(); } } } } } } catch (Exception ex) { TxtLogServices.WriteTxtLog("当班统计异常 异常信息:{0}", ex.Message); } }
/// <summary> /// 续期或续费 /// </summary> /// <param name="grantId"></param> /// <param name="renewalMonth"></param> /// <param name="payTotalMoney"></param> /// <param name="operatorId"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <returns></returns> public static bool RenewalsOrRecharge(string grantId, int renewalMonth, decimal payTotalMoney, string operatorId, DateTime startDate, DateTime endDate) { lock (parkGrant_lock) { ParkGrant grant = ParkGrantServices.QueryByGrantId(grantId); if (grant == null) { throw new MyException("获取授权信息失败"); } if (endDate != null && endDate != DateTime.MinValue) { endDate = endDate.Date.AddDays(1).AddSeconds(-1); } string errorMsg = string.Empty; BaseCard card = BaseCardServices.GetBaseCard(grant.CardID, out errorMsg); if (card == null || !string.IsNullOrWhiteSpace(errorMsg)) { throw new MyException("获取卡失败"); } ParkCarType carType = ParkCarTypeServices.QueryParkCarTypeByRecordId(grant.CarTypeID); if (carType == null) { throw new MyException("获取卡类失败"); } List <ParkGrant> operateTargets = new List <ParkGrant>(); List <string> ioRecords = new List <string>(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { bool renewalsResult = false; dbOperator.BeginTransaction(); switch (carType.BaseTypeID) { case BaseCarType.StoredValueCar: { IBaseCard factory = BaseCardFactory.GetFactory(); if (payTotalMoney > 0) { ParkOrder order = ParkOrderServices.AddStoredValueCarOrder(grant.PKID, payTotalMoney, card, operatorId, dbOperator); if (order == null) { throw new MyException("创建充值订单失败"); } decimal cardtotalmoney = card.Balance + payTotalMoney; if (order.NewMoney != cardtotalmoney) { throw new MyException("充值金额计算错误"); } renewalsResult = factory.Recharge(card.CardID, payTotalMoney, dbOperator); if (!renewalsResult) { throw new MyException("卡充值失败【更改卡余额失败】"); } } renewalsResult = factory.SetEndDate(card.CardID, endDate, dbOperator); if (!renewalsResult) { throw new MyException("卡充值失败【更改有效期失败】"); } break; } case BaseCarType.VIPCar: { ParkOrder order = ParkOrderServices.AddVipCardOrder(grant.PKID, grantId, grant.BeginDate, grant.EndDate, startDate, endDate, renewalMonth, operatorId, dbOperator); if (order == null) { throw new MyException("充值失败【创建充值订单失败】"); } IParkGrant factory = ParkGrantFactory.GetFactory(); renewalsResult = factory.Renewals(grant.GID, startDate, endDate, dbOperator); if (!renewalsResult) { throw new MyException("修改车辆有效期失败"); } break; } case BaseCarType.MonthlyRent: { int pkLotQuantity = 1; if (!string.IsNullOrWhiteSpace(grant.PKLot)) { pkLotQuantity = grant.PKLot.TrimEnd(',').Split(',').Length; } decimal amount = ParkOrderServices.CalculateMonthlyRentExpiredWaitPayAmount(startDate, grantId); //if (payTotalMoney != ((carType.Amount * renewalMonth * pkLotQuantity) + amount)) // throw new MyException("凭证续期金额计算有误"); List <ParkGrant> shareCardGrants = new List <ParkGrant>(); if (!string.IsNullOrWhiteSpace(grant.PKLot)) { shareCardGrants = ParkGrantServices.QueryByParkingAndLotAndCarType(grant.PKID, grant.PKLot, BaseCarType.MonthlyRent, grant.GID); } IParkGrant factory = ParkGrantFactory.GetFactory(); renewalsResult = factory.Renewals(grant.GID, startDate, endDate, dbOperator); if (!renewalsResult) { throw new MyException("修改车辆有效期失败"); } //修改多车多位的有效期 foreach (var item in shareCardGrants) { if (string.IsNullOrWhiteSpace(item.PKLot)) { continue; } int len1 = item.PKLot.TrimEnd(',').Split(',').Length; int len2 = grant.PKLot.TrimEnd(',').Split(',').Length; if (len1 != len2) { continue; } item.BeginDate = startDate; item.EndDate = endDate; factory.Update(item, dbOperator); operateTargets.Add(item); } //过期转临停订单处理 if (grant.EndDate.Date < DateTime.Now.Date) { List <string> plateNos = new List <string>(); EmployeePlate plate = EmployeePlateServices.Query(grant.PlateID); if (plate == null) { throw new MyException("授权车牌信息不存在"); } plateNos.Add(plate.PlateNo); foreach (var item in shareCardGrants) { if (string.IsNullOrWhiteSpace(item.PKLot)) { continue; } int len1 = item.PKLot.TrimEnd(',').Split(',').Length; int len2 = grant.PKLot.TrimEnd(',').Split(',').Length; if (len1 != len2) { continue; } EmployeePlate otherplate = EmployeePlateServices.Query(item.PlateID); if (otherplate == null) { throw new MyException("多车多位存在无效的车牌"); } plateNos.Add(otherplate.PlateNo); } if (plateNos.Count > 0 && grant.EndDate != DateTime.MinValue) { IParkIORecord ioRecord = ParkIORecordFactory.GetFactory(); ioRecords = ioRecord.QueryMonthExpiredNotPayAmountIORecordIds(grant.EndDate.AddDays(1).Date, startDate, grant.PKID, plateNos); if (ioRecords.Count > 0) { bool result = ioRecord.UpdateIORecordEnterType(ioRecords, 0, dbOperator); if (!result) { throw new MyException("修改进出记录类型失败"); } result = ParkOrderServices.AddExpiredToProStopOrder(ioRecords, operatorId, dbOperator); if (!result) { throw new MyException("创建月卡转临停订单失败"); } } } } ParkOrder order = ParkOrderServices.AddMonthlyRentOrderCS(grant.PKID, carType.CarTypeID, grant.GID, grant.BeginDate, grant.EndDate, startDate, endDate, renewalMonth, pkLotQuantity, operatorId, payTotalMoney, dbOperator); if (order == null) { throw new MyException("续期失败【创建续期订单失败】"); } break; } //case BaseCarType.WorkCar: // { // IParkGrant factory = ParkGrantFactory.GetFactory(); // renewalsResult = factory.Renewals(grant.GID, startDate, endDate, dbOperator); // if (!renewalsResult) throw new MyException("修改卡结束时间错误"); // break; // } default: throw new MyException("选择的车辆不能续期和充值"); } dbOperator.CommitTransaction(); string remark = string.Format("grantId:{0};renewalMonth:{1};payTotalMoney:{2};operatorId:{3};startDate:{4};endDate:{5}", grantId, renewalMonth, payTotalMoney, operatorId, startDate.ToString("yyyy-MM-dd"), endDate.ToString("yyyy-MM-dd")); OperateLogServices.AddOperateLog(OperateType.Update, remark); if (ioRecords.Count > 0) { string updateIORecord = string.Format("修改IORecord表,RecordIDs:{0},EnterType:0", string.Join(",", ioRecords)); OperateLogServices.AddOperateLog(OperateType.Update, updateIORecord); } return(renewalsResult); } catch (Exception ex) { dbOperator.RollbackTransaction(); throw ex; } } } }