SendRefund.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace HengshanPaymentTerminal.MessageEntity.Outgoing
  7. {
  8. public class SendRefund:CommonMessage
  9. {
  10. /// <summary>
  11. /// 油枪号
  12. /// </summary>
  13. public int NozzleNum { get; set; }
  14. /// <summary>
  15. /// 流水号
  16. /// </summary>
  17. public int TTC { get; set; }
  18. /// <summary>
  19. /// 支付方式、地点。无效数据,占位。用0x21表示二维码订单
  20. /// </summary>
  21. public byte Pay_X { get; set; }
  22. /// <summary>
  23. /// 加油金额
  24. /// </summary>
  25. public decimal Amount { get; set; }
  26. /// <summary>
  27. /// 实付金额
  28. /// </summary>
  29. public decimal AmountPayable { get; set; }
  30. /// <summary>
  31. /// 退款金额
  32. /// </summary>
  33. public decimal Refund { get; set; }
  34. public SendRefund(int nozzle, string ttc,decimal amount,decimal amountPayable,decimal refund, byte frame)
  35. {
  36. this.Handle = (byte)Command.SEND_REFUND;
  37. this.NozzleNum = nozzle;
  38. int.TryParse(ttc,out int ttcNum);
  39. this.TTC = ttcNum;
  40. this.Pay_X = 0x21;
  41. this.Amount = amount;
  42. this.AmountPayable = amountPayable;
  43. this.Refund = refund;
  44. this.FrameNum = frame;
  45. }
  46. public override byte[] ToCommonByteArray()
  47. {
  48. List<Byte> list = new List<Byte>();
  49. byte[] commandAndNozzle = { this.Handle, (byte)this.NozzleNum };
  50. byte[] ttcBytes = NumberToByteArrayWithPadding(this.TTC, 4);
  51. //加油金额
  52. int amount = (int)(this.Amount * 100);
  53. byte[] amountBytes = NumberToByteArrayWithPadding(amount, 3);
  54. //实付金额
  55. int amountPayable = (int)(this.AmountPayable * 100);
  56. byte[] amountPayableBytes = NumberToByteArrayWithPadding(amountPayable, 3);
  57. //退款金额
  58. int refund = (int)(this.Refund * 100);
  59. byte[] refundBytes = NumberToByteArrayWithPadding(refund, 3);
  60. list.AddRange(commandAndNozzle);
  61. list.AddRange(ttcBytes);
  62. list.Add(this.Pay_X);
  63. list.AddRange(amountBytes);
  64. list.AddRange(amountPayableBytes);
  65. list.AddRange(refundBytes);
  66. byte[] sendBytes = content2data(list.ToArray());
  67. return sendBytes;
  68. }
  69. public override CommonMessage ToObject(byte[] datas)
  70. {
  71. return this;
  72. }
  73. }
  74. }