12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace HengshanPaymentTerminal.MessageEntity.Outgoing
- {
- public class SendRefund:CommonMessage
- {
- /// <summary>
- /// 油枪号
- /// </summary>
- public int NozzleNum { get; set; }
- /// <summary>
- /// 流水号
- /// </summary>
- public int TTC { get; set; }
- /// <summary>
- /// 支付方式、地点。无效数据,占位。用0x21表示二维码订单
- /// </summary>
- public byte Pay_X { get; set; }
- /// <summary>
- /// 加油金额
- /// </summary>
- public decimal Amount { get; set; }
- /// <summary>
- /// 实付金额
- /// </summary>
- public decimal AmountPayable { get; set; }
- /// <summary>
- /// 退款金额
- /// </summary>
- 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<Byte> list = new List<Byte>();
- 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;
- }
- }
- }
|