Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
 private YCTPaymentInfo GetPaymentInfoFromCPU(YCTPacket packet)
 {
     byte[] data = packet.Data; //86字节
     if (data == null || data.Length == 0)
     {
         return(null);
     }
     try
     {
         YCTPaymentInfo payment = new YCTPaymentInfo();
         payment.本次交易设备编号   = HexStringConverter.HexToString(Slice(data, 0, 6), string.Empty);
         payment.终端交易流水号    = BEBinaryConverter.BytesToInt(Slice(data, 6, 4));
         payment.本次交易日期时间   = DateTime.ParseExact(HexStringConverter.HexToString(Slice(data, 10, 7), string.Empty), "yyyyMMddHHmmss", null);
         payment.逻辑卡号       = HexStringConverter.HexToString(Slice(data, 17, 8), string.Empty);
         payment.物理卡号       = HexStringConverter.HexToString(Slice(data, 25, 8), string.Empty);
         payment.交易金额       = BEBinaryConverter.BytesToInt(Slice(data, 33, 4));
         payment.票价         = BEBinaryConverter.BytesToInt(Slice(data, 37, 4));
         payment.本次余额       = BEBinaryConverter.BytesToInt(Slice(data, 41, 4));
         payment.交易类型       = Slice(data, 45, 1)[0];
         payment.附加交易类型     = Slice(data, 46, 1)[0];
         payment.票卡充值交易计数   = BEBinaryConverter.BytesToInt(Slice(data, 47, 2));
         payment.票卡消费交易计数   = BEBinaryConverter.BytesToInt(Slice(data, 49, 2));
         payment.累计门槛月份     = HexStringConverter.HexToString(Slice(data, 51, 2), string.Empty);
         payment.公交门槛计数     = Slice(data, 53, 1)[0];
         payment.地铁门槛计数     = Slice(data, 54, 1)[0];
         payment.联乘门槛计数     = Slice(data, 55, 1)[0];
         payment.本次交易入口设备编号 = HexStringConverter.HexToString(Slice(data, 56, 6), string.Empty);
         payment.本次交易入口日期时间 = HexStringConverter.HexToString(Slice(data, 62, 7), string.Empty);
         payment.次交易设备编号    = HexStringConverter.HexToString(Slice(data, 69, 6), string.Empty);
         payment.次交易日期时间    = HexStringConverter.HexToString(Slice(data, 75, 4), string.Empty);
         payment.区域代码       = HexStringConverter.HexToString(Slice(data, 79, 1), string.Empty);
         payment.区域卡类型      = HexStringConverter.HexToString(Slice(data, 80, 2), string.Empty);
         payment.区域子码       = HexStringConverter.HexToString(Slice(data, 82, 1), string.Empty);
         payment.交易认证码      = HexStringConverter.HexToString(Slice(data, 83, 4), string.Empty);
         return(payment);
     }
     catch (Exception ex)
     {
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
     return(null);
 }
Example #4
0
 private YCTPaymentInfo GetPaymentInfoFromM1(YCTPacket packet)
 {
     byte[] data = packet.Data; //73个字节
     if (data == null || data.Length == 0)
     {
         return(null);
     }
     try
     {
         YCTPaymentInfo payment = new YCTPaymentInfo();
         payment.终端交易流水号    = BEBinaryConverter.BytesToInt(Slice(data, 0, 4));
         payment.逻辑卡号       = HexStringConverter.HexToString(Slice(data, 4, 8), string.Empty);
         payment.物理卡号       = HexStringConverter.HexToString(Slice(data, 12, 4), string.Empty);
         payment.次交易设备编号    = HexStringConverter.HexToString(Slice(data, 16, 4), string.Empty);
         payment.次交易日期时间    = HexStringConverter.HexToString(Slice(data, 20, 7), string.Empty);
         payment.本次交易设备编号   = HexStringConverter.HexToString(Slice(data, 27, 4), string.Empty);
         payment.本次交易日期时间   = DateTime.ParseExact(HexStringConverter.HexToString(Slice(data, 31, 7), string.Empty), "yyyyMMddHHmmss", null);
         payment.交易金额       = BEBinaryConverter.BytesToInt(Slice(data, 38, 4));
         payment.本次余额       = BEBinaryConverter.BytesToInt(Slice(data, 42, 4));
         payment.票价         = BEBinaryConverter.BytesToInt(Slice(data, 46, 4));
         payment.交易类型       = Slice(data, 50, 1)[0];
         payment.票卡消费交易计数   = BEBinaryConverter.BytesToInt(Slice(data, 51, 2));
         payment.累计门槛月份     = HexStringConverter.HexToString(Slice(data, 53, 2), string.Empty);
         payment.公交门槛计数     = Slice(data, 55, 1)[0];
         payment.地铁门槛计数     = Slice(data, 56, 1)[0];
         payment.联乘门槛计数     = Slice(data, 57, 1)[0];
         payment.本次交易入口设备编号 = HexStringConverter.HexToString(Slice(data, 58, 4), string.Empty);
         payment.本次交易入口日期时间 = HexStringConverter.HexToString(Slice(data, 62, 7), string.Empty);
         payment.交易认证码      = HexStringConverter.HexToString(Slice(data, 69, 4), string.Empty);
         return(payment);
     }
     catch (Exception ex)
     {
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
     return(null);
 }