Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 预消费
        /// </summary>
        /// <param name="paid">消费金额(分为单位)</param>
        /// <param name="walletType">钱包类型 1表示M1 2表示CPU</param>
        /// <param name="maxOfflineMonth">离线过期月数</param>
        /// <returns></returns>
        public YCTPaymentInfo Prepaid(int paid, int walletType, int maxOfflineMonth = 0)
        {
            DateTime    dt   = DateTime.Now;
            List <byte> data = new List <byte>();

            data.AddRange(BEBinaryConverter.IntToBytes(paid));
            data.AddRange(BEBinaryConverter.IntToBytes(paid));
            data.Add(BCDConverter.IntToBCD(dt.Year / 100));
            data.Add(BCDConverter.IntToBCD(dt.Year % 100));
            data.Add(BCDConverter.IntToBCD(dt.Month));
            data.Add(BCDConverter.IntToBCD(dt.Day));
            data.Add(BCDConverter.IntToBCD(dt.Hour));
            data.Add(BCDConverter.IntToBCD(dt.Minute));
            data.Add(BCDConverter.IntToBCD(dt.Second));
            data.Add((byte)(maxOfflineMonth > 0 ? 0x01 : 0x00));
            data.Add(BCDConverter.IntToBCD(maxOfflineMonth));
            var response = Request(YCTCommandType.Prepaid, data.ToArray());

            if (response != null && response.IsCommandExcuteOk)
            {
                if (walletType == 1)
                {
                    return(GetPaymentInfoFromM1(response));
                }
                if (walletType == 2)
                {
                    return(GetPaymentInfoFromCPU(response));
                }
            }
            return(null);
        }