using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HengshanPaymentTerminal.MessageEntity.Incoming
{
    /// <summary>
    /// Fcc发起取消授权，油机回复信息数据对象
    /// </summary>
    public class UnAhorizationResponse:CommonAnswerBack
    {
        /// <summary>
        /// 枪号
        /// </summary>
        public int NozzleNum { get; set; }

        /// <summary>
        /// 发起授权时间
        /// </summary>
        public DateTime? AuthorizationTime { get; set; }

        /// <summary>
        /// 授权结果：00：失败；01：成功
        /// </summary>
        public int Result { get; set; }

        /// <summary>
        /// 流水号
        /// </summary>
        public int Ttc { get; set; }

        public override byte[] ToCommonByteArray()
        {
            return base.ToCommonByteArray();
        }

        public override CommonMessage ToObject(byte[] datas)
        {
            string v = BitConverter.ToString(datas).Replace("-", " ");
            getBaseData(datas);
            this.NozzleNum = datas[7];

            Span<byte> authorizationTimeSapn = datas.AsSpan(8, 7);
            this.AuthorizationTime = bytes2DateTime(authorizationTimeSapn.ToArray());

            this.Result = datas[15];

            this.Ttc = Bytes2Number<int>(datas, 16, 4);
            return this;
        }
    }
}
