コード例 #1
0
        private ETCPaymentRecord CreateRecord(GetCardInfoResponse cardInfo, WriteCardResponse writeInfo)
        {
            var ret = new ETCPaymentRecord()
            {
                ListType      = IsExit ? 1 : 0,
                ListNo        = string.Format("{0}{1}{2}{3}{4}{5}{6}", ProvinceNo, CityNo, AreaNo, GateNo, LaneNo, DateTime.Now.ToString("yyyyMMddHHmmss"), "00"),
                KeyServiceNo  = writeInfo.KeyServiceNo,
                TradeType     = writeInfo.TradeType,
                TermCode      = writeInfo.TermCode,
                TermTradeNo   = writeInfo.TermTradeNo,
                CardTradeNo   = writeInfo.CardTradeNo,
                Tac           = writeInfo.Tac,
                OBUID         = null,
                OBUNO         = null,
                CardNo        = cardInfo.CardNo,
                CashMoney     = writeInfo.CashMoney,
                Balance       = writeInfo.Balance,
                TradeDevice   = 1,
                VehPicture    = null,
                VehPictureLen = 0,
                SquadDate     = DateTime.Today.ToString("yyyyMMdd"),
                ShiftID       = DateTime.Today.ToString("yyMMdd"),
                ExTime        = IsExit ? DateTime.Now.ToString("yyyyMMddHHmmss") : null,
                ExAreaNo      = IsExit ? AreaNo : null,
                ExGateNo      = IsExit ? GateNo : null,
                ExLaneNo      = IsExit ? LaneNo : null,
                ExOperatorNo  = IsExit ? "ffff" : null,
                ExVehPlate    = IsExit ? cardInfo.CardPlate : null,
                ExVehType     = IsExit ? cardInfo.CardVehClass : "255",
                ExVehClass    = IsExit ? cardInfo.CardVehUserType : "255",
                EnTime        = IsExit ? cardInfo.PassTime : DateTime.Now.ToString("yyyyMMddHHmmss"),
                EnOperatorNo  = IsExit ? cardInfo.OperatorNo : "000001",
                EnAreaNo      = IsExit ? cardInfo.CardAreaNo : AreaNo,
                EnGateNo      = IsExit ? cardInfo.CardGateNo : GateNo,
                EnLaneNo      = IsExit ? cardInfo.CardLaneNo : LaneNo,
                EnVehPlate    = IsExit ? cardInfo.VehPlate : cardInfo.CardPlate,
                EnVehType     = IsExit ? cardInfo.VehType : cardInfo.CardVehClass,
                EnVehClass    = IsExit ? cardInfo.VehClass : cardInfo.CardVehUserType,
            };

            if (!string.IsNullOrEmpty(ret.ExGateNo) && ret.ExGateNo.Length > 2)
            {
                ret.ExGateNo = ret.ExGateNo.Substring(2);
            }
            if (!string.IsNullOrEmpty(ret.ExLaneNo) && ret.ExLaneNo.Length > 2)
            {
                ret.ExLaneNo = ret.ExLaneNo.Substring(2);
            }
            if (!string.IsNullOrEmpty(ret.EnGateNo) && ret.EnGateNo.Length > 2)
            {
                ret.EnGateNo = ret.EnGateNo.Substring(2);
            }
            if (!string.IsNullOrEmpty(ret.EnLaneNo) && ret.EnLaneNo.Length > 2)
            {
                ret.EnLaneNo = ret.EnLaneNo.Substring(2);
            }
            return(ret);
        }
コード例 #2
0
        /// <summary>
        /// 进行天线扣款操作
        /// </summary>
        /// <param name="money"></param>
        /// <returns></returns>
        public WriteCardResponse RSUWrite(GetOBUInfoResponse r, int money, bool isExit, out ETCPaymentList record)
        {
            int n = -1;

            record = null;
            WriteCardResponse ret  = null;
            int           plen     = 3000;
            StringBuilder response = new StringBuilder(plen);
            var           request  = new
            {
                OBUID           = r.OBUID,
                OBUNO           = r.OBUNO,
                CardNo          = r.CardNo,
                CashMoney       = money.ToString(), //如果不改成字符串格式,会报错
                CardAreaNo      = AreaNo,
                CardGateNo      = GateNo.PadLeft(4, '0'),
                CardLaneNo      = LaneNo.PadLeft(4, '0'),
                PassTime        = DateTime.Now.ToString("yyyyMMddHHmmss"),
                VehPlate        = r.CardPlate,
                VehType         = r.CardVehClass,
                VehClass        = r.CardVehUserType,
                OutFlag         = isExit ? "1" : "0",
                OperatorNo      = "ffff",
                LittleGateNo    = r.LittleGateNo,
                LittleLaneNo    = r.LittleLaneNo,
                LittlePassTime  = r.LittlePassTime,
                LittleCashMoney = r.LittleCashMoney,
                LittleTime      = r.LittleTime,
                OfferType       = r.OfferType,
                OfferTime       = r.OfferTime,
                BackUp          = r.BackUp == null ? string.Empty : r.BackUp, //不能传NULL,
                CheckCode       = r.CheckCode,
            };

            n = ETCInterop.RSUWrite(int.Parse(LaneNo), JsonConvert.SerializeObject(request), response, ref plen);
            if (n != 0)
            {
                return new WriteCardResponse()
                       {
                           ErrorCode = n
                       }
            }
            ;
            ret         = JsonConvert.DeserializeObject <WriteCardResponse>(response.ToString());
            ret.Content = response.ToString();
            if (ret.ErrorCode == 0)
            {
                ret.CashMoney = money; //这两个属性返回串中没有,人为加上去,后面有用!

                ret.Balance = r.Balance - money;
                record      = CreateRecord(r, ret, isExit);
            }
            return(ret);
        }
コード例 #3
0
        private WriteCardResponse CardReaderWriteCard(GetCardInfoResponse r, int money, out ETCPaymentRecord record)
        {
            int n = -1;

            record = null;
            WriteCardResponse ret      = null;
            StringBuilder     response = new StringBuilder(3000);

            if (UseInGD)
            {
                var request = new
                {
                    UserName        = UserName,
                    PassWord        = Password,
                    ProvinceNo      = ProvinceNo,
                    CityNo          = CityNo,
                    AreaNo          = AreaNo,
                    GateNo          = GateNo,
                    LaneNo          = LaneNo,
                    CardNo          = r.CardNo,
                    CashMoney       = money.ToString(),
                    CardAreaNo      = AreaNo,
                    CardGateNo      = GateNo.PadLeft(4, '0'),
                    CardLaneNo      = LaneNo.PadLeft(4, '0'),
                    PassTime        = DateTime.Now.ToString("yyyyMMddHHmmss"),
                    VehPlate        = r.CardPlate,
                    VehType         = r.CardVehClass,
                    VehClass        = r.CardVehUserType,
                    OutFlag         = IsExit ? "1" : "0",
                    OperatorNo      = "ffff",
                    LittleGateNo    = r.LittleGateNo,
                    LittleLaneNo    = r.LittleLaneNo,
                    LittlePassTime  = r.LittlePassTime,
                    LittleCashMoney = r.LittleCashMoney,
                    LittleTime      = r.LittleTime,
                    OfferType       = r.OfferType,
                    OfferTime       = r.OfferTime,
                    BackUp          = r.BackUp == null ? string.Empty : r.BackUp, //不能传NULL
                    CheckCode       = r.CheckCode,
                    ReaderID        = EcReaderID
                };

                n = ETCInterop.CardReaderWriteCard_GD(int.Parse(LaneNo), JsonConvert.SerializeObject(request), response);
                if (n != 0)
                {
                    return new WriteCardResponse()
                           {
                               ErrorCode = n
                           }
                }
                ;
                ret         = JsonConvert.DeserializeObject <WriteCardResponse>(response.ToString());
                ret.Content = response.ToString();
            }
            else
            {
                var request = new
                {
                    UserName   = UserName,
                    PassWord   = Password,
                    ProvinceNo = ProvinceNo,
                    CityNo     = CityNo,
                    AreaNo     = AreaNo,
                    GateNo     = GateNo,
                    LaneNo     = LaneNo,
                    CardNo     = r.CardNo,
                    CashMoney  = money,
                    CardAreaNo = AreaNo,
                    CardGateNo = GateNo.PadLeft(4, '0'),
                    CardLaneNo = LaneNo.PadLeft(4, '0'),
                    PassTime   = DateTime.Now.ToString("yyyyMMddHHmmss"),
                    VehPlate   = r.CardPlate,
                    VehType    = r.CardVehClass,
                    VehClass   = r.CardVehUserType,
                    OutFlag    = IsExit ? "1" : "0",
                    OperatorNo = "ffff",
                    ReaderID   = EcReaderID
                };
                n = ETCInterop.CardReaderWriteCard(int.Parse(LaneNo), JsonConvert.SerializeObject(request), response);
                if (n != 0)
                {
                    return new WriteCardResponse()
                           {
                               ErrorCode = n
                           }
                }
                ;
                ret         = JsonConvert.DeserializeObject <WriteCardResponse>(response.ToString());
                ret.Content = response.ToString();
            }
            if (ret.ErrorCode == -2320) //半条记录的情况,需要验证
            {
                response = new StringBuilder(1000);
                var request = new
                {
                    UserName      = UserName,
                    ProvinceNo    = ProvinceNo,
                    CityNo        = CityNo,
                    AreaNo        = AreaNo,
                    GateNo        = GateNo,
                    LaneNo        = LaneNo,
                    CardNo        = r.CardNo,
                    RelyServiceNo = ret.KeyServiceNo,
                    ReaderID      = EcReaderID
                };
                n = ETCInterop.CardReaderTransActionProve(int.Parse(LaneNo), JsonConvert.SerializeObject(request), response);
                if (n != 0)
                {
                    return new WriteCardResponse {
                               ErrorCode = n
                    }
                }
                ;
                ret         = JsonConvert.DeserializeObject <WriteCardResponse>(response.ToString());
                ret.Content = response.ToString();
            }
            if (ret.ErrorCode == 0)
            {
                ret.CashMoney = money; //这两个属性返回串中没有,人为加上去,后面有用!
                ret.Balance   = r.Balance - money;
                record        = CreateRecord(r, ret);
            }
            return(ret);
        }
コード例 #4
0
ファイル: ETCService.cs プロジェクト: josephca88/510-Null
 private void HandlePayment(ETCDevice device, OpenCardEventArgs e, ReadOBUInfoEventArgs obuInfo, ReadCardInfoEventArgs cardInfo)
 {
     if (this.OnPaying != null)
     {
         this.OnPaying(this, e);                        //产生收费事件
     }
     if (e.Payment == null)
     {
         if (this.OnReadCard != null)
         {
             this.OnReadCard(this, e);
         }
         return;
     }
     if (e.Payment.GetPaying() <= 0) //不用收费直接返回收款成功事件
     {
         WriteCardResponse r    = null;
         ETCPaymentList    list = null;
         if (obuInfo != null)
         {
             r = device.RSUWrite(obuInfo.OBUInfo, 0, true, out list);
         }
         else
         {
             r = device.ReaderWrite(cardInfo.CardInfo, 0, true, out list);
         }
         e.Payment.PaymentCode = Ralid.Park.BusinessModel.Enum.PaymentCode.Computer;
         e.Payment.PaymentMode = Ralid.Park.BusinessModel.Enum.PaymentMode.GDETC;
         if (this.OnPaidOk != null)
         {
             this.OnPaidOk(this, e);
         }
     }
     else //扣费
     {
         //判断余额是否够扣费,否则返回"余额不足",注意钱包单位是分的,这里要转成分比较
         if (e.Payment.GetPaying() <= e.Balance)
         {
             int               paid = (int)(e.Payment.GetPaying() * 100);
             ETCPaymentList    list = null;
             WriteCardResponse r    = null;
             if (obuInfo != null)
             {
                 r = device.RSUWrite(obuInfo.OBUInfo, paid, true, out list);
             }
             else
             {
                 r = device.ReaderWrite(cardInfo.CardInfo, paid, true, out list);
             }
             if (r.ErrorCode == 0)
             {
                 var res    = device.ListUpLoad(list); //上传流水
                 var record = new Ralid.Park.BusinessModel.Model.ETCPaymentRecord()
                 {
                     LaneNo     = device.LaneNo,
                     Device     = obuInfo != null ? 0 : 1,
                     AddTime    = DateTime.Now,
                     Data       = JsonConvert.SerializeObject(list),
                     UploadTime = res.ErrorCode == 0 ? (DateTime?)DateTime.Now : null,
                 };
                 new ETCPaymentRecordBll(AppSettings.CurrentSetting.ParkConnect).Insert(record); //在数据库中保存流水记录
                 e.Paid = e.Payment.GetPaying();
                 e.Payment.PaymentCode = Ralid.Park.BusinessModel.Enum.PaymentCode.Computer;
                 e.Payment.PaymentMode = Ralid.Park.BusinessModel.Enum.PaymentMode.GDETC;
                 e.Balance             = (decimal)r.Balance / 100;
                 if (obuInfo != null && obuInfo.OBUInfo.CardNo != e.CardID)
                 {
                     e.Payment.Memo = "ETC" + obuInfo.OBUInfo.CardNo;                                                        //说明收费的卡号与ETC卡是同一个车牌号
                 }
                 if (this.OnPaidOk != null)
                 {
                     this.OnPaidOk(this, e);
                 }
             }
             else
             {
                 e.LastError = "扣款失败";
                 if (this.OnPaidFail != null)
                 {
                     this.OnPaidFail(this, e);
                 }
             }
         }
         else
         {
             if (obuInfo != null)
             {
                 e.LastError = "余额不足";
                 if (this.OnPaidFail != null)
                 {
                     this.OnPaidFail(this, e);
                 }
             }
             else //ETC读卡器上余额不足时产生读卡事件,在收费电脑上显示明细
             {
                 if (this.OnReadCard != null)
                 {
                     this.OnReadCard(this, e);
                 }
             }
         }
     }
 }