using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HengshanPaymentTerminal.MessageEntity.Outgoing { public class SendRefund:CommonMessage { /// /// 油枪号 /// public int NozzleNum { get; set; } /// /// 流水号 /// public int TTC { get; set; } /// /// 支付方式、地点。无效数据,占位。用0x21表示二维码订单 /// public byte Pay_X { get; set; } /// /// 加油金额 /// public decimal Amount { get; set; } /// /// 实付金额 /// public decimal AmountPayable { get; set; } /// /// 退款金额 /// public decimal Refund { get; set; } public SendRefund(int nozzle, string ttc,decimal amount,decimal amountPayable,decimal refund, byte frame) { this.Handle = (byte)Command.SEND_REFUND; this.NozzleNum = nozzle; int.TryParse(ttc,out int ttcNum); this.TTC = ttcNum; this.Pay_X = 0x21; this.Amount = amount; this.AmountPayable = amountPayable; this.Refund = refund; this.FrameNum = frame; } public override byte[] ToCommonByteArray() { List list = new List(); byte[] commandAndNozzle = { this.Handle, (byte)this.NozzleNum }; byte[] ttcBytes = NumberToByteArrayWithPadding(this.TTC, 4); //加油金额 int amount = (int)(this.Amount * 100); byte[] amountBytes = NumberToByteArrayWithPadding(amount, 3); //实付金额 int amountPayable = (int)(this.AmountPayable * 100); byte[] amountPayableBytes = NumberToByteArrayWithPadding(amountPayable, 3); //退款金额 int refund = (int)(this.Refund * 100); byte[] refundBytes = NumberToByteArrayWithPadding(refund, 3); list.AddRange(commandAndNozzle); list.AddRange(ttcBytes); list.Add(this.Pay_X); list.AddRange(amountBytes); list.AddRange(amountPayableBytes); list.AddRange(refundBytes); byte[] sendBytes = content2data(list.ToArray()); return sendBytes; } public override CommonMessage ToObject(byte[] datas) { return this; } } }