/// <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); }
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); }