Example #1
0
        /// <summary>
        /// 未完整交易记录处理,返回TAC(M1钱包时为4个字节0x00),如果返回空通过 GetlastError获取错误代码
        /// </summary>
        /// <param name="lcn">逻辑卡号(BCD类型)</param>
        /// <param name="fcn">物理卡号(HEX类型)</param>
        /// <param name="xrn">票卡交易计数器</param>
        /// <param name="fee">交易金额</param>
        /// <param name="bal">本次余额</param>
        /// <returns></returns>
        public string RestorePaid(string lcn, string fcn, int xrn, int fee, int bal)
        {
            try
            {
                List <byte> data = new List <byte>();
                data.AddRange(HexStringConverter.StringToHex(lcn));
                string fcnTemp = fcn.PadRight(16, '0');//M1卡时,物理卡号只有4字节,向右填充0到8字节字符串
                data.AddRange(HexStringConverter.StringToHex(fcnTemp));
                data.AddRange(BEBinaryConverter.ShortToBytes((short)xrn));
                data.AddRange(BEBinaryConverter.IntToBytes(fee));
                data.AddRange(BEBinaryConverter.IntToBytes(bal));
                var response = Request(YCTCommandType.RestorePay, data.ToArray());
                if (response != null && response.IsCommandExcuteOk)
                {
                    return(HexStringConverter.HexToString(response.Data, string.Empty));
                }
                return(null);
            }
            catch (Exception ex)
            {
                Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
            }

            return(null);
        }
Example #2
0
        public YiTingPacket CreateResponse(byte[] data)
        {
            List <byte> temp = new List <byte>();

            if (data != null)
            {
                temp.AddRange(data);
            }
            temp.InsertRange(0, BEBinaryConverter.ShortToBytes((short)(data == null ? 0 : data.Length)));
            temp.Insert(0, CalCRC(temp));
            temp.Insert(0, _Data[5]);
            temp.Insert(0, 0x02); //方向
            temp.InsertRange(0, new byte[] { _Data[2], _Data[3] });
            temp.InsertRange(0, new byte[] { _Data[0], _Data[1] });
            temp.AddRange(new byte[] { _Data[_Data.Length - 2], _Data[_Data.Length - 1] });
            return(new YiTingPacket(temp.ToArray()));
        }