private static string GetCPURecord(YCTPaymentRecord r) { return(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13}\t{14}\t{15}\t{16}\t{17}\t{18}\t{19}\t{20}\t{21}\t{22}\t{23}\r\n", r.PID, r.PSN.ToString().PadLeft(10, '0'), r.TIM.ToString("yyyyMMddHHmmss"), r.LCN, r.FCN, r.TF.ToString().PadLeft(7, '0').Insert(5, "."), r.FEE.ToString().PadLeft(7, '0').Insert(5, "."), r.BAL.ToString().PadLeft(7, '0').Insert(5, "."), r.TT.ToString("X2"), r.ATT.ToString("X2"), r.CRN.ToString().PadLeft(5, '0'), r.XRN.ToString().PadLeft(5, '0'), r.DMON, r.BDCT.ToString().PadLeft(3, '0'), r.MDCT.ToString().PadLeft(3, '0'), r.UDCT.ToString().PadLeft(3, '0'), r.EPID, r.ETIM, r.LPID, r.LTIM, r.AREA, r.ACT, r.SAREA, r.TAC )); }
private YCTPaymentRecord CreateRecord(YCTPaymentInfo payment) { YCTPaymentRecord record = new YCTPaymentRecord(); record.PID = payment.本次交易设备编号; record.PSN = payment.终端交易流水号; record.TIM = payment.本次交易日期时间; record.FCN = payment.物理卡号; record.LCN = payment.逻辑卡号; record.TF = payment.交易金额; record.FEE = payment.票价; record.BAL = payment.本次余额; record.TT = payment.交易类型; record.ATT = payment.附加交易类型; record.CRN = payment.票卡充值交易计数; record.XRN = payment.票卡消费交易计数; record.DMON = payment.累计门槛月份; record.BDCT = payment.公交门槛计数; record.MDCT = payment.地铁门槛计数; record.UDCT = payment.联乘门槛计数; record.EPID = payment.本次交易入口设备编号; record.ETIM = payment.本次交易入口日期时间; record.LPID = payment.次交易设备编号; record.LTIM = payment.次交易日期时间; record.AREA = payment.区域代码; record.ACT = payment.区域卡类型; record.SAREA = payment.区域子码; record.TAC = payment.交易认证码; return(record); }
private void ShowItemOnRow(DataGridViewRow row, YCTPaymentRecord record) { row.Cells["colPID"].Value = record.PID; row.Cells["colPSN"].Value = record.PSN; row.Cells["colCardID"].Value = record.LCN; row.Cells["colFee"].Value = ((decimal)record.FEE / 100).ToString("F2"); row.Cells["colBAL"].Value = ((decimal)record.BAL / 100).ToString("F2"); row.Cells["colWalletType"].Value = record.WalletType == 1 ? "M1钱包" : "CPU钱包"; row.Cells["colTIM"].Value = record.TIM.ToString("yyyy-MM-dd HH:mm:ss"); row.Cells["colFile"].Value = record.UploadFile; row.Cells["colState"].Value = StateString(record.State); }
public CommandResult Update(YCTPaymentRecord newVal) { YCTPaymentRecord original = _Provider.GetByID(newVal.ID).QueryObject; if (original != null) { return(_Provider.Update(newVal, original)); } else { return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); } }
/// <summary> /// 处理未完成交易记录 /// </summary> /// <param name="item"></param> /// <param name="w"></param> /// <param name="record"></param> private bool HandleUnFinishedPayment(YCTItem item, YCTWallet w, YCTPaymentRecord record, OpenCardEventArgs args) { string tac = item.Reader.RestorePaid(record.LCN, record.FCN, record.XRN, record.FEE, record.BAL); if (string.IsNullOrEmpty(tac)) { //处理失败 int err = item.Reader.LastError; if (err == 0xC2)//返回无对应的记录 { //无对应交易记录 删除记录 (new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect)).Delete(record); return(true); } return(false); } //处理成功,生成保存上一次的收费记录 args.ChargeDateTime = record.TIM; if (this.OnPaying != null) { this.OnPaying(this, args); //产生上一次的收费事件 } if (args.Payment == null) { return(false); } args.UnFinishedPayment = args.Payment; //设置上次未完成的收费信息 args.Payment = null; //重置收费记录 args.ChargeDateTime = null; //重置计费时间 args.UnFinishedPayment.Paid = record.TF * 1.00M / 100.00M; //设置实收费用,羊城通记录里的交易金额是分为单位的,所以这里需要转换成元 args.UnFinishedPayment.PaymentCode = Ralid.Park.BusinessModel.Enum.PaymentCode.Computer; args.UnFinishedPayment.PaymentMode = Ralid.Park.BusinessModel.Enum.PaymentMode.YangChengTong; //更新未完整交易记录 YCTPaymentRecord newVal = record.Clone(); if (record.WalletType == 0x02) { newVal.TAC = tac; //cpu钱包将TAC写到记录中 } newVal.State = YCTPaymentRecordState.PaidOk; //标记为完成 YCTPaymentRecordBll bll = new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect); CommandResult result = bll.Update(newVal, record); return(result.Result == ResultCode.Successful); }
private bool Paid(YCTItem item, YCTWallet w, CardPaymentInfo paid, out int balance) { balance = 0; YCTPaymentInfo payment = item.Reader.Prepaid((int)(paid.GetPaying() * 100), w.WalletType, Setting.MaxOfflineMonth); if (payment == null) { return(false); } //这里应该保存记录,保存记录成功然后再进行下一步 YCTPaymentRecord record = CreateRecord(payment); record.WalletType = w.WalletType; record.EnterDateTime = paid.EnterDateTime.Value; record.State = YCTPaymentRecordState.PaidFail; YCTPaymentRecordBll bll = new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect); CommandResult result = bll.Insert(record); if (result.Result != ResultCode.Successful) { return(false); } string tac = item.Reader.CompletePaid(); if (string.IsNullOrEmpty(tac)) { int err = item.Reader.LastError; //if (err == 0x01) bll.Delete(record); //失败 删除记录 return(false); } YCTPaymentRecord newVal = record.Clone(); if (w.WalletType == 0x02) { newVal.TAC = tac; //cpu钱包将TAC写到记录中 } newVal.State = YCTPaymentRecordState.PaidOk; //标记为完成 result = bll.Update(newVal, record); balance = record.BAL; //返回余额 if (w.WalletType == 2) { balance -= w.MinBalance; //CPU钱包可用余额为余额减去最小余额 } return(result.Result == ResultCode.Successful); }
private void HandleWallet(YCTItem item, YCTWallet w) { EntranceInfo entrance = item.EntranceID.HasValue ? ParkBuffer.Current.GetEntrance(item.EntranceID.Value) : null; OpenCardEventArgs args = new OpenCardEventArgs() { CardID = w.LogicCardID, CardType = w.WalletType == 0 ? string.Empty : YCTSetting.CardTyte, Entrance = entrance, Balance = (decimal)w.Balance / 100, }; if (args.CardType == YCTSetting.CardTyte) { ParkInfo p = ParkBuffer.Current.GetPark(entrance.ParkID); CardInfo card = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCardByID(w.LogicCardID).QueryObject; if (card != null && (entrance == null || (!p.IsNested && entrance.IsExitDevice))) { //add by Jan 2016-04-27 增加未完整交易记录判断 YCTPaymentRecord record = GetUnFinishedPayment(card); if (record != null) { if (HandleUnFinishedPayment(item, w, record, args) == false) //处理未完整交易记录 { return; //如果处理未完整交易记录失败了,就不需要继续了 } } //end add by Jan 2016-04-27 HandlePayment(item, w, args);//中央收费处和非嵌套车场的出口,并且是羊城通卡,则进行收费处理 } else { if (this.OnReadCard != null) { this.OnReadCard(this, args); } } } else { if (this.OnReadCard != null) { this.OnReadCard(this, args); } } }
private static string GetM1Record(YCTPaymentRecord r) { return(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13}\t{14}\t{15}\r\n", r.PSN.ToString().PadLeft(8, '0'), r.LCN, r.FCN, r.LPID, r.LTIM, r.PID, r.TIM.ToString("yyyyMMddHHmmss"), r.TF.ToString().PadLeft(7, '0').Insert(5, "."), r.BAL.ToString().PadLeft(7, '0').Insert(5, "."), r.TT.ToString("X2"), r.XRN.ToString().PadLeft(5, '0'), r.EPID, r.ETIM, "00", "0", r.TAC )); }
private void YCTPayment_Thread() { try { while (true) { if (Reader != null) { var w = Reader.ReadCard(); if (w != null && w.WalletType != 0) { int p = (int)(Payment * 100); if (w.Balance >= p) { var payment = Reader.Paid(p, w.WalletType); if (payment != null) { YCTPaymentRecord record = CreateRecord(payment); record.WalletType = w.WalletType; record.EnterDateTime = DateTime.Now; record.State = YCTPaymentRecordState.PaidOk; YCTPaymentRecordBll bll = new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect); CommandResult result = bll.Insert(record); string msg = string.Format("扣款{0}元 余额{1}元", Payment, (decimal)payment.本次余额 / 100); ShowMessage(msg); if (AppSettings.CurrentSetting.EnableTTS) { Ralid.GeneralLibrary.Speech.TTSSpeech.Instance.Speek(msg); } if (ChargeLed != null) { ChargeLed.DisplayMsg(msg); } this.DialogResult = DialogResult.OK; break; } else { ShowMessage(Resources.Resource1.FrmYCTPayment_Fail + " 原因:" + Reader.LastErrorDescr); if (AppSettings.CurrentSetting.EnableTTS) { Ralid.GeneralLibrary.Speech.TTSSpeech.Instance.Speek(Resources.Resource1.FrmYCTPayment_Fail); } } } else { ShowMessage(Resources.Resource1.FrmYCTPayment_BalanceNotEnough); if (AppSettings.CurrentSetting.EnableTTS) { Ralid.GeneralLibrary.Speech.TTSSpeech.Instance.Speek(Resources.Resource1.FrmYCTPayment_BalanceNotEnough); } } } } } } catch (ThreadAbortException) { } }
public CommandResult Delete(YCTPaymentRecord info) { return(_Provider.Delete(info)); }
public CommandResult Update(YCTPaymentRecord newVal, YCTPaymentRecord oldVal) { return(_Provider.Update(newVal, oldVal)); }
public CommandResult Insert(YCTPaymentRecord info) { return(_Provider.Insert(info)); }