SendActuallyPaid.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using Edge.Core.Domain.FccOrderInfo.Output;
  2. using Edge.Core.Parser.BinaryParser.MessageEntity;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace HengshanPaymentTerminal.MessageEntity.Outgoing
  9. {
  10. /// <summary>
  11. /// 发送实际支付金额给油机数据对象
  12. /// </summary>
  13. public class SendActuallyPaid : CommonMessage
  14. {
  15. /// <summary>
  16. /// 油枪号
  17. /// </summary>
  18. public int NozzleNum { get; set; }
  19. /// <summary>
  20. /// 流水号
  21. /// </summary>
  22. public int TTC { get; set; }
  23. /// <summary>
  24. /// 实付金额
  25. /// </summary>
  26. public decimal Amount { get; set; }
  27. public SendActuallyPaid(int nozzleNum, int tTC, decimal amount,byte frame)
  28. {
  29. this.Handle = (byte)Command.SEND_NEED_AMOUNT;
  30. NozzleNum = nozzleNum;
  31. TTC = tTC;
  32. Amount = amount;
  33. this.FrameNum = frame;
  34. }
  35. public override byte[] ToCommonByteArray()
  36. {
  37. List<Byte> list = new List<Byte>();
  38. byte[] commandAndNozzle = { this.Handle, (byte)this.NozzleNum };
  39. byte[] ttcBytes = NumberToByteArrayWithPadding(this.TTC, 4);
  40. byte[] amountPayableBytes = FormatDecimal(this.Amount);
  41. list.AddRange(commandAndNozzle); //添加命令字和枪号
  42. list.AddRange(ttcBytes); //添加流水号
  43. list.Add(0x21); //由fcc推送实付金额表示该订单是二维码小程序支付的
  44. list.AddRange(amountPayableBytes); //添加实付金额
  45. //添加3位交易金额1,3位交易金额2,2位优惠规则代码,10位卡应用号,4位消息鉴别码
  46. list.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
  47. byte[] sendBytes = content2data(list.ToArray());
  48. return sendBytes;
  49. }
  50. public override CommonMessage ToObject(byte[] datas)
  51. {
  52. return this;
  53. }
  54. }
  55. }