123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- using Castle.Components.DictionaryAdapter.Xml;
- using Edge.Core.Domain.FccOrderInfo;
- using Edge.Core.Domain.FccStationInfo.Output;
- using Edge.Core.Parser.BinaryParser.MessageEntity;
- using Microsoft.EntityFrameworkCore.Metadata.Internal;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- namespace HengshanPaymentTerminal.MessageEntity.Incoming
- {
- /// <summary>
- /// 油机推送订单信息数据对象
- /// </summary>
- public class OrderFromMachine:CommonMessage
- {
- /// <summary>
- /// 枪号
- /// </summary>
- public int nozzleNum { get; set; }
- /// <summary>
- /// 交易流水号
- /// </summary>
- public int ttc { get; set; }
- /// <summary>
- /// 加油时间
- /// </summary>
- public DateTime dispenserTime { get; set; }
- /// <summary>
- /// 挂枪时间
- /// </summary>
- public DateTime endTime { get; set; }
- /// <summary>
- /// 油品代码
- /// </summary>
- public string oilCode { get; set; }
- /// <summary>
- /// 付款方式/地点
- /// </summary>
- public byte payType { get; set; }
- /// <summary>
- /// 价格
- /// </summary>
- public decimal price { get; set; }
- /// <summary>
- /// 金额
- /// </summary>
- public decimal amount { get; set; }
- /// <summary>
- /// 升数
- /// </summary>
- public decimal volume { get; set; }
- /// <summary>
- /// 泵码
- /// </summary>
- public decimal pumpCode { get; set; }
- public override byte[] ToCommonByteArray()
- {
- byte[] content = new byte[] { 0x55, this.Handle, (byte)this.nozzleNum, ((byte)RESULT.OVER) };
- return content2data(content);
- }
- public override CommonMessage ToObject(byte[] datas)
- {
- getBaseData(datas);
- this.nozzleNum = datas[7];
- this.ttc = Bytes2Number<int>(datas, 8, 4);
- Span<byte> dispenserSpan = datas.AsSpan(12, 7);
- this.dispenserTime = bytes2DateTime(dispenserSpan.ToArray());
- Span<byte> endSpan = datas.AsSpan(19, 7);
- this.endTime = bytes2DateTime(endSpan.ToArray());
- Span<byte> oilCodeSpan = datas.AsSpan(26, 2);
- this.oilCode = BitConverter.ToString(oilCodeSpan.ToArray()).Replace("-", "");
- this.payType = datas[28];
- ushort priceShort = Bytes2Number<ushort>(datas,29, 2);
- this.price = priceShort / 100m;
- uint amountInt = Bytes2Number<uint>(datas, 31, 3);
- this.amount = amountInt / 100m;
- uint volumeInt = Bytes2Number<uint>(datas, 34, 3);
- this.volume = volumeInt / 100m;
- int punpCodeInt = Bytes2Number<int>(datas, 37, 4);
- this.pumpCode = punpCodeInt / 100m;
- return this;
- }
- public FccOrderInfo ToComponent(string? oilName)
- {
- return new FccOrderInfo
- {
- Ttc = this.ttc,
- AuthorizationTime = this.dispenserTime,
- EndTime = this.endTime,
- PaymentTime = null,
- NozzleNum = this.nozzleNum,
- OilName = oilName ?? "",
- PaymentStatus = 0,
- //PayType = 0x21,
- CloundOrderId = null,
- Amount = this.amount,
- Volume = this.volume,
- //AmountPayable = this.amount,
- UploadState = 0,
- IsDelete = 0,
- Price = this.price,
- //RefundAmount = 0,
- UserName = "",
- PhoneNumber = "",
- PaymentName = "",
- PumpCode = this.pumpCode
- };
- }
- /// <summary>
- /// 补充授权订单数据
- /// </summary>
- /// <param name="order">当前数据库中订单数据</param>
- /// <returns></returns>
- public FccOrderInfo PaddingAuthorizationOrderData(FccOrderInfo order)
- {
- order.AuthorizationTime = this.dispenserTime;
- order.EndTime = this.endTime;
- order.Amount = this.amount;
- order.Volume = this.volume;
- order.Price = this.price;
- return order;
- }
- }
- }
|